group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
PhaseDiagnostic.hpp
Go to the documentation of this file.
1
21
22#pragma once
23
24#include <cstdint>
25#include <entt/entt.hpp>
26#include <glm/vec3.hpp>
27#include <string_view>
28
29namespace physics::diag
30{
31
33enum class PhaseFlag : uint32_t
34{
35 None = 0,
36 Grounded = 1u << 0,
37 WallRunning = 1u << 1,
38 Sliding = 1u << 2,
39 Climbing = 1u << 3,
40 LedgeGrabbing = 1u << 4,
41 GrappleActive = 1u << 5,
42 DoubleJumped = 1u << 6,
43 GravityFlipped = 1u << 7,
47 DepenCancelled = 1u << 8,
50 DeepPenetration = 1u << 9,
54 BumpExhausted = 1u << 10,
57 SuspectedPhase = 1u << 11,
58};
59
61{
62 return static_cast<PhaseFlag>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b));
63}
64inline PhaseFlag& operator|=(PhaseFlag& a, PhaseFlag b) noexcept
65{
66 a = a | b;
67 return a;
68}
69inline bool any(PhaseFlag a) noexcept
70{
71 return static_cast<uint32_t>(a) != 0u;
72}
73
77{
78 uint64_t tick = 0;
79 entt::entity entity{entt::null};
80 glm::vec3 posBefore{0.0f};
81 glm::vec3 posAfterDepen{0.0f};
82 glm::vec3 posAfter{0.0f};
83 glm::vec3 velBefore{0.0f};
84 glm::vec3 velAfter{0.0f};
85 glm::vec3 lastHitNormal{0.0f};
86 float depenPushDistance = 0.0f;
87 int bumpHits = 0;
88 int moveMode = 0;
89 int wallrunSide = 0;
90 int jumpCount = 0;
92 char note[48] = {0};
93};
94
97void setEnabled(bool on) noexcept;
98[[nodiscard]] bool isEnabled() noexcept;
99
103void recordFrame(const PlayerFrame& frame) noexcept;
104
109void annotate(entt::entity entity, std::string_view label) noexcept;
110
114void consumeAnnotation(entt::entity entity, char (&out)[48]) noexcept;
115
123{
124 uint32_t triId = 0;
125 glm::vec3 playerPos{0.0f};
126 glm::vec3 faceNormal{0.0f};
127 glm::vec3 v0{0.0f};
128 glm::vec3 v1{0.0f};
129 glm::vec3 v2{0.0f};
130 float signedDist = 0.0f;
131 float minkowskiR = 0.0f;
132 float depth = 0.0f;
133 int region = 0;
134 uint8_t edgeFlags = 0;
135 uint8_t vertFlags = 0;
136};
137
143void recordDepenContact(const DepenContact& contact) noexcept;
144
145} // namespace physics::diag
Definition DeterminismHash.cpp:16
PhaseFlag
Bitfield flags attached to each logged row — auto-detected.
Definition PhaseDiagnostic.hpp:34
@ DepenCancelled
Depen found overlaps but the aggregated push direction cancelled out (rare; either trapped between mi...
Definition PhaseDiagnostic.hpp:47
@ LedgeGrabbing
Definition PhaseDiagnostic.hpp:40
@ DeepPenetration
Depen had to push the player by >20 u in one tick — the player was deep inside geometry before depen.
Definition PhaseDiagnostic.hpp:50
@ SuspectedPhase
Actual per-tick position delta exceeded velocity * dt by > 2× + 5 u — the player likely tunnelled thr...
Definition PhaseDiagnostic.hpp:57
@ DoubleJumped
Definition PhaseDiagnostic.hpp:42
@ BumpExhausted
The bump loop consumed all 4 iterations and still had remainingTime > 0 — the player was grinding aga...
Definition PhaseDiagnostic.hpp:54
@ GrappleActive
Definition PhaseDiagnostic.hpp:41
@ None
Definition PhaseDiagnostic.hpp:35
@ Grounded
Definition PhaseDiagnostic.hpp:36
@ Climbing
Definition PhaseDiagnostic.hpp:39
@ WallRunning
Definition PhaseDiagnostic.hpp:37
@ GravityFlipped
Definition PhaseDiagnostic.hpp:43
@ Sliding
Definition PhaseDiagnostic.hpp:38
PhaseFlag operator|(PhaseFlag a, PhaseFlag b) noexcept
Definition PhaseDiagnostic.hpp:60
void recordDepenContact(const DepenContact &c) noexcept
Append one depen-contact row to its own CSV log (depen-trace-<timestamp>.csv in the working dir).
Definition PhaseDiagnostic.cpp:232
void consumeAnnotation(entt::entity entity, char(&out)[48]) noexcept
Drain any queued annotation for entity into out, then clear it.
Definition PhaseDiagnostic.cpp:140
PhaseFlag & operator|=(PhaseFlag &a, PhaseFlag b) noexcept
Definition PhaseDiagnostic.hpp:64
void annotate(entt::entity entity, std::string_view label) noexcept
Attach a text annotation to the NEXT frame recorded for the given entity.
Definition PhaseDiagnostic.cpp:132
bool isEnabled() noexcept
Definition PhaseDiagnostic.cpp:127
void setEnabled(bool on) noexcept
Enable / disable telemetry.
Definition PhaseDiagnostic.cpp:122
bool any(PhaseFlag a) noexcept
Definition PhaseDiagnostic.hpp:69
void recordFrame(const PlayerFrame &f) noexcept
Append a player's per-tick frame to the open CSV log.
Definition PhaseDiagnostic.cpp:155
One row of depen-contact telemetry.
Definition PhaseDiagnostic.hpp:123
glm::vec3 faceNormal
Cooked face normal of the offending triangle.
Definition PhaseDiagnostic.hpp:126
glm::vec3 v2
Definition PhaseDiagnostic.hpp:129
uint32_t triId
Definition PhaseDiagnostic.hpp:124
uint8_t edgeFlags
Cooked active-edge mask (bit i ⇔ edge i active per Phase 2 welding).
Definition PhaseDiagnostic.hpp:134
uint8_t vertFlags
Cooked active-vertex mask.
Definition PhaseDiagnostic.hpp:135
float minkowskiR
|faceN|·halfExtents — depth would saturate at 2·R (s = -R).
Definition PhaseDiagnostic.hpp:131
glm::vec3 v1
Definition PhaseDiagnostic.hpp:128
int region
Closest feature on the triangle: 0=Face, 1=Edge0, 2=Edge1, 3=Edge2, 4=Vert0, 5=Vert1,...
Definition PhaseDiagnostic.hpp:133
float signedDist
dot(faceN, playerPos - v0). Negative ⇒ player on back side.
Definition PhaseDiagnostic.hpp:130
float depth
MTV magnitude = R - signedDist.
Definition PhaseDiagnostic.hpp:132
glm::vec3 playerPos
Player capsule center at the moment of overlap.
Definition PhaseDiagnostic.hpp:125
glm::vec3 v0
Definition PhaseDiagnostic.hpp:127
One row of telemetry — captured per player per tick.
Definition PhaseDiagnostic.hpp:77
glm::vec3 posAfter
Final position, after bump loop + slope snap.
Definition PhaseDiagnostic.hpp:82
glm::vec3 velBefore
Velocity at tick start (already integrated by movement).
Definition PhaseDiagnostic.hpp:83
int bumpHits
Number of bump iterations that hit something.
Definition PhaseDiagnostic.hpp:87
int moveMode
MoveMode enum cast to int.
Definition PhaseDiagnostic.hpp:88
glm::vec3 posBefore
Position at tick start, BEFORE depen.
Definition PhaseDiagnostic.hpp:80
char note[48]
Free-form annotation slot (e.g., "wallrun-enter").
Definition PhaseDiagnostic.hpp:92
PhaseFlag flags
Definition PhaseDiagnostic.hpp:91
glm::vec3 velAfter
Velocity at tick end.
Definition PhaseDiagnostic.hpp:84
glm::vec3 posAfterDepen
After depen, BEFORE bump loop.
Definition PhaseDiagnostic.hpp:81
uint64_t tick
Definition PhaseDiagnostic.hpp:78
int jumpCount
Definition PhaseDiagnostic.hpp:90
glm::vec3 lastHitNormal
Normal of the last sweep hit in the bump loop (or 0).
Definition PhaseDiagnostic.hpp:85
float depenPushDistance
|posAfterDepen - posBefore|.
Definition PhaseDiagnostic.hpp:86
entt::entity entity
Definition PhaseDiagnostic.hpp:79
int wallrunSide
WallSide enum (None=0, Left=1, Right=2).
Definition PhaseDiagnostic.hpp:89