|
group2 0.1.0
CSE 125 Group 2
|
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 ®istry, float mouseSensitivity) |
| Sample mouse delta and accumulate into yaw / pitch. | |
| void | runMovementKeys (Registry ®istry) |
| Sample keyboard state into the movement flags. | |
| void | runInputSample (Registry ®istry, float mouseSensitivity=0.001f) |
| Legacy combined sampler — calls both runMouseLook and runMovementKeys. | |
| void | runInputSend (Registry ®istry, 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 ®istry, float dt, const physics::WorldGeometry &world) |
| Run one tick of swept-AABB collision for all physics entities. | |
| void | runMovement (Registry ®istry, float dt, const physics::WorldGeometry &world) |
| Apply one tick of player movement physics to all eligible entities. | |
| void | update (Registry ®istry, 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 |
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.
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.
|
static |
Run all depenetration passes (planes, boxes, brushes).
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| world | World collision geometry. |
|
static |
Push the entity out of a static AABB it currently overlaps.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| box | Static axis-aligned bounding box to test against. |
|
static |
Push the entity out of a convex brush it currently overlaps.
Only fires if the entity is inside ALL planes simultaneously.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| brush | Convex brush to test against. |
|
static |
Push the entity out of any infinite planes it currently overlaps.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| planes | Infinite planes to test against. |
| 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]:
grounded flag.pos + vel * dt.grounded = true if a floor surface (normal.y > 0.7) is hit.| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| world | World collision geometry (planes, boxes, brushes) for this tick. |
|
inline |
Deserialise a raw InputSnapshot packet into a gameplay Event.
| data | Pointer to the raw InputSnapshot bytes. |
|
inline |
Legacy combined sampler — calls both runMouseLook and runMovementKeys.
| registry | The ECS registry. |
| mouseSensitivity | Radians per pixel (default 0.001). |
Send the local player's current InputSnapshot over the network.
| registry | The ECS registry. |
| conn | Network connection to the server. |
|
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.
| registry | The ECS registry. |
| mouseSensitivity | Radians per pixel of mouse movement. |
| void systems::runMovement | ( | Registry & | registry, |
| float | dt, | ||
| const physics::WorldGeometry & | world | ||
| ) |
Apply one tick of player movement physics to all eligible entities.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| world | World collision geometry (needed for wall/climb/ledge detection). |
|
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.
| registry | The ECS registry. |
|
static |
Keep the entity glued to descending slopes and step-downs.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| world | World collision geometry. |
|
static |
Attempt to step over a low obstacle when a wall is hit.
| pos | Entity position (modified in place on success). |
| vel | Entity velocity (modified in place on success). |
| halfExtents | AABB half-extents of the entity. |
| remainingTime | Time remaining in the current bump iteration. |
| world | World collision geometry. |
|
inline |
Placeholder system — replace with real logic.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
|
staticconstexpr |
|
staticconstexpr |