From d49a02abe5324b98e3da30405d395f2ae9a64841 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 2 Nov 2011 22:41:48 -0400 Subject: [PATCH] new insertBegin() --- apps/openmw/mwrender/objects.cpp | 21 +++++++++++++++++---- apps/openmw/mwrender/objects.hpp | 5 ++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index ed32a8786f..25308962db 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -4,12 +4,25 @@ using namespace MWRender; void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ - ptr.getRefData().setBaseNode(mBase); - assert (!mInsert); + Ogre::SceneNode* root = rend.getScene()->getRootSceneNode(); + Ogre::SceneNode* cellnode; + if(cellSceneNodes.find(ptr.getCell()) == cellSceneNodes.end()) + { + //Create the scenenode and put it in the map + cellnode = root->createChildSceneNode(); + cellSceneNodes[ptr.getCell()] = cellnode; + assert(!cellnode->getChildIterator()->begin()); //Is this right? + } + else + { + cellnode = (cellSceneNodes.find(ptr.getCell()))->second; + } + Ogre::SceneNode* insert = cellnode->createChildSceneNode(); + + ptr.getRefData().setBaseNode(insert); isStatic = static_; - // Create and place scene node for this object - mInsert = mBase->createChildSceneNode(); + } void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){ diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index e382fb05b2..53a3745ed7 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -8,11 +8,10 @@ namespace MWRender{ class Objects{ private: OEngine::Render::OgreRenderer &rend; - Ogre::SceneNode *mBase; - Ogre::SceneNode *mInsert; + std::map cellSceneNodes; bool isStatic; public: - Objects(OEngine::Render::OgreRenderer& _rend): rend(_rend){mBase = rend.getScene()->getRootSceneNode(); } + Objects(OEngine::Render::OgreRenderer& _rend): rend(_rend){} ~Objects(){} void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);