Merge branch 'tick_fix' of git://github.com/GoaLitiuM/FlaxEngine into GoaLitiuM-tick_fix
This commit is contained in:
@@ -146,7 +146,7 @@ int32 Engine::Main(const Char* cmdLine)
|
||||
while (!ShouldExit())
|
||||
{
|
||||
// Reduce CPU usage by introducing idle time if the engine is running very fast and has enough time to spend
|
||||
if ((useSleep && Time::UpdateFPS > 0) || !Platform::GetHasFocus())
|
||||
if ((useSleep && Time::UpdateFPS > ZeroTolerance) || !Platform::GetHasFocus())
|
||||
{
|
||||
double nextTick = Time::GetNextTick();
|
||||
double timeToTick = nextTick - Platform::GetTimeSeconds();
|
||||
|
||||
@@ -103,7 +103,10 @@ bool Time::TickData::OnTickBegin(float targetFps, float maxDeltaTime)
|
||||
}
|
||||
|
||||
if (targetFps > ZeroTolerance)
|
||||
NextBegin += (1.0 / targetFps);
|
||||
{
|
||||
int skip = (int)(1 + (time - NextBegin) / (1.0 / targetFps));
|
||||
NextBegin += (1.0 / targetFps) * skip;
|
||||
}
|
||||
}
|
||||
|
||||
// Update data
|
||||
@@ -156,7 +159,10 @@ bool Time::FixedStepTickData::OnTickBegin(float targetFps, float maxDeltaTime)
|
||||
}
|
||||
|
||||
if (targetFps > ZeroTolerance)
|
||||
NextBegin += (1.0 / targetFps);
|
||||
{
|
||||
int skip = (int)(1 + (time - NextBegin) / (1.0 / targetFps));
|
||||
NextBegin += (1.0 / targetFps) * skip;
|
||||
}
|
||||
}
|
||||
Samples.Add(deltaTime);
|
||||
|
||||
@@ -183,11 +189,11 @@ double Time::GetNextTick()
|
||||
const double nextDraw = Time::Draw.NextBegin;
|
||||
|
||||
double nextTick = MAX_double;
|
||||
if (UpdateFPS > 0 && nextUpdate < nextTick)
|
||||
if (UpdateFPS > ZeroTolerance && nextUpdate < nextTick)
|
||||
nextTick = nextUpdate;
|
||||
if (PhysicsFPS > 0 && nextPhysics < nextTick)
|
||||
if (PhysicsFPS > ZeroTolerance && nextPhysics < nextTick)
|
||||
nextTick = nextPhysics;
|
||||
if (DrawFPS > 0 && nextDraw < nextTick)
|
||||
if (DrawFPS > ZeroTolerance && nextDraw < nextTick)
|
||||
nextTick = nextDraw;
|
||||
|
||||
if (nextTick == MAX_double)
|
||||
|
||||
Reference in New Issue
Block a user