Page 1 of 1

Collision Filtering with contactTest

Posted: Tue Mar 13, 2018 6:04 pm
by pondwater

I'm using bullet physics strictly for collision detection. So far it's working out great.

I have my btCollisionWorld, I add btCollisionObjects with their various btCollisionShapes. Each frame I call btCollisionWorld::updateAabbs and when I need to I query against them using btCollisionWorld::contactTest along with my impl of btCollisionWorld::ContactResultCallback.

I'm now at the point where I need to incorporate collision filtering ( ... _Filtering).

I've created my bit groups and masks and supply them when I call btCollisionWorld::addCollisionObject. However, there doesn't seem to be any way to provide the bit group / masks to btCollisionWorld::contactTest.

Is there a way to utilize collision bit filters when using the btCollisionWorld::contactTest method? If so, how would I go about doing so, and if not, could any suggest the next best approach.


Re: Collision Filtering with contactTest

Posted: Tue Mar 13, 2018 8:34 pm
by drleviathan
You want your collision group/masks filtering to be obeyed during the contactTest() call?

If so: I think you would go about it like so:

(1) derive MyCustomContactSensorCallback from btCollisionWorld::ContactResultCallback

(2) override MyCustomContactSensorCallback::needsCollision(btBroadphaseProxy* proxy) to examine proxy.m_collisionFilterGroup and proxy.m_collisionFilterMask and return false when they disagree with the group/mask of your test.

For reference see the wiki page on collision callbacks and triggers.