From 442c03237340e5e2cce7e9f7d79679c176794dda Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 26 Sep 2023 14:39:38 +0400 Subject: [PATCH] Decouple rendering simulation time from Lua simulation time (bug 7576) --- apps/openmw/engine.cpp | 5 ++++- apps/openmw/mwworld/datetimemanager.hpp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index df89cd3eb6..ee2ce7ae3e 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -945,7 +945,7 @@ void OMW::Engine::go() .count() * timeManager.getSimulationTimeScale(); - mViewer->advance(timeManager.getSimulationTime()); + mViewer->advance(timeManager.getRenderingSimulationTime()); if (!frame(dt)) { @@ -954,7 +954,10 @@ void OMW::Engine::go() } timeManager.updateIsPaused(); if (!timeManager.isPaused()) + { timeManager.setSimulationTime(timeManager.getSimulationTime() + dt); + timeManager.setRenderingSimulationTime(timeManager.getRenderingSimulationTime() + dt); + } if (stats) { diff --git a/apps/openmw/mwworld/datetimemanager.hpp b/apps/openmw/mwworld/datetimemanager.hpp index f89894292f..af62d9ba3f 100644 --- a/apps/openmw/mwworld/datetimemanager.hpp +++ b/apps/openmw/mwworld/datetimemanager.hpp @@ -29,7 +29,11 @@ namespace MWWorld float getGameTimeScale() const { return mGameTimeScale; } void setGameTimeScale(float scale); // game time to simulation time ratio - // Simulation time (the number of seconds passed from the beginning of the game). + // Rendering simulation time (summary simulation time of rendering frames since application start). + double getRenderingSimulationTime() const { return mRenderingSimulationTime; } + void setRenderingSimulationTime(double t) { mRenderingSimulationTime = t; } + + // World simulation time (the number of seconds passed from the beginning of the game). double getSimulationTime() const { return mSimulationTime; } void setSimulationTime(double t) { mSimulationTime = t; } float getSimulationTimeScale() const { return mSimulationTimeScale; } @@ -64,6 +68,7 @@ namespace MWWorld float mGameHour = 0.f; float mGameTimeScale = 0.f; float mSimulationTimeScale = 1.0; + double mRenderingSimulationTime = 0.0; double mSimulationTime = 0.0; bool mPaused = false; std::set> mPausedTags;