mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-26 13:49:01 -05:00
improve sleeping by ignoring inactive pairs
This commit is contained in:
parent
6516c5be8d
commit
a368828e3f
1 changed files with 8 additions and 2 deletions
|
@ -54,11 +54,17 @@ var Sleeping = {};
|
|||
Sleeping.afterCollisions = function(pairs) {
|
||||
// wake up bodies involved in collisions
|
||||
for (var i = 0; i < pairs.length; i++) {
|
||||
var pair = pairs[i],
|
||||
collision = pair.collision,
|
||||
var pair = pairs[i];
|
||||
|
||||
// don't wake inactive pairs
|
||||
if (!pair.isActive)
|
||||
continue;
|
||||
|
||||
var collision = pair.collision,
|
||||
bodyA = collision.bodyA,
|
||||
bodyB = collision.bodyB;
|
||||
|
||||
// don't wake if at least one body is static
|
||||
if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic)
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Reference in a new issue