I have a compound shape with a bunch of child shapes, for each child-shape I also attach a small user data object containing some specific data for that child shape.
As an (simplified..) example , imagine a compound shape made out of 4 tiles. Each tiles has some user data value giving a certain amount of points:
Code: Select all
------------------------------
| || |
| userData{4} || userData{1} |
| || |
--------------++---------------
--------------++---------------
| || |
| userData{5} || userData{7} |
| || |
-------------------------------
At the moment, say a ball, collides with 1 of the subshapes of the compound shape I need to get the userdata of that child-shape.
Q: how do I get that child-shape user data back from the collision manifolds?
ie:
Code: Select all
int numManifolds = m_collisionWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = m_collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
int numContacts = contactManifold->getNumContacts();
btCollisionObject* object_A = static_cast<btCollisionObject*>(contactManifold->getBody0());
// somehow get the childshape making the actual collision
// get userdata from childshape.
// do stuff with userdata
}