Erwin Coumans wrote:You can get access to which child shape is involved in a collision (or ray cast). For a collision, you can get the contact added callback to get to this information (see gContactAddedCallback in the Bullet/Demos/ConvexDecompositionDemo).
Edit: My only main question right now is, I was under the impression gContactAddedCallback was called too frequently to be used with game logic. The wiki says:
Be careful when using contact callbacks. They might be called too frequent for your purpose.
gContactAddedCallback:
This is called whenever a contact is added. From here, you can modify some properties [eg friction] of the contact point.
I am currently iterating over all contact manifolds in the suggested loop and dispatching collision events like that, are you saying (from a performance standpoint) it's acceptable to just use gContactAddedCallback instead of the contact manifold loop?
Ah thank you! It is good to know this is a possibility. In the past, you have said it's best to share one instance of btCollisionShape among duplicate rigid bodies. I could imagine setting the shape's user pointer to store information (like an ID) that describes what part it is.
For example,
btCompoundShape is composed of:
-btBoxShape (user pointer info: Enum::SPACESHIP::HULL)
-btBoxShape (user pointer info: Enum::SPACESHIP::ENGINE)
-btBoxShape (user pointer info: Enum::SPACESHIP::SHIELD_GENERATOR)
And then in the gContactAddedCallback, I further dispatch information about the specific collider hit. Hopefully something like that will work.
Should this ever do anything besides return true?
Code: Select all
bool MyCompoundChildShapeCallback(const btCollisionShape* pShape0, const btCollisionShape* pShape1)
{
return true;
}
Thank you for your time!