comparison trunk/chipmunkd/cpSpaceStep.d @ 23:4ceef5833c8c

updated to chipmunk 5.3.3
author Extrawurst
date Fri, 10 Dec 2010 02:10:27 +0100
parents c03a41d47b60
children 80058cee1a77
comparison
equal deleted inserted replaced
22:ed2c81f3d1df 23:4ceef5833c8c
212 // Hashset filter func to throw away old arbiters. 212 // Hashset filter func to throw away old arbiters.
213 static cpBool 213 static cpBool
214 contactSetFilter(cpArbiter *arb, cpSpace *space) 214 contactSetFilter(cpArbiter *arb, cpSpace *space)
215 { 215 {
216 if(space.sleepTimeThreshold != INFINITY){ 216 if(space.sleepTimeThreshold != INFINITY){
217 cpBody *a = arb.private_a._body; 217 cpBody *a = arb.a._body;
218 cpBody *b = arb.private_b._body; 218 cpBody *b = arb.b._body;
219 219
220 // both bodies are either static or sleeping 220 // both bodies are either static or sleeping
221 cpBool sleepingNow = 221 cpBool sleepingNow =
222 (cpBodyIsStatic(a) || cpBodyIsSleeping(a)) && 222 (cpBodyIsStatic(a) || cpBodyIsSleeping(a)) &&
223 (cpBodyIsStatic(b) || cpBodyIsSleeping(b)); 223 (cpBodyIsStatic(b) || cpBodyIsSleeping(b));
273 cpFloat dt_inv = 1.0f/dt; 273 cpFloat dt_inv = 1.0f/dt;
274 274
275 cpArray *bodies = space.bodies; 275 cpArray *bodies = space.bodies;
276 cpArray *constraints = space.constraints; 276 cpArray *constraints = space.constraints;
277 277
278 space.locked = cpTrue;
279
280 // Empty the arbiter list. 278 // Empty the arbiter list.
281 space.arbiters.num = 0; 279 space.arbiters.num = 0;
282 280
283 // Integrate positions. 281 // Integrate positions.
284 for(int i=0; i<bodies.num; i++){ 282 for(int i=0; i<bodies.num; i++){
286 _body.position_func(_body, dt); 284 _body.position_func(_body, dt);
287 } 285 }
288 286
289 // Pre-cache BBoxes and shape data. 287 // Pre-cache BBoxes and shape data.
290 cpSpaceHashEach(space.activeShapes, cast(cpSpaceHashIterator)&updateBBCache, null); 288 cpSpaceHashEach(space.activeShapes, cast(cpSpaceHashIterator)&updateBBCache, null);
289
290 space.locked = cpTrue;
291 291
292 // Collide! 292 // Collide!
293 cpSpacePushFreshContactBuffer(space); 293 cpSpacePushFreshContactBuffer(space);
294 if(space.staticShapes.handleSet.entries) 294 if(space.staticShapes.handleSet.entries)
295 cpSpaceHashEach(space.activeShapes, cast(cpSpaceHashIterator)&active2staticIter, space); 295 cpSpaceHashEach(space.activeShapes, cast(cpSpaceHashIterator)&active2staticIter, space);
296 cpSpaceHashQueryRehash(space.activeShapes, cast(cpSpaceHashQueryFunc)&queryFunc, space); 296 cpSpaceHashQueryRehash(space.activeShapes, cast(cpSpaceHashQueryFunc)&queryFunc, space);
297
298 space.locked = cpFalse;
297 299
298 // If body sleeping is enabled, do that now. 300 // If body sleeping is enabled, do that now.
299 if(space.sleepTimeThreshold != INFINITY){ 301 if(space.sleepTimeThreshold != INFINITY){
300 cpSpaceProcessComponents(space, dt); 302 cpSpaceProcessComponents(space, dt);
301 bodies = space.bodies; // rebuilt by processContactComponents() 303 bodies = space.bodies; // rebuilt by processContactComponents()
347 cpConstraint *constraint = cast(cpConstraint *)constraints.arr[j]; 349 cpConstraint *constraint = cast(cpConstraint *)constraints.arr[j];
348 constraint.klass.applyImpulse(constraint); 350 constraint.klass.applyImpulse(constraint);
349 } 351 }
350 } 352 }
351 353
352 space.locked = cpFalse; 354 space.locked = cpTrue;
353 355
354 // run the post solve callbacks 356 // run the post solve callbacks
355 for(int i=0; i<arbiters.num; i++){ 357 for(int i=0; i<arbiters.num; i++){
356 cpArbiter *arb = cast(cpArbiter *) arbiters.arr[i]; 358 cpArbiter *arb = cast(cpArbiter *) arbiters.arr[i];
357 359
358 cpCollisionHandler *handler = arb.handler; 360 cpCollisionHandler *handler = arb.handler;
359 handler.postSolve(arb, space, handler.data); 361 handler.postSolve(arb, space, handler.data);
360 362
361 arb.state = cpArbiterState.cpArbiterStateNormal; 363 arb.state = cpArbiterState.cpArbiterStateNormal;
362 } 364 }
365
366 space.locked = cpFalse;
363 367
364 // Run the post step callbacks 368 // Run the post step callbacks
365 // Loop because post step callbacks may create more post step callbacks 369 // Loop because post step callbacks may create more post step callbacks
366 while(space.postStepCallbacks){ 370 while(space.postStepCallbacks){
367 cpHashSet *callbacks = space.postStepCallbacks; 371 cpHashSet *callbacks = space.postStepCallbacks;