I've been tracing the GIMPACT concave demo with Bullet v2.5.8, and I've noted that the problem with the Pool Allocator comes when releaseManifold is called.
The btGImpactCollisionAlgorithm class calls releaseManifold very often. All problems begin when this function is called:
Code: Select all
SIMD_FORCE_INLINE void clearCache()
{
if(m_manifoldPtr)
{
//m_manifoldPtr->clearManifold();
m_dispatcher->releaseManifold(m_manifoldPtr);
m_manifoldPtr = NULL;
}
destroyConvexAlgorithm();
m_triface0 = -1;
m_part0 = -1;
m_triface1 = -1;
m_part1 = -1;
}
And these are the cases when clearCache() is called:
- When creating a new Manifold point:
Code: Select all
SIMD_FORCE_INLINE btPersistentManifold* newContactManifold( btCollisionObject* body0,btCollisionObject* body1) { clearCache(); m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1); return m_manifoldPtr; }
- When processing the collision:
Code: Select all
void btGImpactCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) { clearCache(); m_resultOut = resultOut; m_dispatchInfo = &dispatchInfo; ... ... ...
- When destroying the algorithm:
Code: Select all
btGImpactCollisionAlgorithm::~btGImpactCollisionAlgorithm() { clearCache(); }
That's the way I've implemented it because I thought it as the correctly way at that moment. But now happens that the new btPoolAllocator class gives problems when releasing memory sometimes.
So the question is, in which case I need to call m_dispatcher->releaseManifold(m_manifoldPtr) ?