From b7dbfb849ab7a37917852fe722ee47a0f8937dbe Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 8 Aug 2011 21:11:30 +0200 Subject: [PATCH 1/3] moved skyManager into RenderingManager --- apps/openmw/mwrender/rendering_manager.cpp | 53 +++++++++++++++++++++- apps/openmw/mwrender/rendering_manager.hpp | 8 ++++ apps/openmw/mwworld/world.cpp | 32 ++++++------- apps/openmw/mwworld/world.hpp | 3 +- 4 files changed, 78 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwrender/rendering_manager.cpp b/apps/openmw/mwrender/rendering_manager.cpp index 66d178606..e7ef93858 100644 --- a/apps/openmw/mwrender/rendering_manager.cpp +++ b/apps/openmw/mwrender/rendering_manager.cpp @@ -1 +1,52 @@ -#include "rendering_manager.hpp" +#include "rendering_manager.hpp" + +namespace MWRender { + +RenderingManager::RenderingManager (SkyManager *skyManager) : + mSkyManager(skyManager) +{ + +} + +RenderingManager::~RenderingManager () +{ + delete mSkyManager; +} + +void RenderingManager::skyEnable () +{ + mSkyManager->enable(); +} + +void RenderingManager::skyDisable () +{ + mSkyManager->disable(); +} + +void RenderingManager::skySetHour (double hour) +{ + mSkyManager->setHour(hour); +} + + +void RenderingManager::skySetDate (int day, int month) +{ + mSkyManager->setDate(day, month); +} + +int RenderingManager::skyGetMasserPhase() const +{ + return mSkyManager->getMasserPhase(); +} + +int RenderingManager::skyGetSecundaPhase() const +{ + return mSkyManager->getSecundaPhase(); +} + +void RenderingManager::skySetMoonColour (bool red) +{ + mSkyManager->setMoonColour(red); +} + +} diff --git a/apps/openmw/mwrender/rendering_manager.hpp b/apps/openmw/mwrender/rendering_manager.hpp index 19ea73f5c..d456716d3 100644 --- a/apps/openmw/mwrender/rendering_manager.hpp +++ b/apps/openmw/mwrender/rendering_manager.hpp @@ -1,6 +1,9 @@ #ifndef _GAME_RENDERING_MANAGER_H #define _GAME_RENDERING_MANAGER_H + +#include "sky.hpp" + #include "../mwworld/ptr.hpp" #include #include @@ -10,6 +13,8 @@ namespace MWRender class RenderingManager { public: + RenderingManager(SkyManager *skyManager); + ~RenderingManager(); void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this? @@ -25,6 +30,7 @@ class RenderingManager { bool getPhysicsDebugRendering() const; void update (float duration); + void skyEnable (); void skyDisable (); void skySetHour (double hour); @@ -35,6 +41,8 @@ class RenderingManager { private: + SkyManager* mSkyManager; + }; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index abb1cf5ba..31c00c5bc 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -279,7 +279,7 @@ namespace MWWorld const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, bool newGame, Environment& environment, const std::string& encoding) - : mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mGlobalVariables (0), + : mScene (renderer,physEng), mPlayer (0), mGlobalVariables (0), mSky (false), mEnvironment (environment), mNextDynamicRecord (0) { mPhysEngine = physEng; @@ -307,20 +307,20 @@ namespace MWWorld mGlobalVariables->setInt ("chargenstate", 1); } - mSkyManager = - MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera(), resDir); - mPhysEngine = physEng; mWorldScene = new Scene(environment, this, mScene, mPhysics); + mRenderingManager = new MWRender::RenderingManager( + MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera(), resDir) + ); } World::~World() { delete mPlayer; - delete mSkyManager; + delete mRenderingManager; delete mGlobalVariables; - //delete mWorldScene; + //delete mWorldScene; // FIXME sagfault in malloc.h when not commented out delete mPhysics; } @@ -499,7 +499,7 @@ namespace MWWorld mGlobalVariables->setFloat ("gamehour", hour); - mSkyManager->setHour (hour); + mRenderingManager->skySetHour (hour); if (days>0) setDay (days + mGlobalVariables->getInt ("day")); @@ -534,7 +534,7 @@ namespace MWWorld mGlobalVariables->setInt ("day", day); mGlobalVariables->setInt ("month", month); - mSkyManager->setDate (day, month); + mRenderingManager->skySetDate (day, month); } void World::setMonth (int month) @@ -555,7 +555,7 @@ namespace MWWorld if (years>0) mGlobalVariables->setInt ("year", years+mGlobalVariables->getInt ("year")); - mSkyManager->setDate (mGlobalVariables->getInt ("day"), month); + mRenderingManager->skySetDate (mGlobalVariables->getInt ("day"), month); } bool World::toggleSky() @@ -563,34 +563,34 @@ namespace MWWorld if (mSky) { mSky = false; - mSkyManager->disable(); + mRenderingManager->skyDisable(); return false; } else { mSky = true; // TODO check for extorior or interior with sky. - mSkyManager->setHour (mGlobalVariables->getFloat ("gamehour")); - mSkyManager->setDate (mGlobalVariables->getInt ("day"), + mRenderingManager->skySetHour (mGlobalVariables->getFloat ("gamehour")); + mRenderingManager->skySetDate (mGlobalVariables->getInt ("day"), mGlobalVariables->getInt ("month")); - mSkyManager->enable(); + mRenderingManager->skyEnable(); return true; } } int World::getMasserPhase() const { - return mSkyManager->getMasserPhase(); + return mRenderingManager->skyGetMasserPhase(); } int World::getSecundaPhase() const { - return mSkyManager->getSecundaPhase(); + return mRenderingManager->skyGetSecundaPhase(); } void World::setMoonColour (bool red) { - mSkyManager->setMoonColour (red); + mRenderingManager->skySetMoonColour (red); } float World::getTimeScaleFactor() const diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index d59474295..7b900fb09 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -9,6 +9,7 @@ #include #include "../mwrender/mwscene.hpp" +#include "../mwrender/rendering_manager.hpp" #include "refdata.hpp" #include "ptr.hpp" @@ -66,7 +67,6 @@ namespace MWWorld typedef std::map CellRenderCollection; - MWRender::SkyManager* mSkyManager; MWRender::MWScene mScene; MWWorld::Scene *mWorldScene; MWWorld::Player *mPlayer; @@ -77,6 +77,7 @@ namespace MWWorld MWWorld::PhysicsSystem *mPhysics; bool mSky; Environment& mEnvironment; + MWRender::RenderingManager *mRenderingManager; int mNextDynamicRecord; std::map mInteriors; From a13b958600c70cc678acf1ee9f4c3ce642c80b26 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 9 Aug 2011 00:05:16 +0200 Subject: [PATCH 2/3] MWWorld::Scene::insertCell --- apps/openmw/mwworld/scene.cpp | 64 +++++++++++++++++++++++++++++++++++ apps/openmw/mwworld/scene.hpp | 2 ++ 2 files changed, 66 insertions(+) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index a6d06a75c..e92966470 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -11,11 +11,42 @@ #include "ptr.hpp" #include "environment.hpp" #include "player.hpp" +#include "class.hpp" #include "doingphysics.hpp" #include "cellfunctors.hpp" + +namespace { + +template +void insertCellRefList (T& cellRefList, ESMS::CellStore &cell) +{ + if (!cellRefList.list.empty()) + { + const MWWorld::Class& class_ = + MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell)); + + for (typename T::List::iterator it = cellRefList.list.begin(); + it != cellRefList.list.end(); it++) + { + if (it->mData.getCount() || it->mData.isEnabled()) + { + MWWorld::Ptr ptr (&*it, &cell); + /* TODO: call + * RenderingManager.insertObject + * class_.insertObjectPhysic + * class_.insertObjectMechanics + */ + } + } + } +} + +} + + namespace MWWorld { @@ -216,5 +247,38 @@ namespace MWWorld { mCellChanged = false; } + +/*#include +#include +#include + +#include "../mwworld/class.hpp" +#include "../mwworld/ptr.hpp"*/ + +void Scene::insertCell(ESMS::CellStore &cell) +{ + // Loop through all references in the cell + insertCellRefList (cell.activators, cell); + insertCellRefList (cell.potions, cell); + insertCellRefList (cell.appas, cell); + insertCellRefList (cell.armors, cell); + insertCellRefList (cell.books, cell); + insertCellRefList (cell.clothes, cell); + insertCellRefList (cell.containers, cell); + insertCellRefList (cell.creatures, cell); + insertCellRefList (cell.doors, cell); + insertCellRefList (cell.ingreds, cell); + insertCellRefList (cell.creatureLists, cell); + insertCellRefList (cell.itemLists, cell); + insertCellRefList (cell.lights, cell); + insertCellRefList (cell.lockpicks, cell); + insertCellRefList (cell.miscItems, cell); + insertCellRefList (cell.npcs, cell); + insertCellRefList (cell.probes, cell); + insertCellRefList (cell.repairs, cell); + insertCellRefList (cell.statics, cell); + insertCellRefList (cell.weapons, cell); +} + } diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index c6d996364..b03b1fee4 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -98,6 +98,8 @@ namespace MWWorld void markCellAsUnchanged(); std::string getFacedHandle(); + + void insertCell(ESMS::CellStore &cell); }; } From 29b8a5374b497611ce8b378571b3a6eccec7c1b2 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Fri, 19 Aug 2011 17:03:47 +0200 Subject: [PATCH 3/3] get rid of the warnings --- apps/openmw/engine.cpp | 3 ++- apps/openmw/mwrender/exterior.cpp | 9 +++++---- apps/openmw/mwworld/scene.cpp | 4 +--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 264cf5347..5dcc412c6 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -523,4 +523,5 @@ void OMW::Engine::setCompileAll (bool all) void OMW::Engine::setEncoding(const std::string& encoding) { mEncoding = encoding; -} \ No newline at end of file +} + diff --git a/apps/openmw/mwrender/exterior.cpp b/apps/openmw/mwrender/exterior.cpp index 6e6908a62..9dd82c68f 100644 --- a/apps/openmw/mwrender/exterior.cpp +++ b/apps/openmw/mwrender/exterior.cpp @@ -35,7 +35,7 @@ int ExteriorCellRender::uniqueID = 0; ExteriorCellRender::ExteriorCellRender(ESMS::CellStore &_cell, MWWorld::Environment& environment, MWScene &_scene, MWWorld::PhysicsSystem *physics) - : mCell(_cell), mEnvironment (environment), mScene(_scene), mBase(NULL), mInsert(NULL), mAmbientMode (0), mPhysics(physics) + : mCell(_cell), mEnvironment (environment), mScene(_scene), mPhysics(physics), mBase(NULL), mInsert(NULL), mAmbientMode (0) { uniqueID = uniqueID +1; sg = mScene.getMgr()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); @@ -350,13 +350,14 @@ void ExteriorCellRender::setAmbientMode() void ExteriorCellRender::show() { + // FIXME: this one may be the bug mBase = mScene.getRoot()->createChildSceneNode(); - + configureAmbient(); configureFog(); - + insertCell(mCell, mEnvironment); - + sg->build(); } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index e92966470..36a02d2d8 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -25,8 +25,7 @@ void insertCellRefList (T& cellRefList, ESMS::CellStore &cell) { if (!cellRefList.list.empty()) { - const MWWorld::Class& class_ = - MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell)); + //const MWWorld::Class& class_ = MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell)); for (typename T::List::iterator it = cellRefList.list.begin(); it != cellRefList.list.end(); it++) @@ -100,7 +99,6 @@ namespace MWWorld void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos) { SuppressDoingPhysics scopeGuard; - // remove active mEnvironment.mMechanicsManager->removeActor (mWorld->getPlayer().getPlayer());