The broadphase first calculates a list of potential contacts via the AABB collision step. Then, looking at the call stack, we have:
Code: Select all
btCollisionDispatcher::dispatchAllCollisionPairs
btHashedOverlappingPairCache::processAllOverlappingPairs
btCollisionPairCallback::processOverlap
btCollisionDispatcher::defaultNearCallback
btCollisionDispatcher::findAlgorithm
Code: Select all
m_doubleDispatchContactPoints[...][...]->CreateCollisionAlgorithm(ci, body0Wrap, body1Wrap);
This function calls the constructor for the collision algorithm. Each collision algorithm constructor calls the dispatcher's getNewManifold method to create a new collision manifold.
Correct me if I'm wrong, but the implication of this is that a new collision algorithm is created for each potential collision pair, and in turn, a new collision manifold is created for each potential collision pair.
Wouldn't it be more efficient to only create a new collision manifold if the potential collision pair from the broadphase actually results in a true collision? What happens to the newly allocated collision manifolds in the dispatcher if the potential collision ends up getting rejected?
Also, it looks like the btCollisionAlgorithm::processCollision (... btManifoldResult*) btManifoldResult gets ignored in nearly all of the collision callbacks. Question: if this gets ignored, would it make the code clearer and more effecient if this parameter was removed?
Thanks