diff trunk/chipmunkd/cpSpace.d @ 23:4ceef5833c8c

updated to chipmunk 5.3.3
author Extrawurst
date Fri, 10 Dec 2010 02:10:27 +0100
parents df4ebc8add66
children 4541ca17975b
line wrap: on
line diff
--- a/trunk/chipmunkd/cpSpace.d	Thu Dec 09 22:25:04 2010 +0100
+++ b/trunk/chipmunkd/cpSpace.d	Fri Dec 10 02:10:27 2010 +0100
@@ -26,7 +26,6 @@
 	void *data;
 }
 
-enum CP_MAX_CONTACTS_PER_ARBITER = 6;
 struct cpContactBufferHeader {
 	cpTimestamp stamp;
 	cpContactBufferHeader *next;
@@ -80,7 +79,8 @@
 	// Linked list ring of contact buffers.
 	// Head is the newest buffer, and each buffer points to a newer buffer.
 	// Head wraps around and points to the oldest (tail) buffer.
-	cpContactBufferHeader* contactBuffersHead, _contactBuffersTail;
+	cpContactBufferHeader* contactBuffersHead;
+	deprecated cpContactBufferHeader* _contactBuffersTail_Deprecated;
 	
 	// List of buffers to be free()ed when destroying the space.
 	cpArray *allocatedBuffers;
@@ -162,8 +162,14 @@
 //// BB query callback function
 alias void function(cpShape *shape, void *data)cpSpaceBBQueryFunc;
 //void cpSpaceBBQuery(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryFunc func, void *data);
-//
-//
+
+// Shape query callback function
+alias void function(cpShape *shape, cpContactPointSet *points, void *data)cpSpaceShapeQueryFunc;
+//cpBool cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data);
+
+
+//void cpSpaceActivateShapesTouchingShape(cpSpace *space, cpShape *shape);
+
 //// Iterator function for iterating the bodies in a space.
 alias void function(cpBody *_body, void *data)cpSpaceBodyIterator;
 //void cpSpaceEachBody(cpSpace *space, cpSpaceBodyIterator func, void *data);
@@ -188,7 +194,7 @@
 	cpShape *a = shapes[0];
 	cpShape *b = shapes[1];
 	
-	return ((a == arb.private_a && b == arb.private_b) || (b == arb.private_a && a == arb.private_b));
+	return ((a == arb.a && b == arb.b) || (b == arb.a && a == arb.b));
 }
 
 // Transformation function for contactSet.
@@ -457,20 +463,6 @@
 	return shape;
 }
 
-static void
-activateShapesTouchingShapeHelper(cpShape *shape, void *unused)
-{
-	cpBodyActivate(shape._body);
-}
-
-static void
-activateShapesTouchingShape(cpSpace *space, cpShape *shape)
-{
-	// TODO this query should be more precise
-	// Use shape queries once they are written
-	cpSpaceBBQuery(space, shape.bb, shape.layers, shape.group, &activateShapesTouchingShapeHelper, null);
-}
-
 cpShape *
 cpSpaceAddStaticShape(cpSpace *space, cpShape *shape)
 {
@@ -481,7 +473,7 @@
 	if(!shape._body) shape._body = &space.staticBody;
 	
 	cpShapeCacheBB(shape);
-	activateShapesTouchingShape(space, shape);
+	cpSpaceActivateShapesTouchingShape(space, shape);
 	cpSpaceHashInsert(space.staticShapes, shape, shape.hashid, shape.bb);
 	
 	return shape;
@@ -490,7 +482,7 @@
 cpBody *
 cpSpaceAddBody(cpSpace *space, cpBody *_body)
 {
-	mixin(cpAssertWarn!("_body.m != INFINITY", "Did you really mean to add an infinite mass body to the space?",__FILE__,__LINE__));
+	mixin(cpAssertWarn!("!cpBodyIsStatic(_body)", "Static bodies cannot be added to a space as they are not meant to be simulated.",__FILE__,__LINE__));
 	assert(!_body.space, "Cannot add a body to a more than one space or to the same space twice.");
 //	cpAssertSpaceUnlocked(space); This should be safe as long as it's not from an integration callback
 	
@@ -525,8 +517,11 @@
 static cpBool
 contactSetFilterRemovedShape(cpArbiter *arb, removalContext *context)
 {
-	if(context.shape == arb.private_a || context.shape == arb.private_b){
-		arb.handler.separate(arb, context.space, arb.handler.data);
+	if(context.shape == arb.a || context.shape == arb.b){
+		if(arb.state != cpArbiterState.cpArbiterStateCached){
+			arb.handler.separate(arb, context.space, arb.handler.data);
+		}
+		
 		cpArrayPush(context.space.pooledArbiters, arb);
 		return cpFalse;
 	}
@@ -567,7 +562,7 @@
 	cpHashSetFilter(space.contactSet, cast(cpHashSetFilterFunc)&contactSetFilterRemovedShape, &context);
 	cpSpaceHashRemove(space.staticShapes, shape, shape.hashid);
 	
-	activateShapesTouchingShape(space, shape);
+	cpSpaceActivateShapesTouchingShape(space, shape);
 }
 
 void