Fixing a memory leak when using Bullet's btGImpactMeshShape for triangle meshes (e.g., rigid bodies). The physic controller's free was only handling the case where regular triangle meshes were used.

This commit is contained in:
Mitchell Stokes
2012-07-08 23:15:26 +00:00
parent 75a5eab8d1
commit 4ff0efd5a2

View File

@@ -539,6 +539,13 @@ static void DeleteBulletShape(btCollisionShape* shape, bool free)
if (meshInterface)
delete meshInterface;
}
else if (shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
{
btGImpactMeshShape* meshShape = static_cast<btGImpactMeshShape*>(shape);
btStridingMeshInterface* meshInterface = meshShape->getMeshInterface();
if (meshInterface)
delete meshInterface;
}
if (free) {
delete shape;
}
@@ -2125,7 +2132,6 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, b
&m_vertexArray[0],
3*sizeof(btScalar)
);
btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(indexVertexArrays);
gimpactShape->setMargin(margin);
collisionShape = gimpactShape;