From 42e44ac1b5d095f6d0ecd7760b2f4597759bb983 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 6 Jun 2012 21:08:20 +0200 Subject: [PATCH] fixed some leaks --- apps/openmw/mwrender/renderingmanager.cpp | 4 +++- libs/openengine/bullet/physic.cpp | 15 ++++++++++++--- libs/openengine/bullet/physic.hpp | 10 ++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index a6f10fcd2..a771eb12e 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -97,7 +97,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const mTerrainManager = new TerrainManager(mRendering.getScene(), this); - //mSkyManager = 0; mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera()); mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode()); @@ -116,10 +115,13 @@ RenderingManager::~RenderingManager () delete mPlayer; delete mSkyManager; delete mDebugging; + delete mShaderHelper; + delete mShadows; delete mTerrainManager; delete mLocalMap; delete mOcclusionQuery; delete mCompositors; + delete mWater; } MWRender::SkyManager* RenderingManager::getSkyManager() diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index d30d5e9f1..a94434e5b 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -300,7 +300,13 @@ namespace Physic body->collide = true; body->getWorldTransform().setOrigin(btVector3( (x+0.5)*triSize*(sqrtVerts-1), (y+0.5)*triSize*(sqrtVerts-1), (maxh+minh)/2.f)); - addRigidBody(body); + HeightField hf; + hf.mBody = body; + hf.mShape = hfShape; + + mHeightFieldMap [name] = hf; + + dynamicsWorld->addRigidBody(body,COL_WORLD,COL_WORLD|COL_ACTOR_INTERNAL|COL_ACTOR_EXTERNAL); } void PhysicEngine::removeHeightField(int x, int y) @@ -309,8 +315,11 @@ namespace Physic + boost::lexical_cast(x) + "_" + boost::lexical_cast(y); - removeRigidBody(name); - deleteRigidBody(name); + HeightField hf = mHeightFieldMap [name]; + + dynamicsWorld->removeRigidBody(hf.mBody); + delete hf.mShape; + delete hf.mBody; } RigidBody* PhysicEngine::createRigidBody(std::string mesh,std::string name,float scale) diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index ba241b2b7..811572320 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -15,6 +15,7 @@ class btSequentialImpulseConstraintSolver; class btCollisionDispatcher; class btDiscreteDynamicsWorld; class btKinematicCharacterController; +class btHeightfieldTerrainShape; namespace BtOgre { @@ -115,6 +116,12 @@ namespace Physic bool collide; }; + struct HeightField + { + btHeightfieldTerrainShape* mShape; + RigidBody* mBody; + }; + /** * The PhysicEngine class contain everything which is needed for Physic. * It's needed that Ogre Resources are set up before the PhysicEngine is created. @@ -240,6 +247,9 @@ namespace Physic //the NIF file loader. BulletShapeLoader* mShapeLoader; + typedef std::map HeightFieldContainer; + HeightFieldContainer mHeightFieldMap; + typedef std::map RigidBodyContainer; RigidBodyContainer RigidBodyMap;