mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-23 09:26:51 -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) {
|
Sleeping.afterCollisions = function(pairs) {
|
||||||
// wake up bodies involved in collisions
|
// wake up bodies involved in collisions
|
||||||
for (var i = 0; i < pairs.length; i++) {
|
for (var i = 0; i < pairs.length; i++) {
|
||||||
var pair = pairs[i],
|
var pair = pairs[i];
|
||||||
collision = pair.collision,
|
|
||||||
|
// don't wake inactive pairs
|
||||||
|
if (!pair.isActive)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var collision = pair.collision,
|
||||||
bodyA = collision.bodyA,
|
bodyA = collision.bodyA,
|
||||||
bodyB = collision.bodyB;
|
bodyB = collision.bodyB;
|
||||||
|
|
||||||
|
// don't wake if at least one body is static
|
||||||
if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic)
|
if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue