summaryrefslogtreecommitdiffhomepage
path: root/editor/character.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/character.cpp')
-rw-r--r--editor/character.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/editor/character.cpp b/editor/character.cpp
index a971434d..845f8345 100644
--- a/editor/character.cpp
+++ b/editor/character.cpp
@@ -62,10 +62,11 @@ character_wip::~character_wip() = default;
int character_wip::allocate_frame_time(float dt)
{
- delta += dt;
- auto ret = (int)(delta*framerate);
- delta -= ret;
- delta = std::fmax(0.f, delta);
+ int d = int(delta) + int(65535u * dt);
+ constexpr int framerate_ = 65535/framerate;
+ static_assert(framerate_ > 0);
+ auto ret = d / framerate_;
+ delta = (std::uint16_t)std::clamp(d - ret*65535, 0, 65535);
return ret;
}