group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
entity_interpolation Namespace Reference

Classes

struct  InterpolatedTransform
 Result of sampling an entity's interpolation buffer. More...
struct  SampleInputs
 PR-28: full sample payload. More...

Functions

void appendSample (entt::registry &registry, entt::entity e, Uint64 captureNs, const SampleInputs &inputs)
 Append a snapshot sample at captureNs into the entity's InterpolationBuffer, creating the component on first call.
InterpolatedTransform sample (const entt::registry &registry, entt::entity e, Uint64 renderTimeNs, const glm::vec3 &fallbackPos, float fallbackYaw)
 Look up e's interpolated transform at renderTimeNs.

Function Documentation

◆ appendSample()

void entity_interpolation::appendSample ( entt::registry & registry,
entt::entity e,
Uint64 captureNs,
const SampleInputs & inputs )

Append a snapshot sample at captureNs into the entity's InterpolationBuffer, creating the component on first call.

O(1) — single ring slot write. Caller is responsible for excluding the local player (whose render path uses prediction, not interpolation).

Parameters
registryClient registry.
eEntity that just had a snapshot applied to it.
captureNsWall-clock timestamp (SDL_GetTicksNS()) of the apply. Must be monotonically non-decreasing per-entity for the bracket-search in sample to work correctly; in practice callers pass the same now for every entity they touch in a single dispatchMessage.
inputsFull sample payload — position + velocity + yaw + pitch + animator-relevant PlayerVisState bits.
Here is the caller graph for this function:

◆ sample()

InterpolatedTransform entity_interpolation::sample ( const entt::registry & registry,
entt::entity e,
Uint64 renderTimeNs,
const glm::vec3 & fallbackPos,
float fallbackYaw )

Look up e's interpolated transform at renderTimeNs.

Walks the entity's InterpolationBuffer for the two adjacent samples bracketing renderTimeNs and lerps between them. Behaviour at the edges (mirrors Source engine and Phase 5a's freeze-no-extrapolate policy):

  • No buffer / < 2 samples / renderTimeNs == 0 → returns {fallbackPos, fallbackYaw, fromBuffer = false} (other fields zero).
  • renderTimeNs ≤ oldest → returns oldest sample (snap to start).
  • renderTimeNs ≥ newest → returns newest sample (freeze; no extrapolation).
  • Otherwise → linear interpolation between bracketing samples for continuous fields; older sample for discrete fields, fromBuffer = true.

O(8) worst case — capacity is fixed at InterpolationBuffer::k_capacity.

Here is the caller graph for this function: