Bounding box query

Discuss any Chipmunk bugs here.
Post Reply
carlessr
Posts: 18
Joined: Wed Jan 27, 2010 3:15 pm
Contact:

Bounding box query

Post by carlessr »

Hi,

I've been using cpSpaceBBQuery, I noticed that when I placed my shapes in a given group, 1 for example I got returned every other group apart from the one I specified. I believe the bug is in the code below, I think !(shape->group) should be exclusive of the (context->group == shape->group)

Code: Select all

static void 
bbQueryHelper(cpBB *bb, cpShape *shape, bbQueryContext *context)
{
	if(
		!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
		cpBBintersects(*bb, shape->bb)
	){
		context->func(shape, context->data);
	}
}



becomes

Code: Select all

static void 
bbQueryHelper(cpBB *bb, cpShape *shape, bbQueryContext *context)
{
	if(
		!(shape->group) && (context->group == shape->group) && (context->layers&shape->layers) &&
		cpBBintersects(*bb, shape->bb)
	){
		context->func(shape, context->data);
	}
}

Cheers
Rich
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Bounding box query

Post by slembcke »

No, that's the correct behavior. It works exactly the same as collision shapes. You aren't specifying a group to query, you are specifying one to ignore. This is a lot more useful with ray and point queries maybe, but I wanted to be consistent. If you need to do further filtering, you can do so in your own callback.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
carlessr
Posts: 18
Joined: Wed Jan 27, 2010 3:15 pm
Contact:

Re: Bounding box query

Post by carlessr »

oh ok, sorry about that.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests