From f755a1eeb45262fe3aea64efc3914709d572afcc Mon Sep 17 00:00:00 2001 From: untodesu Date: Fri, 26 Dec 2025 18:09:35 +0500 Subject: Add interpolation to Velocity component; fixes #20 - Also disabled snapping to grid for sideways movement as it was somehow messing with player_move code and was making you slide on voxels as if you were on ice (not good) --- src/game/client/entity/interpolation.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/game/client/entity/interpolation.cc') diff --git a/src/game/client/entity/interpolation.cc b/src/game/client/entity/interpolation.cc index 69fd487..86af971 100644 --- a/src/game/client/entity/interpolation.cc +++ b/src/game/client/entity/interpolation.cc @@ -6,6 +6,7 @@ #include "shared/entity/head.hh" #include "shared/entity/transform.hh" +#include "shared/entity/velocity.hh" #include "shared/world/dimension.hh" @@ -53,11 +54,23 @@ static void head_interpolate(float alpha) } } +static void velocity_interpolate(float alpha) +{ + auto group = globals::dimension->entities.group(entt::get); + + for(auto [entity, interp, current, previous] : group.each()) { + interp.value[0] = glm::mix(previous.value[0], current.value[0], alpha); + interp.value[1] = glm::mix(previous.value[1], current.value[1], alpha); + interp.value[2] = glm::mix(previous.value[2], current.value[2], alpha); + } +} + void interpolation::update(void) { if(globals::dimension) { auto alpha = static_cast(globals::fixed_accumulator) / static_cast(globals::fixed_frametime_us); transform_interpolate(alpha); head_interpolate(alpha); + velocity_interpolate(alpha); } } \ No newline at end of file -- cgit