From 00a2de432ab6904e993eb7f86be2cb4848cb10d6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 8 Nov 2012 18:48:07 +0100 Subject: [PATCH] fix BulletShapeLoader namespace --- .gitignore | 1 + components/nifbullet/bullet_nif_loader.cpp | 6 +++--- components/nifbullet/bullet_nif_loader.hpp | 4 ++-- libs/openengine/bullet/BulletShapeLoader.cpp | 16 +++++++++++----- libs/openengine/bullet/BulletShapeLoader.h | 13 ++++++++++--- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 26ba80e1a..9734ac35c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Makefile makefile data *.kdev4 +CMakeLists.txt.user diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index d2ec7ca82..42f6a8e68 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -69,7 +69,7 @@ btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 &v) void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) { - cShape = static_cast(resource); + cShape = static_cast(resource); resourceName = cShape->getName(); cShape->mCollide = false; mBoundingBox = NULL; @@ -314,8 +314,8 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags void ManualBulletShapeLoader::load(const std::string &name,const std::string &group) { // Check if the resource already exists - Ogre::ResourcePtr ptr = BulletShapeManager::getSingleton().getByName(name, group); + Ogre::ResourcePtr ptr = OEngine::Physic::BulletShapeManager::getSingleton().getByName(name, group); if (!ptr.isNull()) return; - BulletShapeManager::getSingleton().create(name,group,true,this); + OEngine::Physic::BulletShapeManager::getSingleton().create(name,group,true,this); } diff --git a/components/nifbullet/bullet_nif_loader.hpp b/components/nifbullet/bullet_nif_loader.hpp index 82ac227a0..2190fda1b 100644 --- a/components/nifbullet/bullet_nif_loader.hpp +++ b/components/nifbullet/bullet_nif_loader.hpp @@ -48,7 +48,7 @@ namespace NifBullet /** *Load bulletShape from NIF files. */ -class ManualBulletShapeLoader : public BulletShapeLoader +class ManualBulletShapeLoader : public OEngine::Physic::BulletShapeLoader { public: @@ -104,7 +104,7 @@ private: - BulletShape* cShape;//current shape + OEngine::Physic::BulletShape* cShape;//current shape btTriangleMesh *mTriMesh; btBoxShape *mBoundingBox; btBvhTriangleMeshShape* currentShape;//the shape curently under construction diff --git a/libs/openengine/bullet/BulletShapeLoader.cpp b/libs/openengine/bullet/BulletShapeLoader.cpp index dd3bca692..1e626f088 100644 --- a/libs/openengine/bullet/BulletShapeLoader.cpp +++ b/libs/openengine/bullet/BulletShapeLoader.cpp @@ -1,6 +1,8 @@ #include "BulletShapeLoader.h" - +namespace OEngine { +namespace Physic +{ BulletShape::BulletShape(Ogre::ResourceManager* creator, const Ogre::String &name, Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual, @@ -64,17 +66,18 @@ size_t BulletShape::calculateSize() const //============================================================================================================= -template<> BulletShapeManager *Ogre::Singleton::msSingleton = 0; +BulletShapeManager *BulletShapeManager::sThis = 0; BulletShapeManager *BulletShapeManager::getSingletonPtr() { - return msSingleton; + assert(sThis); + return sThis; } BulletShapeManager &BulletShapeManager::getSingleton() { - assert(msSingleton); - return(*msSingleton); + assert(sThis); + return(*sThis); } BulletShapeManager::BulletShapeManager() @@ -124,3 +127,6 @@ void BulletShapeLoader::loadResource(Ogre::Resource *resource) void BulletShapeLoader::load(const std::string &name,const std::string &group) {} + +} +} diff --git a/libs/openengine/bullet/BulletShapeLoader.h b/libs/openengine/bullet/BulletShapeLoader.h index 21d21777a..5c70aeab9 100644 --- a/libs/openengine/bullet/BulletShapeLoader.h +++ b/libs/openengine/bullet/BulletShapeLoader.h @@ -5,8 +5,10 @@ #include #include #include -//For some reason, Ogre Singleton cannot be used in another namespace, that's why there is no namespace here. -//But the risk of name collision seems pretty low here. + +namespace OEngine { +namespace Physic +{ /** *Define a new resource which describe a Shape usable by bullet.See BulletShapeManager for how to get/use them. @@ -107,7 +109,7 @@ public: *Important Note: i have no idea of what happen if you try to load two time the same resource without unloading. *It won't crash, but it might lead to memory leaks(I don't know how Ogre handle this). So don't do it! */ -class BulletShapeManager : public Ogre::ResourceManager, public Ogre::Singleton +class BulletShapeManager : public Ogre::ResourceManager { protected: @@ -116,6 +118,8 @@ protected: const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader, const Ogre::NameValuePairList *createParams); + static BulletShapeManager *sThis; + public: BulletShapeManager(); @@ -139,4 +143,7 @@ public: virtual void load(const std::string &name,const std::string &group); }; +} +} + #endif