Revert "Testing sleep static fixes"

This reverts commit f0d5280cf8.
This commit is contained in:
Richard Davey 2023-11-10 14:58:02 +00:00
parent 9fe9f4536b
commit 1cae6391b3
2 changed files with 13 additions and 44 deletions

View file

@ -28,13 +28,13 @@ var Body = require('./Body');
* @return {composite} A new composite
*/
Composite.create = function(options) {
return Common.extend({
return Common.extend({
id: Common.nextId(),
type: 'composite',
parent: null,
isModified: false,
bodies: [],
constraints: [],
bodies: [],
constraints: [],
composites: [],
label: 'Composite',
plugin: {},
@ -47,7 +47,7 @@ var Body = require('./Body');
};
/**
* Sets the composite's `isModified` flag.
* Sets the composite's `isModified` flag.
* If `updateParents` is true, all parents will be set (default: false).
* If `updateChildren` is true, all children will be set (default: false).
* @method setModified
@ -246,10 +246,6 @@ 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) {
@ -341,7 +337,7 @@ var Body = require('./Body');
Composite.clear(composite.composites[i], keepStatic, true);
}
}
if (keepStatic) {
composite.bodies = composite.bodies.filter(function(body) { return body.isStatic; });
} else {
@ -452,8 +448,8 @@ var Body = require('./Body');
if (!objects)
return null;
object = objects.filter(function(object) {
return object.id.toString() === id.toString();
object = objects.filter(function(object) {
return object.id.toString() === id.toString();
});
return object.length === 0 ? null : object[0];
@ -492,7 +488,7 @@ var Body = require('./Body');
};
/**
* Translates all children in the composite by a given vector relative to their current positions,
* Translates all children in the composite by a given vector relative to their current positions,
* without imparting any velocity.
* @method translate
* @param {composite} composite
@ -526,7 +522,7 @@ var Body = require('./Body');
var body = bodies[i],
dx = body.position.x - point.x,
dy = body.position.y - point.y;
Body.setPosition(body, {
x: point.x + (dx * cos - dy * sin),
y: point.y + (dx * sin + dy * cos)
@ -554,7 +550,7 @@ var Body = require('./Body');
var body = bodies[i],
dx = body.position.x - point.x,
dy = body.position.y - point.y;
Body.setPosition(body, {
x: point.x + dx * scaleX,
y: point.y + dy * scaleY

View file

@ -53,8 +53,6 @@ var Common = require('../core/Common');
collisionActiveIndex = 0,
collision,
pair,
bodyA,
bodyB,
i;
for (i = 0; i < collisionsLength; i++) {
@ -92,36 +90,11 @@ var Common = require('../core/Common');
pair = pairsList[i];
if (pair.timeUpdated < timestamp) {
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;
// }
pairSetActive(pair, false, timestamp);
collisionEnd[collisionEndIndex++] = pair;
// remove inactive pairs
// 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;
if (!pair.collision.bodyA.isSleeping && !pair.collision.bodyB.isSleeping) {
delete pairsTable[pair.id];
}
} else {