diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 01ecd3d11..f8382f860 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -82,7 +82,7 @@ void OMW::Engine::executeLocalScripts() localScripts.setIgnore (MWWorld::Ptr()); } -double OMW::Engine::frame(float frametime) +void OMW::Engine::frame(float frametime) { try { @@ -101,17 +101,14 @@ double OMW::Engine::frame(float frametime) if (mUseSound) MWBase::Environment::get().getSoundManager()->update(frametime); - // GUI active? Most game processing will be paused, but scripts still run. - bool guiActive = MWBase::Environment::get().getWindowManager()->isGuiMode(); - if (!guiActive) - mSimulationTime += frametime; - // Main menu opened? Then scripts are also paused. bool paused = MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu); // update game state MWBase::Environment::get().getStateManager()->update (frametime); + bool guiActive = MWBase::Environment::get().getWindowManager()->isGuiMode(); + osg::Timer_t beforeScriptTick = osg::Timer::instance()->tick(); if (MWBase::Environment::get().getStateManager()->getState()== MWBase::StateManager::State_Running) @@ -193,7 +190,6 @@ double OMW::Engine::frame(float frametime) { std::cerr << "Error in framelistener: " << e.what() << std::endl; } - return mSimulationTime; } OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) @@ -214,7 +210,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mFSStrict (false) , mScriptBlacklistUse (true) , mNewGame (false) - , mSimulationTime(0.0) , mCfgMgr(configurationManager) { Misc::Rng::init(); @@ -679,14 +674,24 @@ void OMW::Engine::go() // Start the main rendering loop osg::Timer frameTimer; + double simulationTime = 0.0; while (!mViewer->done() && !MWBase::Environment::get().getStateManager()->hasQuitRequest()) { double dt = frameTimer.time_s(); frameTimer.setStartTick(); dt = std::min(dt, 0.2); - double simulationTime = frame(dt); - mViewer->frame(simulationTime); + bool guiActive = MWBase::Environment::get().getWindowManager()->isGuiMode(); + if (!guiActive) + simulationTime += dt; + + mViewer->advance(simulationTime); + + frame(dt); + + mViewer->eventTraversal(); + mViewer->updateTraversal(); + mViewer->renderingTraversals(); } // Save user settings diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 8ac6098b8..73de57dc4 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -106,7 +106,6 @@ namespace OMW bool mNewGame; osg::Timer_t mStartTick; - double mSimulationTime; // not implemented Engine (const Engine&); @@ -114,8 +113,7 @@ namespace OMW void executeLocalScripts(); - /// @return The new simulationTime - double frame (float dt); + void frame (float dt); /// Load settings from various files, returns the path to the user settings file std::string loadSettings (Settings::Manager & settings);