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 int& ssrMode,
85 float physicsHz,
86 float fpsCurrent,
87 float fpsMin,
88 float fpsMax,
89 float fps1pLow,
90 float fps5pLow);
91
96 void buildParticleUI(ParticleSystem& ps, glm::vec3 eyePos, glm::vec3 forward);
97
100 void buildRenderTogglesUI(class Renderer& renderer);
101
103 void buildSkyboxUI(class Renderer& renderer);
104
106 void buildLightingUI(class Renderer& renderer);
107
109 void buildNetworkUI(const NetworkStats& stats);
110
125 void buildNetworkSimUI();
126
129 [[nodiscard]] int getSimulatedLatencyMs() const noexcept { return simulatedLatencyMs_; }
130
133 [[nodiscard]] int getSimulatedLossPercent() const noexcept { return simulatedLossPct_; }
134
135 void buildWeaponUI(const Registry& registry);
136
147 void buildHitboxUI(const Registry& registry,
148 HitboxRig& hitboxRig,
149 const glm::mat4& viewProj,
150 float screenWidth,
151 float screenHeight);
152
153 bool showHitboxWindow = false;
154 bool drawHitboxOverlay = false;
155
164 const glm::mat4& viewProj,
165 float screenWidth,
166 float screenHeight);
167
168 bool showCollisionWindow = false;
169 bool drawCollisionOverlay = false;
170
178 void
179 buildWeaponSpawnerUI(const Registry& registry, const glm::mat4& viewProj, float screenWidth, float screenHeight);
180
183
191 void buildSpawnPointUI(const Registry& registry, const glm::mat4& viewProj, float screenWidth, float screenHeight);
192
193 bool showSpawnPointWindow = false;
195
196 // ── PR-20: Shot-debug visualizer (CSGO sv_showimpacts-style) ─────
197 //
198 // Holds a ring buffer of paired (client-side fire-time snapshot,
199 // server-side rewound snapshot) entries. ImGui panel lets the
200 // user pick how many recent shots to keep (1-30) and which to
201 // highlight in the 3-D overlay.
202 //
203 // The two snapshots reuse the same `ShotDebugCapture` type:
204 // - clientView is populated by `pushClientShot()` from Game.cpp
205 // when the local player fires a shot (with the visible-on-
206 // screen capsules of remote players at fire time).
207 // - serverView is populated by `pushServerShot()` from the
208 // `Client::onShotDebugReport` callback (with the historical
209 // capsules the server raycast against).
210 //
211 // The two halves are paired by `shotInputTick`; either may
212 // arrive first.
221 static constexpr int k_shotRingMax = 30;
222 std::array<ShotDebugPair, k_shotRingMax> shotRing{};
223 int shotRingHead = 0;
225
236
242
246
250
255 void buildShotDebugUI(const glm::mat4& viewProj, float screenWidth, float screenHeight);
256
257 // Per-type visibility toggles (all default on when overlay is active).
264
266 void render();
267
272 void toggleDebugMenu();
273
282 {
283 const char* name;
284 bool* visible;
285 };
286 void buildDebugMenu(std::initializer_list<ExternalPanel> externalPanels);
287
288 bool showDebugMenu = false;
289
290 bool pendingAmmoRefill_ = false;
291
292private:
294 bool showInspector = false;
295 bool showRenderToggles = false;
296 bool showLightingControls = false;
297 bool showSkybox = false;
298 bool showNetworkStats = false;
299 bool showNetworkSim = false;
300 bool showWeaponHud = false;
301
306
310
312 bool showPosition = true;
313 bool showPrevPosition = false;
314 bool showVelocity = true;
315 bool showCollisionShape = true;
316 bool showPlayerState = true;
317 bool showInputSnapshot = true;
318 bool showViewAngles = true;
319 bool showMovementChart = false;
320 bool showBhopAnalyzer = false;
321
327 void buildInspectorContents(const Registry& registry,
328 int tickCount,
329 float& mouseSensitivity,
330 float& gamepadLookSensitivity,
332 bool& renderSeparateFromPhysics,
333 bool& inputSyncedWithPhysics,
334 bool& limitFPSToMonitor,
335 int& ssrMode,
336 float physicsHz,
337 float fpsCurrent,
338 float fpsMin,
339 float fpsMax,
340 float fps1pLow,
341 float fps5pLow);
342
346 void buildMovementChart(const Registry& registry);
347
353 void buildBhopAnalyzer(const Registry& registry);
354
355 // Bhop analyzer rolling state (ring buffers, persist across frames).
356 static constexpr int k_bhopHistorySize = 256;
363 float bhopPrevHSpeed_ = 0.0f;
364 bool bhopHasPrevSample_ = false;
365
366 // Particle UI state
367 float particleSpawnDist_ = 200.f;
369};
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:315
bool drawCollisionSpheres
Definition DebugUI.hpp:262
void toggleDebugMenu()
Toggle the unified debug menu on/off.
Definition DebugUI.cpp:115
void buildMovementChart(const Registry &registry)
Draw the standalone 2-D overhead movement chart window.
Definition DebugUI.cpp:479
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:1940
int bhopHistoryFill_
Samples collected so far (up to k_bhopHistorySize).
Definition DebugUI.hpp:362
bool drawHitboxOverlay
Draw 3-D capsule wireframes (independent of window visibility).
Definition DebugUI.hpp:154
void processEvent(const SDL_Event *event)
Forward an SDL event to the ImGui input backend.
Definition DebugUI.cpp:103
bool drawCollisionBrushes
Definition DebugUI.hpp:260
bool drawCollisionBoxes
Definition DebugUI.hpp:259
int shotDebugVisibleCount
Slider value: how many of the most-recent shots to render (1-k_shotRingMax).
Definition DebugUI.hpp:232
bool drawShotDebugOverlay
Definition DebugUI.hpp:228
void buildShotDebugUI(const glm::mat4 &viewProj, float screenWidth, float screenHeight)
Build the Shot Debug ImGui window + 3D overlay.
Definition DebugUI.cpp:2362
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:2087
bool drawSpawnPointOverlay
Draw spawn point markers (independent of window visibility).
Definition DebugUI.hpp:194
void buildBhopAnalyzer(const Registry &registry)
Draw the bhop analyzer window.
Definition DebugUI.cpp:661
int shotRingHead
Next-write slot.
Definition DebugUI.hpp:223
bool showLightingControls
Show the Lighting Controls window.
Definition DebugUI.hpp:296
bool pendingAmmoRefill_
Set by Weapon HUD button, consumed by Game::iterate().
Definition DebugUI.hpp:290
bool showWeaponHud
Show the Weapon HUD debug window (disabled by default).
Definition DebugUI.hpp:300
bool showRenderToggles
Show the Render Toggles window.
Definition DebugUI.hpp:295
bool showInputSnapshot
Show InputSnapshot key-state row.
Definition DebugUI.hpp:317
int shotDebugSelectIdx
1-based index into the ring (1 = newest) to highlight.
Definition DebugUI.hpp:235
bool showSpawnPointWindow
Show the Spawn Point Debug ImGui window.
Definition DebugUI.hpp:193
void buildDebugMenu(std::initializer_list< ExternalPanel > externalPanels)
Definition DebugUI.cpp:120
bool showWeaponSpawnerWindow
Show the Weapon Spawner Debug ImGui window.
Definition DebugUI.hpp:181
void newFrame()
Begin a new ImGui frame. Call before any ImGui draw calls.
Definition DebugUI.cpp:108
bool drawCollisionTriMeshes
Definition DebugUI.hpp:263
static constexpr int k_shotRingMax
Definition DebugUI.hpp:221
void buildUI(const Registry &registry, int tickCount, float &mouseSensitivity, float &gamepadLookSensitivity, systems::GamepadAimAssistConfig &aimAssistCfg, bool &renderSeparateFromPhysics, bool &inputSyncedWithPhysics, bool &limitFPSToMonitor, int &ssrMode, float physicsHz, float fpsCurrent, float fpsMin, float fpsMax, float fps1pLow, float fps5pLow)
Build the ECS inspector window contents.
Definition DebugUI.cpp:173
void buildNetworkUI(const NetworkStats &stats)
Build the Network Stats window showing ping, bandwidth, and update rate.
Definition DebugUI.cpp:1162
int getSimulatedLossPercent() const noexcept
The current packet-loss setting (0–50 %).
Definition DebugUI.hpp:133
bool bhopHasPrevSample_
Definition DebugUI.hpp:364
bool showNetworkSim
Show the Network Simulator (latency + loss) window.
Definition DebugUI.hpp:299
bool showPosition
Per-component visibility toggles — persistent across frames.
Definition DebugUI.hpp:312
int shotRingCount
Live entries; saturates at k_shotRingMax.
Definition DebugUI.hpp:224
bool showVelocity
Show Velocity component row.
Definition DebugUI.hpp:314
bool showParticleWindow_
Definition DebugUI.hpp:368
int simulatedLatencyMs_
Phase 6 testing: simulated round-trip latency in ms.
Definition DebugUI.hpp:305
bool showViewAngles
Show yaw/pitch/roll in degrees (easier to read than radians).
Definition DebugUI.hpp:318
float bhopGainHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:358
void shutdown()
Destroy the ImGui context and shut down the SDL3 input backend.
Definition DebugUI.cpp:97
void buildNetworkSimUI()
Build the Network Simulator window with sliders to add fake round-trip latency and packet loss.
Definition DebugUI.cpp:1204
int simulatedLossPct_
Phase 6 testing: simulated UDP packet loss in percent.
Definition DebugUI.hpp:309
bool init(SDL_Window *window)
Create the ImGui context and initialise the SDL3 input backend.
Definition DebugUI.cpp:79
void buildWeaponUI(const Registry &registry)
Definition DebugUI.cpp:1299
void buildInspectorContents(const Registry &registry, int tickCount, float &mouseSensitivity, float &gamepadLookSensitivity, systems::GamepadAimAssistConfig &aimAssistCfg, bool &renderSeparateFromPhysics, bool &inputSyncedWithPhysics, bool &limitFPSToMonitor, int &ssrMode, 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:230
int bhopHistoryIdx_
Next write slot in the ring buffers.
Definition DebugUI.hpp:361
bool showMovementChart
Show the 2-D overhead movement chart window.
Definition DebugUI.hpp:319
int getSimulatedLatencyMs() const noexcept
The current latency-simulator setting in milliseconds (0–200).
Definition DebugUI.hpp:129
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:1835
bool showHitboxWindow
Show the Hitbox Debug ImGui window.
Definition DebugUI.hpp:153
bool showShotDebugWindow
Show the Shot Debug panel + 3D overlay (CSGO sv_showimpacts).
Definition DebugUI.hpp:227
bool showCollisionWindow
Show the Collision Debug ImGui window.
Definition DebugUI.hpp:168
float bhopPrevHSpeed_
Previous frame's horizontal speed (for gain calc).
Definition DebugUI.hpp:363
bool showNetworkStats
Show the Network Stats window.
Definition DebugUI.hpp:298
bool showBhopAnalyzer
Show the bhop analyzer (player-relative + gain/sync).
Definition DebugUI.hpp:320
bool showDebugMenu
Master toggle for the unified debug menu window.
Definition DebugUI.hpp:288
void render()
Finalise the ImGui frame. Call after all ImGui draw calls, before Renderer::drawFrame().
Definition DebugUI.cpp:2501
bool showSkybox
Show the Skybox window.
Definition DebugUI.hpp:297
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:1516
bool bhopGainingHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:360
std::array< ShotDebugPair, k_shotRingMax > shotRing
Definition DebugUI.hpp:222
void buildRenderTogglesUI(class Renderer &renderer)
Build the Render Toggles window for live performance profiling.
Definition DebugUI.cpp:970
bool drawCollisionCylinders
Definition DebugUI.hpp:261
void pushServerShot(const net::shotdebug::ShotDebugCapture &cap)
Append a server-reported rewind snapshot.
Definition DebugUI.cpp:2347
static constexpr int k_bhopHistorySize
Definition DebugUI.hpp:356
int shotDebugViewMode
Which side(s) to render in the 3D overlay.
Definition DebugUI.hpp:241
void buildLightingUI(class Renderer &renderer)
Build the Lighting Controls window for live parameter tuning.
Definition DebugUI.cpp:1061
float particleSpawnDist_
Units ahead of camera to spawn effects.
Definition DebugUI.hpp:367
bool showInspector
Per-window visibility toggles — persistent across frames.
Definition DebugUI.hpp:294
float bhopSpeedHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:357
void buildSkyboxUI(class Renderer &renderer)
Build the Skybox selector window for live HDR skybox swapping.
Definition DebugUI.cpp:1121
bool bhopAirborneHistory_[k_bhopHistorySize]
Definition DebugUI.hpp:359
bool showPrevPosition
Show PreviousPosition component row.
Definition DebugUI.hpp:313
bool showPlayerState
Show PlayerState flags row.
Definition DebugUI.hpp:316
void buildParticleUI(ParticleSystem &ps, glm::vec3 eyePos, glm::vec3 forward)
Build the Particle System debug/control window.
Definition DebugUI.cpp:866
bool drawCollisionOverlay
Draw world collision wireframes (independent of window visibility).
Definition DebugUI.hpp:169
void pushClientShot(const net::shotdebug::ShotDebugCapture &cap)
Append a fire-time snapshot the local client just took.
Definition DebugUI.cpp:2331
bool drawCollisionPlanes
Definition DebugUI.hpp:258
bool drawWeaponSpawnerOverlay
Draw weapon spawner wireframes (independent of window visibility).
Definition DebugUI.hpp:182
Top-level particle system orchestrator.
Definition ParticleSystem.hpp:35
Forward-declared to avoid circular includes.
Definition Renderer.hpp:35
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:282
const char * name
Display name shown as checkbox label.
Definition DebugUI.hpp:283
bool * visible
Pointer to the visibility flag.
Definition DebugUI.hpp:284
Definition DebugUI.hpp:214
net::shotdebug::ShotDebugCapture clientView
Definition DebugUI.hpp:218
std::uint32_t shotInputTick
Definition DebugUI.hpp:215
bool hasServer
Definition DebugUI.hpp:217
net::shotdebug::ShotDebugCapture serverView
Definition DebugUI.hpp:219
bool hasClient
Definition DebugUI.hpp:216
Hitbox rig (shared per character archetype).
Definition Hitbox.hpp:159
Live network statistics updated each frame.
Definition Client.hpp:34
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:100
Tunable parameters for gamepad aim assist.
Definition GamepadAimAssistSystem.hpp:71