As a more concrete example, suppose we have: CompoundX [ A, CompoundY [ B, C] ] where A, B, and C are my basic collision shapes, and X and Y are my two compound objects. A collision happens with item B. In btCompoundCompoundCollisionAlgorithm.cpp, we first process the collision with the outer compound object, X:
Code: Select all
m_resultOut->setShapeIdentifiersA(-1,childIndex0); // this equals 1, since Y is at index 1 of X
m_resultOut->setShapeIdentifiersB(-1,childIndex1);
colAlgo->processCollision(&compoundWrap0,&compoundWrap1,m_dispatchInfo,m_resultOut);
Code: Select all
m_resultOut->setShapeIdentifiersA(-1,childIndex0); // this equals 0 now, since B is at index 0 of Y
m_resultOut->setShapeIdentifiersB(-1,childIndex1);
colAlgo->processCollision(&compoundWrap0,&compoundWrap1,m_dispatchInfo,m_resultOut);
Code: Select all
btManifoldPoint& pt = contactManifold->getContactPoint(j);
pt.m_index0 == 0; // Oops.
Due to the structure of the rest of the app it would be painful to try to flatten all my structures to only use a single compound shape in all cases. I'm wondering if there's some other approach I'm missing. One thought I had was to write a patch to include the root shape inside of the contact itself, so when iterating over the manifolds I'd have direct access to A, B, or C, but there might be an easier way.
Thanks!