Collision filtering issue

aliceKittyEars
Posts: 2
Joined: Tue Aug 12, 2008 2:04 pm

Collision filtering issue

Post by aliceKittyEars »

Hi all,
I'm running a simulation using bullet and have implemented collision filtering. Which seems to work until I disable collisions using the filter. If any collisions occur - which should be filtered out - further collisions after re-enabling the filter are never reported. Right, I've confused myself.

Here's a rough breakdown of the process:

Code: Select all

// The world object is using group 1

// Set object collisions off
((game object)) ->getBroadphaseProxy()->m_collisionFilterGroup = 2;
((game object)) ->getBroadphaseProxy()->m_collisionFilterMask = 0;

// Update simulation (Part 1)
// Simulation is updated a few times here to calculate a trajectory.

// Set object collisions on
((game object)) ->getBroadphaseProxy()->m_collisionFilterGroup = 2;
((game object)) ->getBroadphaseProxy()->m_collisionFilterMask = 1;

// Update simulation as normal (Part 2)
//Eek "collisions" during part 1 have stopped actual collisions in part 2 working.
//We know this because if no collisions occur in part 1, then the collisions in part 2 are correctly resolved, as expected.
I've had a dig through the bullet source and failed to find anything conclusive. Does bullet cache any collision information? I'm beginning to get bored.

Sorry for the lack of information! I need to go! :D

~Alice
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision filtering issue

Post by Erwin Coumans »

Make sure to remove the collision object / rigid body from the dynamics world, before changing its collision filter. Add it back to the dynamics world after the filter has been updated.

We should add some assert to notify the user of this.

Hope this helps,
Erwin
aliceKittyEars
Posts: 2
Joined: Tue Aug 12, 2008 2:04 pm

Re: Collision filtering issue

Post by aliceKittyEars »

Yes, that fixed it, thank you ^_^

Just a quick question, is there any reason there isn't a stub in the btDynamicsWorld base class for adding a rigid body with filter properties (as in btDiscreteDynamicsWorld)? Actually, I just looked and notcied btSimpleDynamicsWorld doesn't have it either, even though they both pass through the same btCollisionWorld::addCollisionObject() function. As this function sets the filters by default, is there any reason to not expose them to the user for all dynamic worlds?

I'm still using version 2.69, and will be for a little while; so if you've already changed this, then ignore me ^_^

Thanks for your prompt reply.

~Alice