From 195e1a84102ab994d395001dfcf69bd6323e09ec Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Jun 2015 15:27:33 +0200 Subject: [PATCH] Fix the Viewer's FrameStamp not being set correctly during Engine::frame --- apps/openmw/engine.cpp | 25 +++++++++++++++---------- apps/openmw/engine.hpp | 4 +--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 01ecd3d11a..f8382f860f 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 8ac6098b8a..73de57dc4b 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);