diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4535fd820b..8ca57feb5b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -74,7 +74,7 @@ void OMW::Engine::updateFocusReport (float duration) mFocusTDiff = 0; std::string name; - + std::string handle = mEnvironment.mWorld->getFacedHandle(); if (!handle.empty()) @@ -84,7 +84,7 @@ void OMW::Engine::updateFocusReport (float duration) if (!ptr.isEmpty()){ name = MWWorld::Class::get (ptr).getName (ptr); - } + } } if (name!=mFocusName) @@ -287,7 +287,7 @@ void OMW::Engine::setReportFocus (bool report) void OMW::Engine::go() { - mFocusTDiff = 0; + mFocusTDiff = 0; assert (!mEnvironment.mWorld); assert (!mCellName.empty()); assert (!mMaster.empty()); @@ -416,41 +416,36 @@ void OMW::Engine::go() void OMW::Engine::activate() { - // TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside - // the input handling functions. Looks like this will require an OpenEngine modification. - try + std::string handle = mEnvironment.mWorld->getFacedHandle(); + + if (handle.empty()) + return; + + MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); + + if (ptr.isEmpty()) + return; + + MWScript::InterpreterContext interpreterContext (mEnvironment, + &ptr.getRefData().getLocals(), ptr); + + boost::shared_ptr action = + MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(), + mEnvironment); + + interpreterContext.activate (ptr, action); + + std::string script = MWWorld::Class::get (ptr).getScript (ptr); + + if (!script.empty()) { - std::string handle = mEnvironment.mWorld->getFacedHandle(); - if (handle.empty()) - return; - MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); - if (ptr.isEmpty()) - return; - MWScript::InterpreterContext interpreterContext (mEnvironment, - &ptr.getRefData().getLocals(), ptr); - - boost::shared_ptr action = - MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(), - mEnvironment); - - interpreterContext.activate (ptr, action); - - std::string script = MWWorld::Class::get (ptr).getScript (ptr); - - if (!script.empty()) - { - mEnvironment.mWorld->getLocalScripts().setIgnore (ptr); - mScriptManager->run (script, interpreterContext); - } - - if (!interpreterContext.hasActivationBeenHandled()) - { - interpreterContext.executeActivation(); - } + mEnvironment.mWorld->getLocalScripts().setIgnore (ptr); + mScriptManager->run (script, interpreterContext); } - catch (const std::exception& e) + + if (!interpreterContext.hasActivationBeenHandled()) { - std::cerr << "Activation failed: " << e.what() << std::endl; + interpreterContext.executeActivation(); } } diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index ade1127af1..757d86f3b9 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -31,11 +31,11 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ Ogre::SceneNode* cellnode; if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end()) { - //Create the scenenode and put it in the map - cellnode = root->createChildSceneNode(); + //Create the scenenode and put it in the map + cellnode = root->createChildSceneNode(); mCellSceneNodes[ptr.getCell()] = cellnode; - } - else + } + else { cellnode = mCellSceneNodes[ptr.getCell()]; } @@ -64,7 +64,7 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ ptr.getRefData().setBaseNode(insert); isStatic = static_; - + } void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){ Ogre::SceneNode* insert = ptr.getRefData().getBaseNode(); @@ -79,8 +79,8 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){ } else { - Ogre::StaticGeometry* sg; - if(mSG.find(ptr.getCell()) == mSG.end()) + Ogre::StaticGeometry* sg = 0; + if(mSG.find(ptr.getCell()) == mSG.end()) { uniqueID = uniqueID +1; sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); @@ -95,10 +95,10 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){ sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale()); sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000)); - + mRend.getScene()->destroyEntity(ent); } - + } void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){ @@ -135,30 +135,42 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f insert->attachObject(light); } -void Objects::deleteObject (const std::string& handle) +bool Objects::deleteObject (const MWWorld::Ptr& ptr) { - if (!handle.empty()) + if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode()) { - Ogre::SceneNode *node = mRend.getScene()->getSceneNode (handle); - node->removeAndDestroyAllChildren(); - mRend.getScene()->destroySceneNode (node); + Ogre::SceneNode *parent = base->getParentSceneNode(); + + for (std::map::const_iterator iter ( + mCellSceneNodes.begin()); iter!=mCellSceneNodes.end(); ++iter) + if (iter->second==parent) + { + base->removeAndDestroyAllChildren(); + mRend.getScene()->destroySceneNode (base); + ptr.getRefData().setBaseNode (0); + return true; + } + + return false; } + + return true; } void Objects::removeCell(MWWorld::Ptr::CellStore* store){ - if(mCellSceneNodes.find(store) != mCellSceneNodes.end()) + if(mCellSceneNodes.find(store) != mCellSceneNodes.end()) { Ogre::SceneNode* base = mCellSceneNodes[store]; base->removeAndDestroyAllChildren(); mCellSceneNodes.erase(store); mRend.getScene()->destroySceneNode(base); - base = 0; + base = 0; } if(mSG.find(store) != mSG.end()) { - Ogre::StaticGeometry* sg = mSG[store]; + Ogre::StaticGeometry* sg = mSG[store]; mSG.erase(store); mRend.getScene()->destroyStaticGeometry (sg); sg = 0; @@ -167,9 +179,7 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store){ void Objects::buildStaticGeometry(ESMS::CellStore& cell){ if(mSG.find(&cell) != mSG.end()) { - Ogre::StaticGeometry* sg = mSG[&cell]; - sg->build(); + Ogre::StaticGeometry* sg = mSG[&cell]; + sg->build(); } } - - diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index e7fb716b85..6f36e48497 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -10,9 +10,9 @@ namespace MWRender{ class Objects{ - OEngine::Render::OgreRenderer &mRend; - std::map mCellSceneNodes; - std::map mSG; + OEngine::Render::OgreRenderer &mRend; + std::map mCellSceneNodes; + std::map mSG; Ogre::SceneNode* mwRoot; bool isStatic; static int uniqueID; @@ -36,14 +36,13 @@ public: void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius); - void deleteObject (const std::string& handle); + + bool deleteObject (const MWWorld::Ptr& ptr); + ///< \return found? + void removeCell(MWWorld::Ptr::CellStore* store); void buildStaticGeometry(ESMS::CellStore &cell); void setMwRoot(Ogre::SceneNode* root); - - - /// insert a light related to the most recent insertBegin call. - }; } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index b86f73ba49..b18415e659 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -21,14 +21,11 @@ namespace MWRender { -RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine) :rend(_rend), mDebugging(engine), objects(rend) +RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine) +:rend(_rend), objects(rend), mDebugging(engine) { - - - - //std::cout << "ONE"; - rend.createScene("PlayerCam", 55, 5); - mSkyManager = MWRender::SkyManager::create(rend.getWindow(), rend.getCamera(), resDir); + rend.createScene("PlayerCam", 55, 5); + mSkyManager = MWRender::SkyManager::create(rend.getWindow(), rend.getCamera(), resDir); // Set default mipmap level (NB some APIs ignore this) TextureManager::getSingleton().setDefaultNumMipmaps(5); @@ -41,7 +38,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const // the screen (when x is to the right.) This is the orientation that // Morrowind uses, and it automagically makes everything work as it // should. - //std::cout << "TWO"; SceneNode *rt = rend.getScene()->getRootSceneNode(); mwRoot = rt->createChildSceneNode(); mwRoot->pitch(Degree(-90)); @@ -57,6 +53,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const cameraPitchNode->attachObject(rend.getCamera()); mPlayer = new MWRender::Player (rend.getCamera(), playerNode); + mWater = 0; //std::cout << "Three"; @@ -64,24 +61,23 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const RenderingManager::~RenderingManager () { - delete mPlayer; + delete mPlayer; delete mSkyManager; } MWRender::Npcs& RenderingManager::getNPCs(){ - return npcs; + return npcs; } MWRender::Objects& RenderingManager::getObjects(){ - return objects; + return objects; } MWRender::Creatures& RenderingManager::getCreatures(){ - return creatures; + return creatures; } MWRender::Player& RenderingManager::getPlayer(){ return (*mPlayer); } - void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){ objects.removeCell(store); @@ -92,17 +88,33 @@ void RenderingManager::removeWater (){ mWater = 0; } } + +void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store) +{ + objects.buildStaticGeometry (*store); +} + void RenderingManager::addObject (const MWWorld::Ptr& ptr){ const MWWorld::Class& class_ = MWWorld::Class::get (ptr); class_.insertObjectRendering(ptr, *this); -} -void RenderingManager::removeObject (const MWWorld::Ptr& ptr){ } -void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position){ - +void RenderingManager::removeObject (const MWWorld::Ptr& ptr) +{ + if (!objects.deleteObject (ptr)) + { + /// \todo delete non-object MW-references + } } + +void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position) +{ + /// \todo move this to the rendering-subsystems + rend.getScene()->getSceneNode (ptr.getRefData().getHandle())-> + setPosition (position); +} + void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale){ } @@ -112,17 +124,12 @@ void RenderingManager::rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quate void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store){ } -void RenderingManager::setPhysicsDebugRendering (bool){ -} -bool RenderingManager::getPhysicsDebugRendering() const{ - return true; -} void RenderingManager::update (float duration){ } -void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store){ +void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ if(store->cell->data.flags & store->cell->HasWater){ if(mWater == 0) mWater = new MWRender::Water(rend.getCamera(), store->cell); @@ -168,7 +175,7 @@ void RenderingManager::skySetMoonColour (bool red) mSkyManager->setMoonColour(red); } bool RenderingManager::toggleRenderMode(int mode){ - return mDebugging.toggleRenderMode(mode); + return mDebugging.toggleRenderMode(mode); } void RenderingManager::configureFog(ESMS::CellStore &mCell) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index e35a807516..217b3df665 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -4,7 +4,6 @@ #include "sky.hpp" #include "debugging.hpp" -//Commented out for now, possibly do an ifdef if necessary, cla #include "../mwworld/class.hpp" @@ -45,30 +44,42 @@ namespace MWWorld namespace MWRender { - + class RenderingManager: private RenderingInterface { - + private: + + virtual MWRender::Npcs& getNPCs(); + virtual MWRender::Creatures& getCreatures(); + virtual MWRender::Objects& getObjects(); public: RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine); virtual ~RenderingManager(); - virtual MWRender::Npcs& getNPCs(); - virtual MWRender::Creatures& getCreatures(); - virtual MWRender::Objects& getObjects(); - virtual MWRender::Player& getPlayer(); - void cellAdded (MWWorld::Ptr::CellStore *store); - void toggleLight(); - bool toggleRenderMode(int mode); - void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this? + + virtual MWRender::Player& getPlayer(); /// \todo move this to private again as soon as + /// MWWorld::Player has been rewritten to not need access + /// to internal details of the rendering system anymore + + void toggleLight(); + bool toggleRenderMode(int mode); + + void removeCell (MWWorld::Ptr::CellStore *store); + + /// \todo this function should be removed later. Instead the rendering subsystems should track + /// when rebatching is needed and update automatically at the end of each frame. + void cellAdded (MWWorld::Ptr::CellStore *store); + void waterAdded(MWWorld::Ptr::CellStore *store); + + void removeWater(); void addObject (const MWWorld::Ptr& ptr); void removeObject (const MWWorld::Ptr& ptr); - + void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position); void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale); void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation); @@ -76,12 +87,9 @@ class RenderingManager: private RenderingInterface { /// \param store Cell the object was in previously (\a ptr has already been updated to the new cell). void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store); - - void setPhysicsDebugRendering (bool); - bool getPhysicsDebugRendering() const; - + void update (float duration); - + void skyEnable (); void skyDisable (); void skySetHour (double hour); @@ -89,15 +97,12 @@ class RenderingManager: private RenderingInterface { int skyGetMasserPhase() const; int skyGetSecundaPhase() const; void skySetMoonColour (bool red); - OEngine::Render::OgreRenderer& getOgreRenderer(){return rend;} - Ogre::SceneManager *getMgr() { return rend.getScene(); } - Ogre::SceneNode *getRoot() { return mwRoot; } - void configureAmbient(ESMS::CellStore &mCell); - /// configure fog according to cell + void configureAmbient(ESMS::CellStore &mCell); + /// configure fog according to cell void configureFog(ESMS::CellStore &mCell); - + private: - + void setAmbientMode(); SkyManager* mSkyManager; OEngine::Render::OgreRenderer &rend; @@ -107,23 +112,23 @@ class RenderingManager: private RenderingInterface { MWRender::Water *mWater; MWRender::Objects objects; - // 0 normal, 1 more bright, 2 max + + + // 0 normal, 1 more bright, 2 max int mAmbientMode; Ogre::ColourValue mAmbientColor; - /// Root node for all objects added to the scene. This is rotated so - /// that the OGRE coordinate system matches that used internally in - /// Morrowind. - Ogre::SceneNode *mwRoot; - Ogre::RaySceneQuery *mRaySceneQuery; + /// Root node for all objects added to the scene. This is rotated so + /// that the OGRE coordinate system matches that used internally in + /// Morrowind. + Ogre::SceneNode *mwRoot; + Ogre::RaySceneQuery *mRaySceneQuery; - OEngine::Physic::PhysicEngine* eng; + OEngine::Physic::PhysicEngine* eng; - MWRender::Player *mPlayer; - MWRender::Debugging mDebugging; - - + MWRender::Player *mPlayer; + MWRender::Debugging mDebugging; }; } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 98730922cb..4ab809567c 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -7,9 +7,10 @@ namespace MWRender { Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false); } catch(...) { } + std::cout << "Water Constructor\n"; mTop = cell->water; - std::cout << "Making water\n"; + mIsUnderwater = false; mCamera->addListener(this); @@ -27,25 +28,24 @@ namespace MWRender { mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); - //if(!(cell->data.flags & cell->Interior)) - //{ - mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY)); - //} - //else - // mWaterNode->setPosition(10000, 0, 10000); //Don't mess with y + + if(!(cell->data.flags & cell->Interior)) + { + mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY)); + } mWaterNode->attachObject(mWater); } Water::~Water() { + Ogre::MeshManager::getSingleton().remove("water"); mCamera->removeListener(this); mWaterNode->detachObject(mWater); mSceneManager->destroyEntity(mWater); mSceneManager->destroySceneNode(mWaterNode); - - Ogre::MeshManager::getSingleton().remove("water"); + //Ogre::TextureManager::getSingleton().remove("refraction"); //Ogre::TextureManager::getSingleton().remove("reflection"); Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index cc93f68c2b..4eb41ebf5c 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -22,7 +22,7 @@ namespace MWWorld playerPos[0] = playerPos[1] = playerPos[2] = 0; std::cout << renderer->getHandle(); - + mPlayer.mData.setBaseNode(renderer->getNode()); /// \todo Do not make a copy of classes defined in esm/p records. mClass = new ESM::Class (*world.getStore().classes.find (player->cls)); @@ -35,7 +35,7 @@ namespace MWWorld void Player::setPos(float x, float y, float z) { - /// \todo This fcuntion should be removed during the mwrender-refactoring. + /// \todo This fcuntion should be removed during the mwrender-refactoring. mWorld.moveObject (getPlayer(), x, y, z); } diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 6cef9da19d..9a91a27b56 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -47,8 +47,11 @@ namespace MWWorld public: - RefData(const ESMS::CellRef& cr) : mHasLocals (false), mEnabled (true), - mCount (1), mPosition(cr.pos), mBaseNode(0) {} + /// @param cr Used to copy constant data such as position into this class where it can + /// be altered without effecting the original data. This makes it possible + /// to reset the position as the orignal data is still held in the CellRef + RefData(const ESMS::CellRef& cr) : mBaseNode(0), mHasLocals (false), mEnabled (true), + mCount (1), mPosition(cr.pos) {} std::string getHandle() diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 12264913e6..b222d5aec9 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -63,6 +63,8 @@ namespace MWWorld + mRendering.removeCell(active); + active->forEach(functor); { @@ -95,6 +97,7 @@ namespace MWWorld mActiveCells.insert(cell); if(result.second){ insertCell(*cell, mEnvironment); + mRendering.cellAdded(cell); mRendering.configureAmbient(*cell); } @@ -179,7 +182,7 @@ namespace MWWorld assert (iter!=mActiveCells.end()); mCurrentCell = *iter; - std::cout << "GridX: " << mCurrentCell->cell->data.gridX << "GridY: " << mCurrentCell->cell->data.gridY << "\n"; + // adjust player playerCellChange (mWorld->getExterior(X, Y), position, adjustPlayerPos); @@ -188,7 +191,7 @@ namespace MWWorld mWorld->adjustSky(); mCellChanged = true; - mRendering.cellAdded(mCurrentCell); + mRendering.waterAdded(mCurrentCell); } //We need the ogre renderer and a scene node. @@ -239,7 +242,8 @@ namespace MWWorld mWorld->adjustSky(); mCellChanged = true; - mRendering.cellAdded(cell); + + mRendering.waterAdded(cell); } void Scene::changeToExteriorCell (const ESM::Position& position) diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index c5183b58c8..1ddabb57b4 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -6,16 +6,17 @@ #include +#include + #include -#include "physicssystem.hpp" +#include "../mwrender/renderingmanager.hpp" +#include "../mwrender/renderinginterface.hpp" +#include "physicssystem.hpp" #include "refdata.hpp" #include "ptr.hpp" #include "globals.hpp" -#include "../mwrender/renderingmanager.hpp" -#include "../mwrender/renderinginterface.hpp" -#include namespace Ogre { @@ -58,7 +59,6 @@ namespace MWWorld private: //OEngine::Render::OgreRenderer& mRenderer; - Ogre::SceneNode *mMwRoot; Ptr::CellStore* mCurrentCell; // the cell, the player is in CellStoreCollection mActiveCells; bool mCellChanged; @@ -69,8 +69,8 @@ namespace MWWorld void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position, bool adjustPlayerPos = true); - - + + public: Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics); @@ -100,9 +100,6 @@ namespace MWWorld void markCellAsUnchanged(); -// std::string getFacedHandle(); - - void insertCell(ESMS::CellStore &cell); void insertCell(ESMS::CellStore &cell, MWWorld::Environment& environment); }; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index f02c71ed64..b694d45ccc 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -163,7 +163,7 @@ namespace MWWorld mEsm.open (masterPath.string()); mStore.load (mEsm); - MWRender::Player* play = &(mRendering.getPlayer()); + MWRender::Player* play = &(mRendering.getPlayer()); mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this); mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0)); @@ -319,12 +319,12 @@ namespace MWWorld { reference.getRefData().enable(); - + //render->enable (reference.getRefData().getHandle()); if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end()) Class::get (reference).enable (reference, mEnvironment); - - + + } } @@ -334,14 +334,14 @@ namespace MWWorld { reference.getRefData().disable(); - + //render->disable (reference.getRefData().getHandle()); if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end()){ Class::get (reference).disable (reference, mEnvironment); mEnvironment.mSoundManager->stopSound3D (reference); } - - + + } } @@ -499,9 +499,9 @@ namespace MWWorld { ptr.getRefData().setCount (0); - + if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end()){ - Class::get (ptr).disable (ptr, mEnvironment); +// Class::get (ptr).disable (ptr, mEnvironment); /// \todo this line needs to be removed mEnvironment.mSoundManager->stopSound3D (ptr); mPhysics->removeObject (ptr.getRefData().getHandle()); @@ -509,11 +509,6 @@ namespace MWWorld mLocalScripts.remove (ptr); } - - - //Should this go here or inside the for loop? - mRendering.getObjects().deleteObject (ptr.getRefData().getHandle()); - ptr.getRefData().setBaseNode(0); } } @@ -547,11 +542,9 @@ namespace MWWorld } } - // \todo cell change for non-player ref + /// \todo cell change for non-player ref - // \todo this should go into the new scene class and eventually into the objects/actors classes. - mRendering.getMgr()->getSceneNode (ptr.getRefData().getHandle())-> - setPosition (Ogre::Vector3 (x, y, z)); + mRendering.moveObject (ptr, Ogre::Vector3 (x, y, z)); } void World::moveObject (Ptr ptr, float x, float y, float z) diff --git a/libs/openengine b/libs/openengine index 26b9d0fdc3..2f5eca9d87 160000 --- a/libs/openengine +++ b/libs/openengine @@ -1 +1 @@ -Subproject commit 26b9d0fdc374fac648f6293e1d4a4abdc2c20c19 +Subproject commit 2f5eca9d878526bdd9dce93ece7f42093b481545