From 4ff0efd5a2a1790f7f4407d732bf01ec3d2f00b3 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 8 Jul 2012 23:15:26 +0000 Subject: 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. --- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/gameengine/Physics/Bullet') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 21158a9461d..c7ba17e7f97 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -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(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; -- cgit v1.2.3