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>
This commit is contained in:
amzn-sean
2021-11-18 14:31:14 +00:00
committed by GitHub
parent e4563c0058
commit e2772fca21
2 changed files with 3 additions and 5 deletions
@@ -124,14 +124,13 @@ namespace AZ
const TimeUs currentTimeUs = static_cast<TimeUs>(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;
}
@@ -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; //<! Stores the TimeUs value of the t_simulationTickDeltaOverride cvar.
TimeUs m_simulationTickLimitTimeUs = AZ::Time::ZeroTimeUs; //<! Stores the TimeUs value of the t_simulationTickRate cvar.