mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
optimised Grid._bucketRemoveBody
This commit is contained in:
parent
5e3c629b90
commit
84136de6a4
1 changed files with 8 additions and 4 deletions
|
@ -264,16 +264,20 @@ var Common = require('../core/Common');
|
||||||
* @param {} body
|
* @param {} body
|
||||||
*/
|
*/
|
||||||
Grid._bucketRemoveBody = function(grid, bucket, body) {
|
Grid._bucketRemoveBody = function(grid, bucket, body) {
|
||||||
|
var gridPairs = grid.pairs,
|
||||||
|
pairId = Pair.id,
|
||||||
|
i;
|
||||||
|
|
||||||
// remove from bucket
|
// remove from bucket
|
||||||
bucket.splice(Common.indexOf(bucket, body), 1);
|
bucket.splice(Common.indexOf(bucket, body), 1);
|
||||||
|
|
||||||
|
var bucketLength = bucket.length;
|
||||||
|
|
||||||
// update pair counts
|
// update pair counts
|
||||||
for (var i = 0; i < bucket.length; i++) {
|
for (i = 0; i < bucketLength; i++) {
|
||||||
// keep track of the number of buckets the pair exists in
|
// keep track of the number of buckets the pair exists in
|
||||||
// important for _createActivePairsList to work
|
// important for _createActivePairsList to work
|
||||||
var bodyB = bucket[i],
|
var pair = gridPairs[pairId(body, bucket[i])];
|
||||||
pairId = Pair.id(body, bodyB),
|
|
||||||
pair = grid.pairs[pairId];
|
|
||||||
|
|
||||||
if (pair)
|
if (pair)
|
||||||
pair[2] -= 1;
|
pair[2] -= 1;
|
||||||
|
|
Loading…
Reference in a new issue