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;
}