Add Time.Synchronize to stabilize engine loop

This commit is contained in:
2024-04-17 13:01:58 +02:00
parent c83b74c85d
commit 692a61c948
4 changed files with 16 additions and 10 deletions
+5 -5
View File
@@ -54,7 +54,7 @@ void TimeSettings::Apply()
::MaxUpdateDeltaTime = MaxUpdateDeltaTime;
}
void Time::TickData::OnBeforeRun(float targetFps, double currentTime)
void Time::TickData::Synchronize(float targetFps, double currentTime)
{
Time = UnscaledTime = TimeSpan::Zero();
DeltaTime = UnscaledDeltaTime = targetFps > ZeroTolerance ? TimeSpan::FromSeconds(1.0f / targetFps) : TimeSpan::Zero();
@@ -240,13 +240,13 @@ void Time::SetFixedDeltaTime(bool enable, float value)
FixedDeltaTimeValue = value;
}
void Time::OnBeforeRun()
void Time::Synchronize()
{
// Initialize tick data (based on a time settings)
const double time = Platform::GetTimeSeconds();
Update.OnBeforeRun(UpdateFPS, time);
Physics.OnBeforeRun(PhysicsFPS, time);
Draw.OnBeforeRun(DrawFPS, time);
Update.Synchronize(UpdateFPS, time);
Physics.Synchronize(PhysicsFPS, time);
Draw.Synchronize(DrawFPS, time);
}
bool Time::OnBeginUpdate()