diff --git a/Code/Framework/AzCore/AzCore/Time/ITime.h b/Code/Framework/AzCore/AzCore/Time/ITime.h index a3dcca09ea..a61b629f35 100644 --- a/Code/Framework/AzCore/AzCore/Time/ITime.h +++ b/Code/Framework/AzCore/AzCore/Time/ITime.h @@ -137,11 +137,18 @@ namespace AZ return AZ::Interface::Get()->GetElapsedTimeUs(); } + //! This is a simple convenience wrapper inline TimeMs GetRealElapsedTimeMs() { return AZ::Interface::Get()->GetRealElapsedTimeMs(); } + //! This is a simple convenience wrapper + inline TimeUs GetRealElapsedTimeUs() + { + return AZ::Interface::Get()->GetRealElapsedTimeUs(); + } + //! This is a simple convenience wrapper inline TimeUs GetSimulationTickDeltaTimeUs() { diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/RPISystem.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/RPISystem.h index 9138c0b418..57f595ccba 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/RPISystem.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/RPISystem.h @@ -97,7 +97,7 @@ namespace AZ // SystemTickBus::OnTick void OnSystemTick() override; - float GetCurrentTime(); + float GetCurrentTime() const; // The set of core asset handlers registered by the system. AZStd::vector> m_assetHandlers; @@ -123,7 +123,6 @@ namespace AZ // The job policy used for feature processor's rendering prepare RHI::JobPolicy m_prepareRenderJobPolicy = RHI::JobPolicy::Parallel; - ScriptTimePoint m_startTime; float m_currentSimulationTime = 0.0f; RPISystemDescriptor m_descriptor; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp index 2b32503838..4465b8594f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp @@ -33,6 +33,7 @@ #include #include +#include #include @@ -276,15 +277,10 @@ namespace AZ } } - float RPISystem::GetCurrentTime() + float RPISystem::GetCurrentTime() const { - ScriptTimePoint timeAtCurrentTick; - AZ::TickRequestBus::BroadcastResult(timeAtCurrentTick, &AZ::TickRequestBus::Events::GetTimeAtCurrentTick); - - // We subtract the start time to maximize precision of the time value, since we will be converting it to a float. - double currentTime = timeAtCurrentTick.GetSeconds() - m_startTime.GetSeconds(); - - return aznumeric_cast(currentTime); + const AZ::TimeUs currentSimulationTimeUs = AZ::GetRealElapsedTimeUs(); + return AZ::TimeUsToSeconds(currentSimulationTimeUs); } void RPISystem::RenderTick()