group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
InterpolationBuffer Struct Reference

Render-time interpolation history for a remote entity. More...

#include <InterpolationBuffer.hpp>

Classes

struct  Sample
 One snapshot's worth of interpolatable state. More...

Public Attributes

std::array< Sample, k_capacityring {}
std::size_t head = 0
 Next write index (mod k_capacity).
std::size_t count = 0
 Live entries; saturates at k_capacity.

Static Public Attributes

static constexpr std::size_t k_capacity = 8
 Maximum samples retained. Sized for ~250 ms at 32 Hz snapshot rate.

Detailed Description

Render-time interpolation history for a remote entity.

PR-11 (server-perf): entity interpolation with N-tick render delay (Valorant / Fortnite / Source-engine cl_interp style). Each time a snapshot is applied, the network thread appends one Sample per replicated entity into its ring. At render time, the renderer asks for the entity's state at now - (delayTicks × snapshotInterval) — the lookup walks the ring for the two samples bracketing that timestamp and lerps between them.

Why a ring? To absorb network jitter and packet loss. A 2-tick render delay (~62.5 ms at 32 Hz snapshot rate) means the renderer always has ≥ 1 future sample to interpolate toward, so a single dropped snapshot is invisible — the lerp targets the next-arriving sample instead. Without the buffer (Phase 5a), a missed snapshot froze the entity for ~31 ms (alpha clamps to 1.0 in the old path).

Capacity 8 covers ~250 ms of history at 32 Hz — enough to smooth any reasonable network jitter while staying tiny: 8 × (8 + 12 + 4) bytes = 192 B / entity, ≈ 96 KB at 500 entities.

Note
Client-only. The local player is excluded — that entity uses client-side prediction and renders at "now", not "now - delay". Excluded by checking LocalPlayer before append.

Member Data Documentation

◆ count

std::size_t InterpolationBuffer::count = 0

Live entries; saturates at k_capacity.

◆ head

std::size_t InterpolationBuffer::head = 0

Next write index (mod k_capacity).

◆ k_capacity

std::size_t InterpolationBuffer::k_capacity = 8
staticconstexpr

Maximum samples retained. Sized for ~250 ms at 32 Hz snapshot rate.

◆ ring

std::array<Sample, k_capacity> InterpolationBuffer::ring {}

The documentation for this struct was generated from the following file: