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

Client-only input sampling system — split into two halves so mouse look can run every iterate() (smooth camera at any FPS) while movement keys run once per physics tick group (server-consistent). More...

Functions

void runMouseLook (Registry &registry, float mouseSensitivity)
 Sample mouse delta and accumulate into yaw / pitch.
 
void runMovementKeys (Registry &registry)
 Sample keyboard state into the movement flags.
 
void runInputSample (Registry &registry, float mouseSensitivity=0.001f)
 Legacy combined sampler — calls both runMouseLook and runMovementKeys.
 
void runInputSend (Registry &registry, Client &conn)
 Send the local player's current InputSnapshot over the network.
 
static void depenetratePlanes (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, std::span< const physics::Plane > planes)
 Push the entity out of any infinite planes it currently overlaps.
 
static void depenetrateBox (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldAABB &box)
 Push the entity out of a static AABB it currently overlaps.
 
static void depenetrateBrush (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldBrush &brush)
 Push the entity out of a convex brush it currently overlaps.
 
static void depenetrate (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldGeometry &world)
 Run all depenetration passes (planes, boxes, brushes).
 
static bool tryStepUp (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, float remainingTime, const physics::WorldGeometry &world)
 Attempt to step over a low obstacle when a wall is hit.
 
static void snapToGround (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldGeometry &world)
 Keep the entity glued to descending slopes and step-downs.
 
void runCollision (Registry &registry, float dt, const physics::WorldGeometry &world)
 Run one tick of swept-AABB collision for all physics entities.
 
void runMovement (Registry &registry, float dt, const physics::WorldGeometry &world)
 Apply one tick of player movement physics to all eligible entities.
 
void update (Registry &registry, float dt)
 Placeholder system — replace with real logic.
 
Event runInputReceive (const void *data)
 Deserialise a raw InputSnapshot packet into a gameplay Event.
 

Variables

static constexpr float k_pushback = 0.03125f
 
static constexpr float k_groundProbeDistance = physics::k_stepHeight
 

Detailed Description

Client-only input sampling system — split into two halves so mouse look can run every iterate() (smooth camera at any FPS) while movement keys run once per physics tick group (server-consistent).

Input receive system functions.

ECS systems namespace.

Shared movement system — compiled identically on client and server.

Shared collision system — compiled identically on client and server.

Reconciles server state against the client's predicted history (not yet implemented).

Client-side prediction system (not yet implemented).

Client-only system that serialises and sends input to the server.

Will apply local input immediately without waiting for server confirmation, storing snapshots in a ring buffer for reconciliation.

When the server sends a correction, this system rewinds the ring buffer to the authoritative tick and re-simulates forward to the current tick.

Any divergence between client and server builds is a bug (breaks prediction).

Any divergence between client and server builds is a bug (breaks prediction).

Implements the full Titanfall-inspired movement state machine: OnFoot → Sliding → WallRunning → Climbing → LedgeGrabbing with sprint, double jump, coyote time, jump lurch, air strafing, and speed cap.

Note
Position integration is NOT done here — CollisionSystem owns that via swept AABB.

Each free function (or callable) represents one system. A system receives the shared Registry and any per-frame state it needs, then queries and mutates components.

Concrete system implementations live in individual .hpp/.cpp pairs under this directory.

Function Documentation

◆ depenetrate()

static void systems::depenetrate ( glm::vec3 &  pos,
glm::vec3 &  vel,
const glm::vec3 &  halfExtents,
const physics::WorldGeometry world 
)
static

Run all depenetration passes (planes, boxes, brushes).

Parameters
posEntity position (modified in place).
velEntity velocity (modified in place).
halfExtentsAABB half-extents of the entity.
worldWorld collision geometry.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ depenetrateBox()

static void systems::depenetrateBox ( glm::vec3 &  pos,
glm::vec3 &  vel,
const glm::vec3 &  halfExtents,
const physics::WorldAABB box 
)
static

Push the entity out of a static AABB it currently overlaps.

Parameters
posEntity position (modified in place).
velEntity velocity (modified in place).
halfExtentsAABB half-extents of the entity.
boxStatic axis-aligned bounding box to test against.
Here is the caller graph for this function:

◆ depenetrateBrush()

static void systems::depenetrateBrush ( glm::vec3 &  pos,
glm::vec3 &  vel,
const glm::vec3 &  halfExtents,
const physics::WorldBrush brush 
)
static

Push the entity out of a convex brush it currently overlaps.

Only fires if the entity is inside ALL planes simultaneously.

Parameters
posEntity position (modified in place).
velEntity velocity (modified in place).
halfExtentsAABB half-extents of the entity.
brushConvex brush to test against.
Here is the caller graph for this function:

◆ depenetratePlanes()

static void systems::depenetratePlanes ( glm::vec3 &  pos,
glm::vec3 &  vel,
const glm::vec3 &  halfExtents,
std::span< const physics::Plane planes 
)
static

Push the entity out of any infinite planes it currently overlaps.

Parameters
posEntity position (modified in place).
velEntity velocity (modified in place).
halfExtentsAABB half-extents of the entity.
planesInfinite planes to test against.
Here is the caller graph for this function:

◆ runCollision()

void systems::runCollision ( Registry registry,
float  dt,
const physics::WorldGeometry world 
)

Run one tick of swept-AABB collision for all physics entities.

For every entity with [Position, Velocity, CollisionShape, PlayerState]:

  1. Clears the grounded flag.
  2. Sweeps the AABB from current position toward pos + vel * dt.
  3. On hit: moves to the contact point, clips velocity, repeats up to 4 times (Quake-style bumping handles corners and multi-surface contacts).
  4. Sets grounded = true if a floor surface (normal.y > 0.7) is hit.
Note
Position integration lives here, not in MovementSystem.
Parameters
registryThe ECS registry.
dtFixed physics delta time in seconds.
worldWorld collision geometry (planes, boxes, brushes) for this tick.
Here is the call graph for this function:

◆ runInputReceive()

Event systems::runInputReceive ( const void *  data)
inline

Deserialise a raw InputSnapshot packet into a gameplay Event.

Parameters
dataPointer to the raw InputSnapshot bytes.
Returns
An Event populated with the decoded movement and action intents.

◆ runInputSample()

void systems::runInputSample ( Registry registry,
float  mouseSensitivity = 0.001f 
)
inline

Legacy combined sampler — calls both runMouseLook and runMovementKeys.

Parameters
registryThe ECS registry.
mouseSensitivityRadians per pixel (default 0.001).
Here is the call graph for this function:

◆ runInputSend()

void systems::runInputSend ( Registry registry,
Client conn 
)
inline

Send the local player's current InputSnapshot over the network.

Parameters
registryThe ECS registry.
connNetwork connection to the server.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ runMouseLook()

void systems::runMouseLook ( Registry registry,
float  mouseSensitivity 
)
inline

Sample mouse delta and accumulate into yaw / pitch.

Must be called every iterate() call regardless of whether a physics tick fires — this keeps camera rotation smooth at the render frame rate. SDL_GetRelativeMouseState returns the accumulated delta since the previous call, so the total rotation over any time window is identical regardless of call frequency.

Parameters
registryThe ECS registry.
mouseSensitivityRadians per pixel of mouse movement.
Here is the caller graph for this function:

◆ runMovement()

void systems::runMovement ( Registry registry,
float  dt,
const physics::WorldGeometry world 
)

Apply one tick of player movement physics to all eligible entities.

Parameters
registryThe ECS registry.
dtFixed physics delta time in seconds.
worldWorld collision geometry (needed for wall/climb/ledge detection).
Here is the call graph for this function:

◆ runMovementKeys()

void systems::runMovementKeys ( Registry registry)
inline

Sample keyboard state into the movement flags.

Should be called once per physics tick group when input is synced with physics (the default) so movement calculations match the server. Can also be called every iterate() when the sync toggle is off.

Parameters
registryThe ECS registry.
Here is the caller graph for this function:

◆ snapToGround()

static void systems::snapToGround ( glm::vec3 &  pos,
glm::vec3 &  vel,
const glm::vec3 &  halfExtents,
const physics::WorldGeometry world 
)
static

Keep the entity glued to descending slopes and step-downs.

Parameters
posEntity position (modified in place).
velEntity velocity (modified in place).
halfExtentsAABB half-extents of the entity.
worldWorld collision geometry.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryStepUp()

static bool systems::tryStepUp ( glm::vec3 &  pos,
glm::vec3 &  vel,
const glm::vec3 &  halfExtents,
float  remainingTime,
const physics::WorldGeometry world 
)
static

Attempt to step over a low obstacle when a wall is hit.

Parameters
posEntity position (modified in place on success).
velEntity velocity (modified in place on success).
halfExtentsAABB half-extents of the entity.
remainingTimeTime remaining in the current bump iteration.
worldWorld collision geometry.
Returns
True if the step succeeded and position/velocity were updated.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void systems::update ( Registry registry,
float  dt 
)
inline

Placeholder system — replace with real logic.

Parameters
registryThe ECS registry.
dtFixed physics delta time in seconds.

Variable Documentation

◆ k_groundProbeDistance

constexpr float systems::k_groundProbeDistance = physics::k_stepHeight
staticconstexpr

◆ k_pushback

constexpr float systems::k_pushback = 0.03125f
staticconstexpr