mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
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:
@@ -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
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
namespace Cubed {
|
||||
namespace Tools {
|
||||
// return ms
|
||||
inline uint64_t get_time_ticks() { return SDL_GetTicks(); }
|
||||
} // namespace Tools
|
||||
|
||||
|
||||
Reference in New Issue
Block a user