From e9da32c8864b9530925ff2c8d447cc6cafcffd7f Mon Sep 17 00:00:00 2001 From: liabru Date: Sun, 13 Aug 2023 15:31:52 +0100 Subject: [PATCH] added local pairs functions in Pairs.update --- src/collision/Pair.js | 2 +- src/collision/Pairs.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/collision/Pair.js b/src/collision/Pair.js index f1b4e6b..f965313 100644 --- a/src/collision/Pair.js +++ b/src/collision/Pair.js @@ -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) { diff --git a/src/collision/Pairs.js b/src/collision/Pairs.js index 99c02ca..2cb9d18 100644 --- a/src/collision/Pairs.js +++ b/src/collision/Pairs.js @@ -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, @@ -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 @@ -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