diff --git a/libs/openengine/bullet/BulletShapeLoader.cpp b/libs/openengine/bullet/BulletShapeLoader.cpp index 1e626f088..071a5ee8a 100644 --- a/libs/openengine/bullet/BulletShapeLoader.cpp +++ b/libs/openengine/bullet/BulletShapeLoader.cpp @@ -70,7 +70,6 @@ BulletShapeManager *BulletShapeManager::sThis = 0; BulletShapeManager *BulletShapeManager::getSingletonPtr() { - assert(sThis); return sThis; } @@ -82,6 +81,9 @@ BulletShapeManager &BulletShapeManager::getSingleton() BulletShapeManager::BulletShapeManager() { + assert(!sThis); + sThis = this; + mResourceType = "BulletShape"; // low, because it will likely reference other resources @@ -95,6 +97,8 @@ BulletShapeManager::~BulletShapeManager() { // and this is how we unregister it Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType); + + sThis = 0; } BulletShapePtr BulletShapeManager::load(const Ogre::String &name, const Ogre::String &group) diff --git a/libs/openengine/bullet/BulletShapeLoader.h b/libs/openengine/bullet/BulletShapeLoader.h index 5c70aeab9..d9bd5879a 100644 --- a/libs/openengine/bullet/BulletShapeLoader.h +++ b/libs/openengine/bullet/BulletShapeLoader.h @@ -120,6 +120,14 @@ protected: static BulletShapeManager *sThis; +private: + /** \brief Explicit private copy constructor. This is a forbidden operation.*/ + BulletShapeManager(const BulletShapeManager &); + + /** \brief Private operator= . This is a forbidden operation. */ + BulletShapeManager& operator=(const BulletShapeManager &); + + public: BulletShapeManager(); diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index d78e25ce7..b39ba53a2 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -251,7 +251,6 @@ namespace Physic PhysicEngine::~PhysicEngine() { - HeightFieldContainer::iterator hf_it = mHeightFieldMap.begin(); for (; hf_it != mHeightFieldMap.end(); ++hf_it) { @@ -293,6 +292,8 @@ namespace Physic delete broadphase; delete pairCache; delete mShapeLoader; + + delete BulletShapeManager::getSingletonPtr(); } void PhysicEngine::addHeightField(float* heights,