group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
DebugUI.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
10#include "network/ShotDebugReport.hpp" // PR-20: ShotDebugCapture.
11
12// Forward-declared so DebugUI doesn't drag in raycast / hitbox headers via the
13// gamepad aim-assist system. Full definition pulled in by DebugUI.cpp.
14namespace systems
15{
17}
18
19#include <SDL3/SDL.h>
20
21#include <array>
22#include <cstdint>
23#include <glm/mat4x4.hpp>
24#include <glm/vec3.hpp>
25#include <initializer_list>
26
27struct NetworkStats;
28class ParticleSystem;
29
44{
45public:
49 bool init(SDL_Window* window);
50
52 void shutdown();
53
56 void processEvent(const SDL_Event* event);
57
59 void newFrame();
60
76 void buildUI(const Registry& registry,
77 int tickCount,
78 float& mouseSensitivity,
79 float& gamepadLookSensitivity,
81 bool& renderSeparateFromPhysics,
82 bool& inputSyncedWithPhysics,
83 bool& limitFPSToMonitor,
84 float physicsHz,
85 float fpsCurrent,
86 float fpsMin,
87 float fpsMax,
88 float fps1pLow,
89 float fps5pLow);
90
95 void buildParticleUI(ParticleSystem& ps, glm::vec3 eyePos, glm::vec3 forward);
96
98 void buildNetworkUI(const NetworkStats& stats);
99
114 void buildNetworkSimUI();
115
118 [[nodiscard]] int getSimulatedLatencyMs() const noexcept { return simulatedLatencyMs_; }
119
122 [[nodiscard]] int getSimulatedLossPercent() const noexcept { return simulatedLossPct_; }
123
124 void buildWeaponUI(const Registry& registry);
125
136 void buildHitboxUI(const Registry& registry,
137 HitboxRig& hitboxRig,
138 const glm::mat4& viewProj,
139 float screenWidth,
140 float screenHeight);
141
142 bool showHitboxWindow = false;
143 bool drawHitboxOverlay = false;
144
153 const glm::mat4& viewProj,
154 float screenWidth,
155 float screenHeight);
156
157 bool showCollisionWindow = false;
158 bool drawCollisionOverlay = false;
159
167 void
168 buildWeaponSpawnerUI(const Registry& registry, const glm::mat4& viewProj, float screenWidth, float screenHeight);
169
172
180 void
181 buildDroppedWeaponUI(const Registry& registry, const glm::mat4& viewProj, float screenWidth, float screenHeight);
182
185
193 void buildSpawnPointUI(const Registry& registry, const glm::mat4& viewProj, float screenWidth, float screenHeight);
194
195 bool showSpawnPointWindow = false;
197
204 void buildKillzoneUI(const Registry& registry, const glm::mat4& viewProj, float screenWidth, float screenHeight);
205
206 bool showKillzoneWindow = false;
207 bool drawKillzoneOverlay = false;
208
209 // ── PR-20: Shot-debug visualizer (CSGO sv_showimpacts-style) ─────
210 //
211 // Holds a ring buffer of paired (client-side fire-time snapshot,
212 // server-side rewound snapshot) entries. ImGui panel lets the
213 // user pick how many recent shots to keep (1-30) and which to
214 // highlight in the 3-D overlay.
215 //
216 // The two snapshots reuse the same `ShotDebugCapture` type:
217 // - clientView is populated by `pushClientShot()` from Game.cpp
218 // when the local player fires a shot (with the visible-on-
219 // screen capsules of remote players at fire time).
220 // - serverView is populated by `pushServerShot()` from the
221 // `Client::onShotDebugReport` callback (with the historical
222 // capsules the server raycast against).
223 //
224 // The two halves are paired by `shotInputTick`; either may
225 // arrive first.
234 static constexpr int k_shotRingMax = 30;
235 std::array<ShotDebugPair, k_shotRingMax> shotRing{};
236 int shotRingHead = 0;
238
249
255
259
263
268 void buildShotDebugUI(const glm::mat4& viewProj, float screenWidth, float screenHeight);
269
270 // Per-type visibility toggles (all default on when overlay is active).
277
296 void buildContactDebugUI(const glm::mat4& viewProj, float screenWidth, float screenHeight);
297
299 bool drawContactOverlay = false;
300
301 // Per-source visibility toggles for the contact overlay.
314
318 float contactNormalLength = 16.0f;
319
321 float contactPointRadius = 4.0f;
322
328
331
333 void render();
334
339 void toggleDebugMenu();
340
349 {
350 const char* name;
351 bool* visible;
352 };
353 void buildDebugMenu(std::initializer_list<ExternalPanel> externalPanels);
354
355 bool showDebugMenu = false;
356
361 bool consumePhysicsCsvRecordingRequest(bool& enabled) noexcept;
362
363 bool pendingAmmoRefill_ = false;
365 std::int8_t pendingSetPrimaryWeapon_ = -1;
366 std::int8_t pendingSetSecondaryWeapon_ = -1;
367
368private:
370 bool showInspector = false;
371 bool showNetworkStats = false;
372 bool showNetworkSim = false;
373 bool showWeaponHud = false;
374
377
382
386
388 bool showPosition = true;
389 bool showPrevPosition = false;
390 bool showVelocity = true;
391 bool showCollisionShape = true;
392 bool showPlayerState = true;
393 bool showInputSnapshot = true;
394 bool showViewAngles = true;
395 bool showMovementChart = false;
396 bool showBhopAnalyzer = false;
397
403 void buildInspectorContents(const Registry& registry,
404 int tickCount,
405 float& mouseSensitivity,
406 float& gamepadLookSensitivity,
408 bool& renderSeparateFromPhysics,
409 bool& inputSyncedWithPhysics,
410 bool& limitFPSToMonitor,
411 float physicsHz,
412 float fpsCurrent,
413 float fpsMin,
414 float fpsMax,
415 float fps1pLow,
416 float fps5pLow);
417
421 void buildMovementChart(const Registry& registry);
422
428 void buildBhopAnalyzer(const Registry& registry);
429
430 // Bhop analyzer rolling state (ring buffers, persist across frames).
431 static constexpr int k_bhopHistorySize = 256;
438 float bhopPrevHSpeed_ = 0.0f;
439 bool bhopHasPrevSample_ = false;
440
441 // Particle UI state
442 float particleSpawnDist_ = 200.f;
451};
Skeleton-driven hitbox types: body regions, capsule definitions, damage profiles, and per-entity runt...
Shared definitions for match status and state synchronization between server and clients.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
Wire-format types for the PR-20 lag-comp shot debug visualizer.
Swept AABB and sphere collision queries against world geometry.
Forward-declared to avoid pulling in heavy particle headers.
Definition DebugUI.hpp:44
bool showCollisionShape
Show CollisionShape half-extents row.
Definition DebugUI.hpp:391
bool drawCollisionSpheres
Definition DebugUI.hpp:275
void toggleDebugMenu()
Toggle the unified debug menu on/off.
Definition DebugUI.cpp:142
bool consumePhysicsCsvRecordingRequest(bool &enabled) noexcept
Consume a start/stop request from the physics CSV button.
Definition DebugUI.cpp:147
bool drawContactSphereDepen
Definition DebugUI.hpp:312
void buildMovementChart(const Registry &registry)
Draw the standalone 2-D overhead movement chart window.
Definition DebugUI.cpp:518
void buildWeaponSpawnerUI(const Registry &registry, const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Draw the Weapon Spawner Debug window and (optionally) wireframe overlay for all weapon spawner entiti...
Definition DebugUI.cpp:2196
int bhopHistoryFill_
Samples collected so far (up to k_bhopHistorySize).
Definition DebugUI.hpp:437
bool drawHitboxOverlay
Draw 3-D capsule wireframes (independent of window visibility).
Definition DebugUI.hpp:143
bool drawContactBoxSweep
Definition DebugUI.hpp:303
bool drawContactTriMeshDepen
Definition DebugUI.hpp:313
void processEvent(const SDL_Event *event)
Forward an SDL event to the ImGui input backend.
Definition DebugUI.cpp:130
bool drawCollisionBrushes
Definition DebugUI.hpp:273
bool showContactDebugWindow
Show the Contact Debug ImGui window.
Definition DebugUI.hpp:298
bool drawCollisionBoxes
Definition DebugUI.hpp:272
int shotDebugVisibleCount
Slider value: how many of the most-recent shots to render (1-k_shotRingMax).
Definition DebugUI.hpp:245
bool drawShotDebugOverlay
Definition DebugUI.hpp:241
bool drawContactBrushDepen
Definition DebugUI.hpp:310
void buildShotDebugUI(const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Build the Shot Debug ImGui window + 3D overlay.
Definition DebugUI.cpp:2754
void buildSpawnPointUI(const Registry &registry, const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Draw the Spawn Point Debug window and (optionally) overlay markers for all player respawn point entit...
Definition DebugUI.cpp:2398
bool drawSpawnPointOverlay
Draw spawn point markers (independent of window visibility).
Definition DebugUI.hpp:196
bool drawDroppedWeaponOverlay
Draw dropped weapon wireframes (independent of window visibility).
Definition DebugUI.hpp:184
void buildBhopAnalyzer(const Registry &registry)
Draw the bhop analyzer window.
Definition DebugUI.cpp:700
bool drawContactTriMeshSweep
Definition DebugUI.hpp:307
int shotRingHead
Next-write slot.
Definition DebugUI.hpp:236
void buildDroppedWeaponUI(const Registry &registry, const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Draw the Dropped Weapon Debug window and (optionally) wireframe overlay for all dropped weapon entiti...
Definition DebugUI.cpp:2318
bool pendingAmmoRefill_
Set by Weapon HUD button, consumed by Game::iterate().
Definition DebugUI.hpp:363
void buildUI(const Registry &registry, int tickCount, float &mouseSensitivity, float &gamepadLookSensitivity, systems::GamepadAimAssistConfig &aimAssistCfg, bool &renderSeparateFromPhysics, bool &inputSyncedWithPhysics, bool &limitFPSToMonitor, float physicsHz, float fpsCurrent, float fpsMin, float fpsMax, float fps1pLow, float fps5pLow)
Build the ECS inspector window contents.
Definition DebugUI.cpp:218
bool showWeaponHud
Show the Weapon HUD debug window (disabled by default).
Definition DebugUI.hpp:373
bool showInputSnapshot
Show InputSnapshot key-state row.
Definition DebugUI.hpp:393
bool drawContactSphereSweep
Definition DebugUI.hpp:306
int shotDebugSelectIdx
1-based index into the ring (1 = newest) to highlight.
Definition DebugUI.hpp:248
bool showSpawnPointWindow
Show the Spawn Point Debug ImGui window.
Definition DebugUI.hpp:195
void buildDebugMenu(std::initializer_list< ExternalPanel > externalPanels)
Definition DebugUI.cpp:156
bool showWeaponSpawnerWindow
Show the Weapon Spawner Debug ImGui window.
Definition DebugUI.hpp:170
float energyTeslaGuideDist_
Definition DebugUI.hpp:445
void newFrame()
Begin a new ImGui frame. Call before any ImGui draw calls.
Definition DebugUI.cpp:135
float energyTeslaEndpointRight_
Definition DebugUI.hpp:447
bool drawCollisionTriMeshes
Definition DebugUI.hpp:276
static constexpr int k_shotRingMax
Definition DebugUI.hpp:234
void buildInspectorContents(const Registry &registry, int tickCount, float &mouseSensitivity, float &gamepadLookSensitivity, systems::GamepadAimAssistConfig &aimAssistCfg, bool &renderSeparateFromPhysics, bool &inputSyncedWithPhysics, bool &limitFPSToMonitor, float physicsHz, float fpsCurrent, float fpsMin, float fpsMax, float fps1pLow, float fps5pLow)
Draw the body of the ECS Inspector window (everything after ImGui::Begin).
Definition DebugUI.cpp:273
bool drawContactOverlay
Draw contact-point + normal overlay in 3D.
Definition DebugUI.hpp:299
void buildNetworkUI(const NetworkStats &stats)
Build the Network Stats window showing ping, bandwidth, and update rate.
Definition DebugUI.cpp:1063
int getSimulatedLossPercent() const noexcept
The current packet-loss setting (0–50 %).
Definition DebugUI.hpp:122
bool bhopHasPrevSample_
Definition DebugUI.hpp:439
bool drawKillzoneOverlay
Draw killzone trigger boxes (independent of window visibility).
Definition DebugUI.hpp:207
bool showDroppedWeaponWindow
Show the Dropped Weapon Debug ImGui window.
Definition DebugUI.hpp:183
bool showNetworkSim
Show the Network Simulator (latency + loss) window.
Definition DebugUI.hpp:372
bool showPosition
Per-component visibility toggles — persistent across frames.
Definition DebugUI.hpp:388
bool drawContactCylinderSweep
Definition DebugUI.hpp:305
int shotRingCount
Live entries; saturates at k_shotRingMax.
Definition DebugUI.hpp:237
bool showVelocity
Show Velocity component row.
Definition DebugUI.hpp:390
bool pendingPhysicsCsvRecordingRequest_
Definition DebugUI.hpp:375
bool drawContactBoxDepen
Definition DebugUI.hpp:309
bool showParticleWindow_
Definition DebugUI.hpp:450
int simulatedLatencyMs_
Phase 6 testing: simulated round-trip latency in ms.
Definition DebugUI.hpp:381
bool showViewAngles
Show yaw/pitch/roll in degrees (easier to read than radians).
Definition DebugUI.hpp:394
float bhopGainHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:433
bool drawContactCylinderDepen
Definition DebugUI.hpp:311
void shutdown()
Destroy the ImGui context and shut down the SDL3 input backend.
Definition DebugUI.cpp:125
void buildNetworkSimUI()
Build the Network Simulator window with sliders to add fake round-trip latency and packet loss.
Definition DebugUI.cpp:1105
int simulatedLossPct_
Phase 6 testing: simulated UDP packet loss in percent.
Definition DebugUI.hpp:385
bool init(SDL_Window *window)
Create the ImGui context and initialise the SDL3 input backend.
Definition DebugUI.cpp:118
bool showKillzoneWindow
Show the Killzone Debug ImGui window.
Definition DebugUI.hpp:206
void buildWeaponUI(const Registry &registry)
Definition DebugUI.cpp:1200
int bhopHistoryIdx_
Next write slot in the ring buffers.
Definition DebugUI.hpp:436
bool showMovementChart
Show the 2-D overhead movement chart window.
Definition DebugUI.hpp:395
int getSimulatedLatencyMs() const noexcept
The current latency-simulator setting in milliseconds (0–200).
Definition DebugUI.hpp:118
void buildCollisionUI(const physics::WorldGeometry &world, const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Draw the Collision Debug window and (optionally) wireframe overlay for all world collision primitives...
Definition DebugUI.cpp:1775
float energyTeslaPreviewLockStrength_
Definition DebugUI.hpp:449
bool showHitboxWindow
Show the Hitbox Debug ImGui window.
Definition DebugUI.hpp:142
bool showShotDebugWindow
Show the Shot Debug panel + 3D overlay (CSGO sv_showimpacts).
Definition DebugUI.hpp:240
bool showCollisionWindow
Show the Collision Debug ImGui window.
Definition DebugUI.hpp:157
float bhopPrevHSpeed_
Previous frame's horizontal speed (for gain calc).
Definition DebugUI.hpp:438
bool showNetworkStats
Show the Network Stats window.
Definition DebugUI.hpp:371
bool showBhopAnalyzer
Show the bhop analyzer (player-relative + gain/sync).
Definition DebugUI.hpp:396
bool showDebugMenu
Master toggle for the unified debug menu window.
Definition DebugUI.hpp:355
void render()
Finalise the ImGui frame. Call after all ImGui draw calls, before Renderer::drawFrame().
Definition DebugUI.cpp:2893
float contactPointRadius
Radius (px) of the contact-point circle in screen space.
Definition DebugUI.hpp:321
void buildHitboxUI(const Registry &registry, HitboxRig &hitboxRig, const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Draw the Hitbox Debug window and (optionally) capsule wireframe overlay.
Definition DebugUI.cpp:1455
bool bhopGainingHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:435
float energyTeslaEndpointForward_
Definition DebugUI.hpp:446
void buildContactDebugUI(const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Draw the Contact Debug window + (optionally) per-contact overlay.
Definition DebugUI.cpp:2045
std::array< ShotDebugPair, k_shotRingMax > shotRing
Definition DebugUI.hpp:235
bool drawMeshEdgeOverlay
Draw the per-trimesh welded-edge overlay: each triangle edge is coloured green when active (real boun...
Definition DebugUI.hpp:327
void buildKillzoneUI(const Registry &registry, const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Draw the Killzone Debug window and (optionally) trigger-volume overlay.
Definition DebugUI.cpp:2506
float contactNormalLength
World units of arrow length for unit-normal contacts.
Definition DebugUI.hpp:318
float energyTeslaEndpointUp_
Definition DebugUI.hpp:448
bool drawCollisionCylinders
Definition DebugUI.hpp:274
bool drawMeshVertexOverlay
Optional vertex markers on welded-edge overlay (active = green dot).
Definition DebugUI.hpp:330
void pushServerShot(const net::shotdebug::ShotDebugCapture &cap)
Append a server-reported rewind snapshot.
Definition DebugUI.cpp:2739
bool drawContactBrushSweep
Definition DebugUI.hpp:304
static constexpr int k_bhopHistorySize
Definition DebugUI.hpp:431
int shotDebugViewMode
Which side(s) to render in the 3D overlay.
Definition DebugUI.hpp:254
bool energyTeslaPreviewLive_
Definition DebugUI.hpp:443
bool drawContactPlaneDepen
Definition DebugUI.hpp:308
bool pendingAbilityLevelGrant_
Set by Weapon HUD button, consumed by Game::iterate().
Definition DebugUI.hpp:364
bool energyTeslaPreviewLocked_
Definition DebugUI.hpp:444
bool drawContactPlaneSweep
Definition DebugUI.hpp:302
float particleSpawnDist_
Units ahead of camera to spawn effects.
Definition DebugUI.hpp:442
bool showInspector
Per-window visibility toggles — persistent across frames.
Definition DebugUI.hpp:370
std::int8_t pendingSetSecondaryWeapon_
Mirror for the secondary slot.
Definition DebugUI.hpp:366
float bhopSpeedHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:432
bool bhopAirborneHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:434
bool showPrevPosition
Show PreviousPosition component row.
Definition DebugUI.hpp:389
std::int8_t pendingSetPrimaryWeapon_
-1 = none; else WeaponType ordinal. Consumed by Game::iterate().
Definition DebugUI.hpp:365
bool showPlayerState
Show PlayerState flags row.
Definition DebugUI.hpp:392
void buildParticleUI(ParticleSystem &ps, glm::vec3 eyePos, glm::vec3 forward)
Build the Particle System debug/control window.
Definition DebugUI.cpp:905
bool drawCollisionOverlay
Draw world collision wireframes (independent of window visibility).
Definition DebugUI.hpp:158
void pushClientShot(const net::shotdebug::ShotDebugCapture &cap)
Append a fire-time snapshot the local client just took.
Definition DebugUI.cpp:2723
bool drawCollisionPlanes
Definition DebugUI.hpp:271
bool drawWeaponSpawnerOverlay
Draw weapon spawner wireframes (independent of window visibility).
Definition DebugUI.hpp:171
bool pendingPhysicsCsvRecordingEnabled_
Definition DebugUI.hpp:376
Top-level particle system orchestrator.
Definition ParticleSystem.hpp:39
Client-only input sampling system — split into two halves so mouse look can run every iterate() (smoo...
Definition DebugUI.hpp:15
Build the unified debug menu window.
Definition DebugUI.hpp:349
const char * name
Display name shown as checkbox label.
Definition DebugUI.hpp:350
bool * visible
Pointer to the visibility flag.
Definition DebugUI.hpp:351
Definition DebugUI.hpp:227
net::shotdebug::ShotDebugCapture clientView
Definition DebugUI.hpp:231
std::uint32_t shotInputTick
Definition DebugUI.hpp:228
bool hasServer
Definition DebugUI.hpp:230
net::shotdebug::ShotDebugCapture serverView
Definition DebugUI.hpp:232
bool hasClient
Definition DebugUI.hpp:229
Hitbox rig (shared per character archetype).
Definition Hitbox.hpp:159
Live network statistics updated each frame.
Definition Client.hpp:45
Server-side runtime capture of one shot's debug data, produced by WeaponSystem::handleFire and consum...
Definition ShotDebugReport.hpp:111
All world collision geometry for one tick.
Definition SweptCollision.hpp:225
Tunable parameters for gamepad aim assist.
Definition GamepadAimAssistSystem.hpp:71