summaryrefslogtreecommitdiffhomepage
path: root/editor/character.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-10 18:02:29 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-10 18:02:29 +0100
commit29bdd5f2170b9d46a8b3b0973c4c0845d6a2b61e (patch)
treede0e6f19b1c6fc12326afa092e8f13c011d8f8eb /editor/character.cpp
parentb17c955193cbcc0bc774cdf09022b40abf80f768 (diff)
editor: reduce struct character size
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;
}