Fix Time::Synchronize to not reset time on unpause

This commit is contained in:
2026-04-20 14:06:51 +02:00
parent 21cac2ad6e
commit 3cea8621a7
4 changed files with 13 additions and 11 deletions
+2 -2
View File
@@ -163,7 +163,7 @@ namespace FlaxEditor.States
IsPlayModeStarting = false;
Profiler.EndEvent();
Time.Synchronize();
Time.Synchronize(true);
}
private void SetupEditorEnvOptions()
@@ -213,7 +213,7 @@ namespace FlaxEditor.States
IsPlayModeEnding = false;
Profiler.EndEvent();
Time.Synchronize();
Time.Synchronize(true);
}
}
}
+1 -1
View File
@@ -157,7 +157,7 @@ int32 Engine::OnInit(const Char* cmdLine)
Application::BeforeRun();
LOG_FLOOR();
LOG_FLUSH();
Time::Synchronize();
Time::Synchronize(true);
EngineImpl::IsReady = true;
PROFILE_MEM_END();
+7 -6
View File
@@ -75,10 +75,11 @@ void TimeSettings::Apply()
#endif
}
void Time::TickData::Synchronize(float targetFps, double currentTime)
void Time::TickData::Synchronize(float targetFps, double currentTime, bool resetTotalTime)
{
OnReset(targetFps, currentTime);
Time = UnscaledTime = TimeSpan::Zero();
if (resetTotalTime)
Time = UnscaledTime = TimeSpan::Zero();
NextBegin = targetFps > ZeroTolerance ? LastBegin + (1.0f / targetFps) : 0.0;
}
@@ -258,13 +259,13 @@ void Time::SetFixedDeltaTime(bool enable, float value)
FixedDeltaTimeValue = value;
}
void Time::Synchronize()
void Time::Synchronize(bool resetTotalTime)
{
// Initialize tick data (based on a time settings)
const double time = Platform::GetTimeSeconds();
Update.Synchronize(UpdateFPS, time);
Physics.Synchronize(PhysicsFPS, time);
Draw.Synchronize(DrawFPS, time);
Update.Synchronize(UpdateFPS, time, resetTotalTime);
Physics.Synchronize(PhysicsFPS, time, resetTotalTime);
Draw.Synchronize(DrawFPS, time, resetTotalTime);
}
bool Time::OnBeginUpdate(double time)
+3 -2
View File
@@ -75,7 +75,7 @@ public:
TimeSpan UnscaledTime;
public:
virtual void Synchronize(float targetFps, double currentTime);
virtual void Synchronize(float targetFps, double currentTime, bool resetTotalTime);
virtual void OnReset(float targetFps, double currentTime);
virtual bool OnTickBegin(double time, float targetFps, float maxDeltaTime);
virtual void OnTickEnd();
@@ -220,7 +220,8 @@ public:
/// <summary>
/// Synchronizes update, fixed update and draw. Resets any pending deltas for fresh ticking in sync.
/// </summary>
API_FUNCTION() static void Synchronize();
/// <param name="resetTotalTime">True if reset total time, otherwise only delta time and ticking is reset.</param>
API_FUNCTION() static void Synchronize(bool resetTotalTime = false);
private:
// Methods used by the Engine class