Code: Select all
mDynamicsWorld->stepSimulation(ms/1000.0f,2);
int numManifolds = mDynamicsWorld->getDispatcher()->getNumManifolds();
for(int i = 0;i < numManifolds;i++)
{
btPersistentManifold* contact = mDynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
if (contact->getNumContacts())
{
btRigidBody* a = dynamic_cast<btRigidBody*>((btRigidBody*)contact->getBody0());
btRigidBody* b = dynamic_cast<btRigidBody*>((btRigidBody*)contact->getBody1());
EntBase* ent1 = (EntBase*)a->getUserPointer();
EntBase* ent2 = (EntBase*)b->getUserPointer();
if (ent1 && ent2)
{
ent1->Collide(ent2);
}
}
}
I have 3 objects, my ground, a box target and a box object thats being thrown. If it hits the target box I should get a collision, but sometimes it doesn't work, and then I get the ground collision. Any ideas if the above code looks correct?
Thanks!
Jeff.