mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-24 13:29:01 -05:00
optimised Grid._createActivePairsList
This commit is contained in:
parent
84136de6a4
commit
e4b3bcd69e
1 changed files with 9 additions and 9 deletions
|
@ -292,23 +292,23 @@ var Common = require('../core/Common');
|
|||
* @return [] pairs
|
||||
*/
|
||||
Grid._createActivePairsList = function(grid) {
|
||||
var pairKeys,
|
||||
pair,
|
||||
pairs = [];
|
||||
|
||||
// grid.pairs is used as a hashmap
|
||||
pairKeys = Common.keys(grid.pairs);
|
||||
var pair,
|
||||
gridPairs = grid.pairs,
|
||||
pairKeys = Common.keys(gridPairs),
|
||||
pairKeysLength = pairKeys.length,
|
||||
pairs = [],
|
||||
k;
|
||||
|
||||
// iterate over grid.pairs
|
||||
for (var k = 0; k < pairKeys.length; k++) {
|
||||
pair = grid.pairs[pairKeys[k]];
|
||||
for (k = 0; k < pairKeysLength; k++) {
|
||||
pair = gridPairs[pairKeys[k]];
|
||||
|
||||
// if pair exists in at least one bucket
|
||||
// it is a pair that needs further collision testing so push it
|
||||
if (pair[2] > 0) {
|
||||
pairs.push(pair);
|
||||
} else {
|
||||
delete grid.pairs[pairKeys[k]];
|
||||
delete gridPairs[pairKeys[k]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue