group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
PlayerSimState.hpp
Go to the documentation of this file.
1
15
16#pragma once
17
18#include "PlayerVisState.hpp" // for PlayerStateRef + transitively PlayerStateEnums
21
22#include <cstdint>
23#include <glm/vec2.hpp>
24#include <glm/vec3.hpp>
25
32{
33 // ── Jump state ─────────────────────────────────────────────────────────
34 bool canDoubleJump{true};
37 bool jumpedThisTick{false};
38 bool jumpHeldLastTick{false};
39 float jumpCooldown{0.0f};
40
41 // ── Coyote time ────────────────────────────────────────────────────────
42 float coyoteTimer{0.0f};
44 float groundedDuration{0.0f};
47
48 // ── Jump lurch ─────────────────────────────────────────────────────────
49 bool jumpLurchEnabled{false};
50 float jumpLurchTimer{0.0f};
51 glm::vec2 moveInputsOnJump{0.0f};
52
53 // ── Sliding ────────────────────────────────────────────────────────────
54 float slideTimer{0.0f};
56 float slideBoostCooldown{0.0f};
58 bool canEnterSlide{true};
59
60 // ── Wallrunning ────────────────────────────────────────────────────────
61 glm::vec3 wallNormal{0.0f};
62 glm::vec3 wallForward{0.0f};
63 glm::vec3 wallAnchor{0.0f};
64 float wallRunTimer{0.0f};
65 float wallRunSpeedTimer{0.0f};
66 float exitWallTimer{0.0f};
67 uint32_t wallMeshIndex{UINT32_MAX};
68 uint32_t wallTriId{UINT32_MAX};
70 bool wallAttachmentValid{false};
72 glm::vec3 wallCornerAnchor{0.0f};
73 glm::vec3 wallCornerFromNormal{0.0f};
74 glm::vec3 wallCornerFromForward{0.0f};
75 glm::vec3 wallCornerToNormal{0.0f};
76 glm::vec3 wallCornerToForward{0.0f};
77 uint32_t wallCornerMeshIndex{UINT32_MAX};
78 uint32_t wallCornerTriId{UINT32_MAX};
80 float wallCornerTimer{0.0f};
81 glm::vec3 wallCornerIgnoreNormal{0.0f};
84 glm::vec3 wallrunBlockerNormal{0.0f};
85 float wallrunBlockerTimer{0.0f};
88 bool wasWallRunning{false};
89 glm::vec3 pendingKccCorrection{0.0f};
90
92 bool hasLastKccResult{false};
93 glm::vec3 kccPreviousPosBefore{0.0f};
94 glm::vec3 kccPreviousPosAfter{0.0f};
95 glm::vec3 kccPreviousDepenDelta{0.0f};
98
99 // Wall blacklist: stores the last wall's normal + height to prevent regrab.
100 glm::vec3 wallBlacklistNormal{0.0f};
101 float wallBlacklistHeight{-1e10f};
103
104 // ── Collision recovery ─────────────────────────────────────────────────
105 glm::vec3 lastSafePosition{0.0f};
107
108 // ── Grappling hook (Widowmaker-style: direct pull, look-biased launch) ─
111 float grapplePullTimer{0.0f};
112 glm::vec3 grapplePullDir{0.0f};
114
115 // ── Grapple perch mode (hold jump while grappling → arc above hook) ─
116 // No state needed: the trajectory is computed each tick purely from
117 // current Position + replicated grapplePoint, so it stays in sync
118 // across server simulation, client prediction, and reconciliation
119 // replay (PlayerSimState is server-only, so anything stateful here
120 // would drift on every snapshot apply and cause visible jitter).
121};
122
136
Per-tick collision feedback emitted by the player KCC.
Visible / replicated half of the player locomotion state.
Triangle-mesh collision with BVH acceleration and seam welding.
TriRegion
Voronoi region of a triangle.
Definition TriMeshCollision.hpp:27
@ Face
Definition TriMeshCollision.hpp:28
Read-only counterpart of PlayerStateRef, for const consumers.
Definition PlayerSimState.hpp:139
const PlayerSimState & sim
Definition PlayerSimState.hpp:141
const PlayerVisState & vis
Definition PlayerSimState.hpp:140
Server-only locomotion bookkeeping.
Definition PlayerSimState.hpp:32
float exitWallTimer
Remaining exit-wall grace time (s).
Definition PlayerSimState.hpp:66
float wallRunTimer
Time on current wall (s).
Definition PlayerSimState.hpp:64
uint32_t wallCornerMeshIndex
Pending wall mesh after corner clearance.
Definition PlayerSimState.hpp:77
physics::TriRegion wallCornerRegion
Pending wall feature after clearance.
Definition PlayerSimState.hpp:79
bool wallAttachmentValid
True while the wallrun has a collision-backed attachment.
Definition PlayerSimState.hpp:70
bool canEnterSlide
Cleared when in air, set on landing.
Definition PlayerSimState.hpp:58
bool kccPreviousFrameValid
True once previous KCC frame fields are initialized.
Definition PlayerSimState.hpp:96
bool wasGroundedLastTick
Definition PlayerSimState.hpp:43
bool jumpHeldLastTick
Was jump key held on the previous tick (edge detection).
Definition PlayerSimState.hpp:38
int wallrunBlockedFrames
Consecutive frames constrained by the active blocker.
Definition PlayerSimState.hpp:86
bool canDoubleJump
Refreshed only after k_doubleJumpGroundedRefreshTime of continuous grounded OnFoot time.
Definition PlayerSimState.hpp:34
glm::vec3 wallCornerToForward
Pending wall tangent to use after clearance.
Definition PlayerSimState.hpp:76
uint32_t wallMeshIndex
Current static collision mesh under the wall attachment, if any.
Definition PlayerSimState.hpp:67
glm::vec3 wallrunBlockerNormal
Collision normal of the active wallrun blocker.
Definition PlayerSimState.hpp:84
bool jumpLurchEnabled
True during the lurch grace window after jumping.
Definition PlayerSimState.hpp:49
float wallBlacklistHeight
Definition PlayerSimState.hpp:101
int slideFatigueDecayAccum
Tick accumulator for fatigue recovery.
Definition PlayerSimState.hpp:57
physics::KccFrameResult lastKccResult
Last collision feedback frame emitted by KCC.
Definition PlayerSimState.hpp:91
float jumpCooldown
Minimum time before double jump is available (s).
Definition PlayerSimState.hpp:39
glm::vec3 kccPreviousPosBefore
Previous KCC input position for oscillation detection.
Definition PlayerSimState.hpp:93
int slideFatigueCounter
Diminishing returns on consecutive slidehops.
Definition PlayerSimState.hpp:55
int kccOscillationFrames
Consecutive ABAB-style KCC oscillation detections.
Definition PlayerSimState.hpp:97
bool lastSafePositionValid
Definition PlayerSimState.hpp:106
float wallrunCeilingConstrainedTimer
Short grace after head/ceiling contact while wallrun remains valid.
Definition PlayerSimState.hpp:87
glm::vec3 wallCornerAnchor
Corner/seam point used as the transition clearance origin.
Definition PlayerSimState.hpp:72
uint32_t wallTriId
Current mesh triangle under the wall attachment, if any.
Definition PlayerSimState.hpp:68
glm::vec3 wallNormal
Normal of the wall being run on.
Definition PlayerSimState.hpp:61
float slideTimer
How long the current slide has lasted (s).
Definition PlayerSimState.hpp:54
bool wallBlacklistActive
Definition PlayerSimState.hpp:102
bool jumpedThisTick
Set during the tick a jump occurs (for lurch setup).
Definition PlayerSimState.hpp:37
glm::vec3 wallAnchor
Closest point on the attached wall surface.
Definition PlayerSimState.hpp:63
glm::vec3 kccPreviousDepenDelta
Previous depenetration push for oscillation detection.
Definition PlayerSimState.hpp:95
glm::vec3 wallCornerFromForward
Old wall tangent held during the corner approach.
Definition PlayerSimState.hpp:74
float wallCornerIgnoreTimer
Remaining time to suppress source-wall backtracking.
Definition PlayerSimState.hpp:82
glm::vec3 pendingKccCorrection
One-tick collision-owned correction requested by movement.
Definition PlayerSimState.hpp:89
float jumpLurchTimer
Time elapsed since the jump that enabled lurch (s).
Definition PlayerSimState.hpp:50
float groundedDuration
Time continuously grounded (s); resets on leaving ground.
Definition PlayerSimState.hpp:44
float wallrunBlockerTimer
Time since the blocker was last confirmed by KCC.
Definition PlayerSimState.hpp:85
float grapplePullTimer
Time spent being pulled (s).
Definition PlayerSimState.hpp:111
float wallCornerTimer
Time spent in the active corner transition (s).
Definition PlayerSimState.hpp:80
glm::vec3 wallCornerIgnoreNormal
Source wall briefly ignored after a corner commit.
Definition PlayerSimState.hpp:81
uint32_t wallCornerTriId
Pending wall triangle after corner clearance.
Definition PlayerSimState.hpp:78
glm::vec3 lastSafePosition
Last KCC-verified non-penetrating capsule center.
Definition PlayerSimState.hpp:105
glm::vec3 wallBlacklistNormal
Definition PlayerSimState.hpp:100
glm::vec3 kccPreviousPosAfter
Previous KCC output position for oscillation detection.
Definition PlayerSimState.hpp:94
glm::vec3 grapplePullDir
Cached pull direction (toward anchor at fire time).
Definition PlayerSimState.hpp:112
bool grappleInputLastTick
Edge detection on the grapple key.
Definition PlayerSimState.hpp:113
physics::TriRegion wallRegion
Closest feature on wallMeshIndex / wallTriId.
Definition PlayerSimState.hpp:69
float slideBoostCooldown
Remaining cooldown before next slide boost (s).
Definition PlayerSimState.hpp:56
bool wallCornerTransitionActive
True while carrying a pending external-corner handoff.
Definition PlayerSimState.hpp:71
glm::vec2 moveInputsOnJump
WASD direction when jump started (for direction-change detection).
Definition PlayerSimState.hpp:51
bool wasWallRunning
Set briefly after leaving wallrun (coyote wall jump).
Definition PlayerSimState.hpp:88
float wallRunSpeedTimer
Timer for the speed-loss delay.
Definition PlayerSimState.hpp:65
glm::vec3 wallCornerToNormal
Pending wall normal to attach after clearance.
Definition PlayerSimState.hpp:75
glm::vec3 wallForward
Direction of travel along the wall.
Definition PlayerSimState.hpp:62
bool hasLastKccResult
True after the first KCC frame has been recorded.
Definition PlayerSimState.hpp:92
float coyoteTimer
Remaining grace time after leaving ground/wall (s).
Definition PlayerSimState.hpp:42
bool wallrunBlockerActive
True while collision is sliding/holding against a non-traversable blocker.
Definition PlayerSimState.hpp:83
glm::vec3 wallCornerFromNormal
Wall normal held until the capsule clears the old wall edge.
Definition PlayerSimState.hpp:73
bool grappleCooldownActive
True during cooldown between uses.
Definition PlayerSimState.hpp:109
float grappleCooldownTimer
Remaining cooldown time (s).
Definition PlayerSimState.hpp:110
Combined-reference helper for code that needs both halves.
Definition PlayerSimState.hpp:132
PlayerSimState & sim
Definition PlayerSimState.hpp:134
PlayerVisState & vis
Definition PlayerSimState.hpp:133
Replicated subset of player locomotion state.
Definition PlayerVisState.hpp:39
Collision-owned result for one player KCC step.
Definition KccFrameResult.hpp:16