Retrieve the specific btCollisionShape (in a btCompoundShape hierarchy) during a contact
Posted: Tue Apr 09, 2019 10:21 am
Hello,
I have a "complex" btCompoundShape hierarchy structured like this:
Using the btPersistentManifold I can get the btCollisionObjects involved using the internal tick callback of btDynamicWorld:
l_obj0 and l_obj1 are the btRigidBody, in my case, and I can get the btCompoundShape (with getCollisionShape()) which is the root of the "complex" hierarchy cited above. I'm interested to find the specific btCollisionShape in the hierarchy (or the relative btCompoundShape direct father) which has the collision. I need to retrieve this information because I need to get my stored user pointer in the specific btCollisionShape (or btCompoundShape) in order to do some action when a contact happens.
Is this possible? Maybe is there the possibility to add specific callback to the element's hierarchy?
I found some attributes of the btManifoldPoint like m_index0/1 and m_part0/1 but inside the code there is this comment:
//BP mod, store contact triangles.
So I think those variables speaks about the number of contact in terms of triangles.
Can you help me?
Many thanks,
bye
I have a "complex" btCompoundShape hierarchy structured like this:
Code: Select all
btCompoundShape_0
|--- btCollisionShape_0
|--- btCompoundShape_1
|--- btCollisionShape_1
|--- btCompoundShape_2
|--- btCollisionShape_2
.....
Code: Select all
...
int numManifolds = p_dynamics_world->getDispatcher()->getNumManifolds();
for (unsigned int i = 0; i < numManifolds; i++) {
btPersistentManifold* l_contact_manifold = p_dynamics_world->getDispatcher()->getManifoldByIndexInternal(i);
const btCollisionObject *l_obj0 = l_contact_manifold->getBody0();
const btCollisionObject *l_obj1 = l_contact_manifold->getBody1();
int l_num_contacts = l_contact_manifold->getNumContacts();
for(unsigned int j = 0; j < l_num_contacts; j++) {
btManifoldPoint& pt = l_contact_manifold->getContactPoint(j);
.....
}
Is this possible? Maybe is there the possibility to add specific callback to the element's hierarchy?
I found some attributes of the btManifoldPoint like m_index0/1 and m_part0/1 but inside the code there is this comment:
//BP mod, store contact triangles.
So I think those variables speaks about the number of contact in terms of triangles.
Can you help me?
Many thanks,
bye