Page 1 of 1

Bounding box query

Posted: Sun Feb 14, 2010 9:05 am
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

Re: Bounding box query

Posted: Sun Feb 14, 2010 1:29 pm
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.

Re: Bounding box query

Posted: Sun Feb 14, 2010 3:42 pm
by carlessr
oh ok, sorry about that.