Add some tolerance in checks against zero floating point values

This commit is contained in:
GoaLitiuM
2021-12-05 16:43:24 +02:00
parent d7d8eca9c8
commit 17311e7c9e
2 changed files with 4 additions and 4 deletions

View File

@@ -146,7 +146,7 @@ int32 Engine::Main(const Char* cmdLine)
while (!ShouldExit()) while (!ShouldExit())
{ {
// Reduce CPU usage by introducing idle time if the engine is running very fast and has enough time to spend // 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 nextTick = Time::GetNextTick();
double timeToTick = nextTick - Platform::GetTimeSeconds(); double timeToTick = nextTick - Platform::GetTimeSeconds();

View File

@@ -189,11 +189,11 @@ double Time::GetNextTick()
const double nextDraw = Time::Draw.NextBegin; const double nextDraw = Time::Draw.NextBegin;
double nextTick = MAX_double; double nextTick = MAX_double;
if (UpdateFPS > 0 && nextUpdate < nextTick) if (UpdateFPS > ZeroTolerance && nextUpdate < nextTick)
nextTick = nextUpdate; nextTick = nextUpdate;
if (PhysicsFPS > 0 && nextPhysics < nextTick) if (PhysicsFPS > ZeroTolerance && nextPhysics < nextTick)
nextTick = nextPhysics; nextTick = nextPhysics;
if (DrawFPS > 0 && nextDraw < nextTick) if (DrawFPS > ZeroTolerance && nextDraw < nextTick)
nextTick = nextDraw; nextTick = nextDraw;
if (nextTick == MAX_double) if (nextTick == MAX_double)