summaryrefslogtreecommitdiffstats
path: root/src/game/client/entity/interpolation.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-12-26 18:09:35 +0500
committeruntodesu <kirill@untode.su>2025-12-26 18:09:35 +0500
commitf755a1eeb45262fe3aea64efc3914709d572afcc (patch)
treebb08dff89a7ddd446a4363edabac8f9ee0514234 /src/game/client/entity/interpolation.cc
parenteebc2b776717f18e4a24af39b0209afa8eb7404f (diff)
downloadvoxelius-f755a1eeb45262fe3aea64efc3914709d572afcc.tar.bz2
voxelius-f755a1eeb45262fe3aea64efc3914709d572afcc.zip
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)
Diffstat (limited to 'src/game/client/entity/interpolation.cc')
-rw-r--r--src/game/client/entity/interpolation.cc13
1 files changed, 13 insertions, 0 deletions
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<client::VelocityIntr>(entt::get<Velocity, client::VelocityPrev>);
+
+ 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<float>(globals::fixed_accumulator) / static_cast<float>(globals::fixed_frametime_us);
transform_interpolate(alpha);
head_interpolate(alpha);
+ velocity_interpolate(alpha);
}
} \ No newline at end of file