Oh, It's done actually. I just forgot to add it to the documentation. Whoops
http://code.google.com/p/chipmunk-physi ... ?r=677#187
Code: Select all
typedef void (*cpSpaceShapeQueryFunc)(cpShape *shape, cpContactPointSet *points, void *data);
cpBool cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data);
cpSpaceShapeQuery() queries the given shape against the space returning true if there are any overlapping shapes and calling the callback for each one. You can pass NULL as the query function if you only need the boolean value. The cpContactPointSet structure is fairly new, but is documented in the cpArbiter section of the documentation.
The shape you pass to cpSpaceShapeQuery() needs to be fully set up and attached to a body. You can just allocate the shape and body on the stack if you just want to make a quick shape query:
Code: Select all
// Must use the specific shape type here so enough stack space is allocated
cpCircleShape circle;
cpCircleShapeInit(&circle, &space.staticBody, 4.0f, cpv(offsetX, offsetY));
circle.shape.layers = layers;
circle.shape.group = group;
cpSpaceShapeQuery(space, (cpShape *)&circle, queryCallback, callbackData);
It's a little messy to do so I'm going to make functions like cpSpaceCircleQuery(), etc that hide this extra work. They just haven't gotten written yet.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/