Testing sleep static fixes

This commit is contained in:
Richard Davey 2023-11-10 13:44:47 +00:00
parent bd67ed38a5
commit f0d5280cf8
2 changed files with 44 additions and 13 deletions

View file

@ -246,6 +246,10 @@ var Body = require('./Body');
var position = Common.indexOf(composite.bodies, body);
if (position !== -1) {
Composite.removeBodyAt(composite, position);
// remove sleeping to allow pair removal
body.isSleeping = false;
body.sleepCounter = 0;
}
if (deep) {

View file

@ -53,6 +53,8 @@ var Common = require('../core/Common');
collisionActiveIndex = 0,
collision,
pair,
bodyA,
bodyB,
i;
for (i = 0; i < collisionsLength; i++) {
@ -90,11 +92,36 @@ var Common = require('../core/Common');
pair = pairsList[i];
if (pair.timeUpdated < timestamp) {
pairSetActive(pair, false, timestamp);
collisionEnd[collisionEndIndex++] = pair;
bodyA = pair.collision.bodyA;
bodyB = pair.collision.bodyB;
// if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic)
// {
// continue;
// }
// keep pair if it is sleeping but not both static
// if ((bodyA.isSleeping || bodyA.isStatic) || (bodyB.isSleeping || bodyB.isStatic) && !(bodyA.isStatic && bodyB.isStatic)) {
// pairSetActive(pair, true, timestamp);
// continue;
// }
// pairSetActive(pair, false, timestamp);
// collisionEnd[collisionEndIndex++] = pair;
// keep pair if it is sleeping but not both static
// if ((bodyA.isSleeping || bodyA.isStatic) && (bodyB.isSleeping || bodyB.isStatic)
// && !(bodyA.isStatic && bodyB.isStatic)) {
// continue;
// }
// remove inactive pairs
if (!pair.collision.bodyA.isSleeping && !pair.collision.bodyB.isSleeping) {
// if (!bodyA.isSleeping && !bodyB.isSleeping && !bodyA.isStatic && !bodyB.isStatic) {
if ((!bodyA.isSleeping || !bodyA.isStatic) && (!bodyB.isSleeping || !bodyB.isStatic)) {
console.log('deleted pair', bodyA, bodyB);
pairSetActive(pair, false, timestamp);
collisionEnd[collisionEndIndex++] = pair;
delete pairsTable[pair.id];
}
} else {