This commit is contained in:
2026-05-07 00:19:53 -04:00
parent a1bdbeba1c
commit 5c746d99c2
12 changed files with 51 additions and 69 deletions
+15 -18
View File
@@ -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();
}
}