btPersistentManifold::getNumContacts always returns zero
Posted: Sat Jun 15, 2019 4:36 pm
I want to get access to the contact point details for a collision. The problem is, whenever I try to get the number of contacts from a manifold, via btPersistentManifold::getNumContacts, the result is always zero. Here's how I'm getting the contacts:
The strange thing is, when I debug, I can see that there are 4 btManifoldPoint records inside contactManifold->m_pointCache. What am I missing here?
Code: Select all
// these methods are part of a C wrapper so I can use bullet using the C FFI
int btDynamicsWorldGetCollisionCount(btDynamicsWorldRef* world) {
return ((btDynamicsWorld*)world)->getDispatcher()->getNumManifolds();
}
btContact btDynamicsWorldGetCollision(btDynamicsWorldRef* world, int index) {
btPersistentManifold* contactManifold = ((btDynamicsWorld*)world)->getDispatcher()->getManifoldByIndexInternal(index);
btContact contact; // this is a struct defined to expose contact info to this C wrapper
contact.objectA = contactManifold->getBody0()->getUserPointer();
contact.objectB = contactManifold->getBody1()->getUserPointer();
contact.manifoldRef = (btContactManifoldRef*)contactManifold;
return contact;
}
int btContactManifordGetContactCount(btContactManifoldRef* manifold) {
btPersistentManifold* contactManifold = (btPersistentManifold*) manifold;
int count = contactManifold->getNumContacts();
return count;
}