0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

improve sleeping by ignoring inactive pairs

This commit is contained in:
liabru 2014-03-10 21:54:01 +00:00
parent 6516c5be8d
commit a368828e3f

View file

@ -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;