feat(client-entity): use snapshot history for entity interpolation

Replace exponential smoothing with a buffered snapshot system. Each entity keeps a deque of position/direction snapshots with timestamps; the render transform is interpolated at a fixed 100 ms render delay to hide network jitter. Snapshots are capped to 16 entries.
This commit is contained in:
2026-08-07 09:13:40 +08:00
parent 6e7bef8626
commit d3d277a231
3 changed files with 92 additions and 12 deletions

View File

@@ -2,6 +2,8 @@
#include "Cubed/gameplay/ecs/animation.hpp"
#include "Cubed/gameplay/ecs/transform.hpp"
#include "Cubed/gameplay/model.hpp"
#include <deque>
namespace Cubed {
struct BaseClientCreature {
@@ -16,4 +18,14 @@ struct SoundTime {
float next_call_time;
};
struct ClientEntitySnapshot {
double time_ms = 0.0;
glm::vec3 pos{0.0f};
glm::vec3 dir{0.0f};
};
struct ClientEntityState {
std::deque<ClientEntitySnapshot> history;
};
} // namespace Cubed

View File

@@ -4,6 +4,7 @@
#include <cstdint>
namespace Cubed {
namespace Tools {
// return ms
inline uint64_t get_time_ticks() { return SDL_GetTicks(); }
} // namespace Tools