Panda3D Manual: Bullet Collision FilteringBy default all Bullet collision objects collide with all other Bullet collision objects. Here the term "collision objects" referns to objects which are derived from Bullet collision objects won't collide with visible geometry, that is objects of type GeomNode! Sometime we need more control over who collides with whom. This can be achieved by setting up collision filtering properly. Collision filtering is done using bitmasks, which get assigned to every collision object. Two objects collide if the two masks have at least one bit in common.
Bit MasksBullet makes use of the regular Panda3D collide masks, which are instances of #include "panda3d/bitMask.h" Given the above bit masks we would get the following results for collision: mask1 and mask2 = false mask1 vs. mask3 = true mask3 vs. mask4 = false mask3 vs. mask5 = true mask4 vs. mask5 = false
AssignmentThe example below shows a typical setup for a rigid body. Only the last line of the code block is new. Here we set the collide mask which specifies what other objects this rigid body collides with. BulletBoxShape *box_shape = new BulletBoxShape(LVecBase3f(0.5, 0.5, 0.5)); PandaNodes have two kinds of collide masks, a "from" collide mask and an "into" collide mask. Panda3D's internal collision system requires both masks set, but when using Bullet physics only the "into" collide mask is used. The following line is an alternate way to set the collide mask: np_box.node()->set_into_collide_mask(mask); This way of setting collide masks can be used for rigid bodies and ghost objects. Soft body collisions (and soft body vs. rigid body collisions) are more complex. Please see the manual pages about soft body configuration for details. © Carnegie Mellon University 2010 |