Refactor...

This commit is contained in:
2025-10-21 20:23:27 -04:00
parent 7f07eaa128
commit 5b0f9a39c4
104 changed files with 17010 additions and 13171 deletions

48
src/playback.cpp Normal file
View File

@@ -0,0 +1,48 @@
#include "playback.h"
#include <glm/common.hpp>
namespace anm2ed::playback
{
void Playback::toggle()
{
if (isFinished) time = 0.0f;
isFinished = false;
isPlaying = !isPlaying;
}
void Playback::clamp(int length)
{
time = glm::clamp(time, 0.0f, (float)length - 1.0f);
}
void Playback::tick(int fps, int length, bool isLoop)
{
if (isFinished) return;
time += (float)fps / 30.0f;
if (time >= (float)length)
{
if (isLoop)
time = 0.0f;
else
{
isPlaying = false;
isFinished = true;
}
}
}
void Playback::decrement(int length)
{
--time;
clamp(length);
}
void Playback::increment(int length)
{
++time;
clamp(length);
}
}