I'm fairly sure that function there is just for filtering possible collisions, so bullet knows whether or not to keep trying it.
What you want to do is loop through all the manifolds and contacts of those manifolds after you do a world->performDiscreteCollisionDetection() call (or in your case, after a stepSimulation call - if your framerate is low, you need to do it INSIDE the stepSimulation call, check the wiki for how to do that)
Code: Select all
int numManifolds = phyWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;++i)
{
btPersistentManifold* contactManifold = phyWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
if (pt.getDistance()<0.f)
{
/** Your collision logic can go in here */
}
}
}
That's the idea anyway.
If you want some kind of response, you'll need to use setUserPointer and getUserPointer to figure out how to handle the different object. I just created a physics response interface for this, and attached it when I create my object:
Code: Select all
class IPhysicsResponse
{
public:
IPhysicsResponse(void){}
virtual ~IPhysicsResponse(void){}
virtual void Collide(IPhysicsResponse *other)=0;
};
and then in the collision bit, simply something like:
Code: Select all
void* ptrA = obA->getUserPointer();
void* ptrB = obB->getUserPointer();
IPhysicsResponse *responseA = ptrA ? static_cast<IPhysicsResponse*>(ptrA) : NULL;
IPhysicsResponse *responseB = ptrB ? static_cast<IPhysicsResponse*>(ptrB) : NULL;
if (responseA)
responseA->Collide(responseB);
if (responseB)
responseB->Collide(responseA);
break;
Override the IPhysicsResponse with your own response class, and call setUserPointer when creating the rigid body and voila!
I've only just got this worked out myself, so I hope that gives you less headaches then I had!