Skip to content

Commit

Permalink
added local pairs functions in Pairs.update
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Aug 13, 2023
1 parent 72bc203 commit e9da32c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/collision/Pair.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var Contact = require('./Contact');
collision.pair = pair;

var support = supports[0],
contact = contacts[0];
contact = contacts[0];

// reset first contact if support changed
if (contact.vertex !== support) {
Expand Down
15 changes: 9 additions & 6 deletions src/collision/Pairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ var Common = require('../core/Common');
* @param {number} timestamp
*/
Pairs.update = function(pairs, collisions, timestamp) {
var pairsList = pairs.list,
var pairUpdate = Pair.update,
pairCreate = Pair.create,
pairSetActive = Pair.setActive,
pairsTable = pairs.table,
pairsList = pairs.list,
pairsListLength = pairsList.length,
pairsListIndex = pairsListLength,
pairsTable = pairs.table,
collisionsLength = collisions.length,
collisionStart = pairs.collisionStart,
collisionEnd = pairs.collisionEnd,
collisionActive = pairs.collisionActive,
collisionsLength = collisions.length,
collisionStartIndex = 0,
collisionEndIndex = 0,
collisionActiveIndex = 0,
Expand All @@ -67,10 +70,10 @@ var Common = require('../core/Common');
}

// update the pair
Pair.update(pair, collision, timestamp);
pairUpdate(pair, collision, timestamp);
} else {
// pair did not exist, create a new pair
pair = Pair.create(collision, timestamp);
pair = pairCreate(collision, timestamp);
pairsTable[pair.id] = pair;

// add the new pair
Expand All @@ -87,7 +90,7 @@ var Common = require('../core/Common');
pair = pairsList[i];

if (pair.timeUpdated < timestamp) {
Pair.setActive(pair, false, timestamp);
pairSetActive(pair, false, timestamp);
collisionEnd[collisionEndIndex++] = pair;

// remove inactive pairs
Expand Down

0 comments on commit e9da32c

Please sign in to comment.