I have a physical object that can contain other physical objects inside and then it shouldn't collide with (only) those objects. So I derived a btCollisionDispatcher's descendant to filter those collisions. It worked fine in the project... But doesn't do now. Here it looks like:
Code: Select all
theBulletCollisionConfiguration = new btDefaultCollisionConfiguration();
theBulletCollisionDispatcher = new DerivedCollisionDispatcher(theBulletCollisionConfiguration);
btGImpactCollisionAlgorithm::registerAlgorithm(theBulletCollisionDispatcher);
btVector3 worldMin(-1000, -1000, -1000);
btVector3 worldMax(1000, 1000, 1000);
theBulletBroadphase = new btAxisSweep3(worldMin, worldMax);
theBulletConstraintSolver = new btSequentialImpulseConstraintSolver();
theBulletWorld = new btDiscreteDynamicsWorld(theBulletCollisionDispatcher,
theBulletBroadphase,
theBulletConstraintSolver,
theBulletCollisionConfiguration);
Code: Select all
class DerivedCollisionDispatcher : public btCollisionDispatcher
{
public:
typedef btCollisionDispatcher BaseClass;
DerivedCollisionDispatcher(btCollisionConfiguration* aCollisionConfiguration)
:
BaseClass(aCollisionConfiguration)
{};
virtual bool needsCollision(btCollisionObject* aBody0, btCollisionObject* aBody1);
protected:
virtual bool canCollideWith(btCollisionObject* aBody0, btCollisionObject* aBody1);
};