Removal and Replacement of the CryTimer (gEnv->pTimer) (#5409)

Replaced and removed the CryTimer (gEnv->pTimer). The new TimeSystem is a merger of the current time functionality found in the engine.

* Rename TimeSystemComponent.h/.cpp to TimeSystem.h/.cpp
* Adding New TimeSystem
* remove old timer cvars
* small improvements to the time system.
 - updated parts to use the time conversion functions.
 - in AdvanceTickDeltaTimes applying t_simulationTickScale is now uses doubles instead of floats.
* Replace gEnv->pTimer / ITimer usages with TimeSystem
* Updating usages of AZ::TimeMs{ 0 } and AZ::TimeUs{ 0 } to AZ::Time::ZeroTimeMs and AZ::Time::ZeroTimeUs
* red code the CryTimer
* using TimeUs instead of TimeMs is some cases + updating usages of old cvars to new

Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
This commit is contained in:
amzn-sean
2021-11-15 12:11:58 +00:00
committed by GitHub
parent 0ada8b335b
commit 38a03817bb
142 changed files with 1215 additions and 2090 deletions
@@ -13,7 +13,6 @@
#include "AnimationContext.h"
#include <LyShine/Animation/IUiAnimation.h>
#include "ITimer.h"
#include "GameEngine.h"
#include "Objects/SelectionGroup.h"
@@ -29,6 +28,27 @@
#include "IPostRenderer.h"
#include "UiEditorAnimationBus.h"
#include <AzCore/Time/ITime.h>
namespace Internal
{
float GetFrameDeltaTime()
{
const AZ::TimeUs frameDeltaTimeMs = AZ::GetSimulationTickDeltaTimeUs();
return AZ::TimeUsToSeconds(frameDeltaTimeMs);
}
float GetFrameRate()
{
const float deltaTime = GetFrameDeltaTime();
if (AZ::IsClose(deltaTime, 0.0f))
{
return 0.0f;
}
return 1.0f / deltaTime;
}
}
//////////////////////////////////////////////////////////////////////////
// Animation Callback.
//////////////////////////////////////////////////////////////////////////
@@ -380,17 +400,15 @@ void CUiAnimationContext::Update()
return;
}
ITimer* pTimer = GetIEditor()->GetSystem()->GetITimer();
AnimateActiveSequence();
float dt = pTimer->GetFrameTime();
m_currTime += dt * m_fTimeScale;
const float frameDeltaTime = Internal::GetFrameDeltaTime();
m_currTime += frameDeltaTime * m_fTimeScale;
if (!m_recording)
{
GetUiAnimationSystem()->PreUpdate(dt);
GetUiAnimationSystem()->PostUpdate(dt);
GetUiAnimationSystem()->PreUpdate(frameDeltaTime);
GetUiAnimationSystem()->PostUpdate(frameDeltaTime);
}
if (m_currTime > m_timeMarker.end)
@@ -444,7 +462,7 @@ void CUiAnimationContext::OnPostRender()
{
SUiAnimContext ac;
ac.dt = 0;
ac.fps = GetIEditor()->GetSystem()->GetITimer()->GetFrameRate();
ac.fps = Internal::GetFrameRate();
ac.time = m_currTime;
ac.bSingleFrame = true;
ac.bForcePlay = true;
@@ -586,7 +604,7 @@ void CUiAnimationContext::AnimateActiveSequence()
SUiAnimContext ac;
ac.dt = 0;
ac.fps = GetIEditor()->GetSystem()->GetITimer()->GetFrameRate();
ac.fps = Internal::GetFrameRate();
ac.time = m_currTime;
ac.bSingleFrame = true;
ac.bForcePlay = true;