From e4984955894d5c0593e966f454bda5bb7d095dec Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 14 Jun 2012 21:27:55 +0200 Subject: [PATCH 1/2] fix a leak: physics heightfield was only destroyed on cell change and not on exit --- libs/openengine/bullet/physic.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index a94434e5b..354b4d589 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -222,6 +222,14 @@ namespace Physic PhysicEngine::~PhysicEngine() { + HeightFieldContainer::iterator hf_it = mHeightFieldMap.begin(); + for (; hf_it != mHeightFieldMap.end(); ++hf_it) + { + dynamicsWorld->removeRigidBody(hf_it->second.mBody); + delete hf_it->second.mShape; + delete hf_it->second.mBody; + } + RigidBodyContainer::iterator rb_it = RigidBodyMap.begin(); for (; rb_it != RigidBodyMap.end(); ++rb_it) { From 0b850a2cb5280114fd003b3b8f6d6c899e9fb11b Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 15 Jun 2012 09:15:37 +0200 Subject: [PATCH 2/2] fix crash introduced by last commit --- libs/openengine/bullet/physic.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 354b4d589..f7caa54b4 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -328,6 +328,8 @@ namespace Physic dynamicsWorld->removeRigidBody(hf.mBody); delete hf.mShape; delete hf.mBody; + + mHeightFieldMap.erase(name); } RigidBody* PhysicEngine::createRigidBody(std::string mesh,std::string name,float scale)