StateInterpolationBuffer class
Interpolation buffer for actor positions received from a remote authority.
Ring buffer of timestamped positions received over the network, sampled ServerDelay milliseconds in the past so movement stays smooth between (and across late) updates. Shared by the server-side shadow of a remote player (RemotePlayerOnServer) and by client-side remote actors (RemoteActor).
Public static variables
-
static std::
int64_t ServerDelay constexpr - How far in the past the received state is displayed, in milliseconds.
- static float MaxInterpolatedDistance constexpr
- Longest jump between two received positions that is still interpolated, in pixels.
Public static functions
-
static auto Now() -> std::
int64_t - Returns the current timestamp of the interpolation clock, in milliseconds.
Public functions
- auto IsTeleport(Vector2f pos) const -> bool
- Returns
trueif the jump from the most recently pushed position toposis too long to interpolate. -
void Reset(Vector2f pos,
std::
int64_t now) - Resets the whole buffer to a single position (spawn, warp, forced resync), disabling interpolation.
- auto GetLatest() const -> Vector2f
- Returns the most recently pushed position.
-
void Push(Vector2f pos,
std::
int64_t now, bool wasVisible) - Pushes a newly received position.
-
auto Sample(std::
int64_t renderTime, Vector2f& result) const -> bool - Samples the interpolated position at the given time.
Function documentation
void Jazz2:: Actors:: Multiplayer:: StateInterpolationBuffer:: Push(Vector2f pos,
std:: int64_t now,
bool wasVisible)
Pushes a newly received position.
When wasVisible is false, the actor was hidden before this update, so the previous and current frames are collapsed to the new position to disable interpolation across the gap.
bool Jazz2:: Actors:: Multiplayer:: StateInterpolationBuffer:: Sample(std:: int64_t renderTime,
Vector2f& result) const
Samples the interpolated position at the given time.
| Returns | true and writes result when renderTime is covered by the buffer; false when it is ahead of the newest received state, in which case result is left untouched. |
|---|
Variable documentation
static float Jazz2:: Actors:: Multiplayer:: StateInterpolationBuffer:: MaxInterpolatedDistance constexpr
Longest jump between two received positions that is still interpolated, in pixels.
Nothing covers this much ground between two updates - even the fastest legitimate movement needs several of them - so a longer jump is a teleport (a warp or a respawn somewhere the sender didn't flag as such), and interpolating across it would slide the actor through the level instead.