Changing collision filter flags on the fly
Posted: Tue Jul 06, 2010 9:59 pm
I'm familiar with the tutorial on filtering collisions using bitmasks -->http://bulletphysics.org/mediawiki-1.5. ... _Filtering. In everything I have seen, it's always done when an object is set up and inserted into the collision world. But what if I want to change these masks on the fly, once the simulation is already running? Can I grab a reference to a collision object and modify its collision group and/or mask?
I saw some semi-related code in another thread that seemed to imply that to do this one must remove the object from the collision world and then re-add it with the newly desired collision group and mask values.
Ie.
Is this basically how it is done, or is there a preferred method for updating collision filtering on the fly? I imagine I could perhaps use one of the callback methods also described in the tutorial, but the bitmask method seems more ideal and simpler.
I saw some semi-related code in another thread that seemed to imply that to do this one must remove the object from the collision world and then re-add it with the newly desired collision group and mask values.
Ie.
Code: Select all
world->removeCollisionObject(collObj);
world->addCollisionObject(collObj, newFilterGroup, newFilterMask);
... // any other code to awaken/reactivate object