# HG changeset patch # User Extrawurst # Date 1292455986 -3600 # Node ID 80058cee1a7789603205c734e728966d3d1e520f # Parent 4541ca17975b853d1324552563b8fd278f702a4f updated to chipmunk 5.3.4 diff -r 4541ca17975b -r 80058cee1a77 trunk/chipmunkd/cpSpace.d --- a/trunk/chipmunkd/cpSpace.d Mon Dec 13 21:40:56 2010 +0100 +++ b/trunk/chipmunkd/cpSpace.d Thu Dec 16 00:33:06 2010 +0100 @@ -1,4 +1,3 @@ - // written in the D programming language module chipmunkd.cpSpace; @@ -58,7 +57,7 @@ // *** Internally Used Fields // When the space is locked, you should not add or remove objects; - cpBool locked; + int locked; // Time stamp. Is incremented on every call to cpSpaceStep(). cpTimestamp stamp; @@ -73,6 +72,9 @@ // List of groups of sleeping bodies. cpArray *sleepingComponents; + // List of bodies that have been flagged to be awoken. + cpArray *rousedBodies; + // List of active arbiters for the impulse solver. cpArray* arbiters, pooledArbiters; @@ -278,6 +280,8 @@ space.bodies = cpArrayNew(0); space.sleepingComponents = cpArrayNew(0); + space.rousedBodies = cpArrayNew(0); + space.sleepTimeThreshold = INFINITY; space.idleSpeedThreshold = 0.0f; @@ -315,6 +319,7 @@ cpArrayFree(space.bodies); cpArrayFree(space.sleepingComponents); + cpArrayFree(space.rousedBodies); cpArrayFree(space.constraints); @@ -448,7 +453,7 @@ cpSpaceAddShape(cpSpace *space, cpShape *shape) { cpBody *_body = shape._body; - if(!_body || _body == &space.staticBody) return cpSpaceAddStaticShape(space, shape); + if(!_body || cpBodyIsStatic(_body)) return cpSpaceAddStaticShape(space, shape); assert(!cpHashSetFind(space.activeShapes.handleSet, shape.hashid, shape), "Cannot add the same shape more than once."); @@ -623,3 +628,51 @@ cpSpaceHashRehashObject(space.staticShapes, shape, shape.hashid); } +void +cpSpaceEachBody(cpSpace *space, cpSpaceBodyIterator func, void *data) +{ + cpArray *bodies = space.bodies; + + for(int i=0; i= 0, "Internal error:Space lock underflow."); + + if(!space.locked){ + cpArray *waking = space.rousedBodies; + for(int i=0, count=waking.num; i