From e2772fca21e5bd6953d61edb7f6180766bca7fe8 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Thu, 18 Nov 2021 14:31:14 +0000 Subject: [PATCH] Fix large delta on next frame when turning t_simulationTickDeltaOverride off. (#5716) This was due to incorrectly setting m_lastSimulationTickTimeUs when t_simulationTickDeltaOverride was enabled to the override. m_lastSimulationTickTimeUs is now always set to the current time so the delta calculation will always be correct. Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com> --- Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp | 5 ++--- Code/Framework/AzCore/AzCore/Time/TimeSystem.h | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp b/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp index cd0170749f..a5e0908ac4 100644 --- a/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp +++ b/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp @@ -124,14 +124,13 @@ namespace AZ const TimeUs currentTimeUs = static_cast(AZStd::GetTimeNowMicroSecond()); //real time - m_realTickDeltaTimeUs = currentTimeUs - m_lastRealTickTimeUs; - m_lastRealTickTimeUs = currentTimeUs; + m_realTickDeltaTimeUs = currentTimeUs - m_lastSimulationTickTimeUs; //game time if (m_simulationTickDeltaOverride > AZ::Time::ZeroTimeUs) { m_simulationTickDeltaTimeUs = m_simulationTickDeltaOverride; - m_lastSimulationTickTimeUs = m_simulationTickDeltaTimeUs; + m_lastSimulationTickTimeUs = currentTimeUs; return m_simulationTickDeltaTimeUs; } diff --git a/Code/Framework/AzCore/AzCore/Time/TimeSystem.h b/Code/Framework/AzCore/AzCore/Time/TimeSystem.h index d2587c76d8..ded70c9be5 100644 --- a/Code/Framework/AzCore/AzCore/Time/TimeSystem.h +++ b/Code/Framework/AzCore/AzCore/Time/TimeSystem.h @@ -74,8 +74,7 @@ namespace AZ //! Updated in AdvanceTickDeltaTimes(). TimeUs m_realTickDeltaTimeUs = AZ::Time::ZeroTimeUs; - TimeUs m_lastSimulationTickTimeUs = AZ::Time::ZeroTimeUs; //!< Used to determine the game tick delta time (affected by cvars). - TimeUs m_lastRealTickTimeUs = AZ::Time::ZeroTimeUs; //!< Used to determine the real game tick delta time (not affected by cvars). + TimeUs m_lastSimulationTickTimeUs = AZ::Time::ZeroTimeUs; //!< Used to determine the game tick delta time. TimeUs m_simulationTickDeltaOverride = AZ::Time::ZeroTimeUs; //