60Hz
This commit is contained in:
+15
-18
@@ -21,30 +21,27 @@ namespace anm2ed
|
||||
|
||||
void Playback::tick(int fps, int length, bool isLoop, float deltaSeconds)
|
||||
{
|
||||
if (isLoop) isFinished = false;
|
||||
if (isFinished || !isPlaying || fps <= 0 || length <= 0) return;
|
||||
if (deltaSeconds <= 0.0f) return;
|
||||
|
||||
auto frameDuration = 1.0f / (float)fps;
|
||||
tickAccumulator += deltaSeconds;
|
||||
auto steps = (int)std::floor(tickAccumulator / frameDuration);
|
||||
if (steps <= 0) return;
|
||||
tickAccumulator -= frameDuration * (float)steps;
|
||||
time += deltaSeconds * (float)fps;
|
||||
|
||||
time += (float)steps;
|
||||
if (!std::isfinite(time)) time = 0.0f;
|
||||
|
||||
if (time > (float)length - 1.0f)
|
||||
if (isLoop)
|
||||
{
|
||||
if (isLoop)
|
||||
{
|
||||
time = std::fmod(time, (float)length);
|
||||
}
|
||||
else
|
||||
{
|
||||
time = (float)length - 1.0f;
|
||||
isPlaying = false;
|
||||
isFinished = true;
|
||||
timing_reset();
|
||||
}
|
||||
time = std::fmod(time, (float)length);
|
||||
if (time < 0.0f) time += (float)length;
|
||||
return;
|
||||
}
|
||||
|
||||
if (time >= (float)length)
|
||||
{
|
||||
time = (float)length - 1.0f;
|
||||
isPlaying = false;
|
||||
isFinished = true;
|
||||
timing_reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user