Jazz2::Actors::Multiplayer::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.

Public static functions

static auto Now() -> std::int64_t
Returns the current timestamp of the interpolation clock, in milliseconds.

Public functions

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.