|
group2 0.1.0
CSE 125 Group 2
|
Forward-declared to avoid pulling in heavy particle headers. More...
#include <DebugUI.hpp>
Classes | |
| struct | ShotDebugPair |
| struct | ExternalPanel |
| Build the unified debug menu window. More... | |
Public Member Functions | |
| bool | init (SDL_Window *window) |
| Create the ImGui context and initialise the SDL3 input backend. | |
| void | shutdown () |
| Destroy the ImGui context and shut down the SDL3 input backend. | |
| void | processEvent (const SDL_Event *event) |
| Forward an SDL event to the ImGui input backend. | |
| void | newFrame () |
| Begin a new ImGui frame. Call before any ImGui draw calls. | |
| void | buildUI (const Registry ®istry, 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. | |
| void | buildParticleUI (ParticleSystem &ps, glm::vec3 eyePos, glm::vec3 forward) |
| Build the Particle System debug/control window. | |
| void | buildRenderTogglesUI (class Renderer &renderer) |
| Build the Render Toggles window for live performance profiling. | |
| void | buildSkyboxUI (class Renderer &renderer) |
| Build the Skybox selector window for live HDR skybox swapping. | |
| void | buildLightingUI (class Renderer &renderer) |
| Build the Lighting Controls window for live parameter tuning. | |
| void | buildNetworkUI (const NetworkStats &stats) |
| Build the Network Stats window showing ping, bandwidth, and update rate. | |
| void | buildNetworkSimUI () |
| Build the Network Simulator window with sliders to add fake round-trip latency and packet loss. | |
| int | getSimulatedLatencyMs () const noexcept |
| The current latency-simulator setting in milliseconds (0–200). | |
| int | getSimulatedLossPercent () const noexcept |
| The current packet-loss setting (0–50 %). | |
| void | buildWeaponUI (const Registry ®istry) |
| void | buildHitboxUI (const Registry ®istry, HitboxRig &hitboxRig, const glm::mat4 &viewProj, float screenWidth, float screenHeight) |
| Draw the Hitbox Debug window and (optionally) capsule wireframe overlay. | |
| 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. | |
| void | buildWeaponSpawnerUI (const Registry ®istry, const glm::mat4 &viewProj, float screenWidth, float screenHeight) |
| Draw the Weapon Spawner Debug window and (optionally) wireframe overlay for all weapon spawner entities, showing their bounding boxes and spawn positions. | |
| void | buildSpawnPointUI (const Registry ®istry, const glm::mat4 &viewProj, float screenWidth, float screenHeight) |
| Draw the Spawn Point Debug window and (optionally) overlay markers for all player respawn point entities, showing position and cooldown state. | |
| void | pushClientShot (const net::shotdebug::ShotDebugCapture &cap) |
| Append a fire-time snapshot the local client just took. | |
| void | pushServerShot (const net::shotdebug::ShotDebugCapture &cap) |
| Append a server-reported rewind snapshot. | |
| void | buildShotDebugUI (const glm::mat4 &viewProj, float screenWidth, float screenHeight) |
| Build the Shot Debug ImGui window + 3D overlay. | |
| void | render () |
| Finalise the ImGui frame. Call after all ImGui draw calls, before Renderer::drawFrame(). | |
| void | toggleDebugMenu () |
| Toggle the unified debug menu on/off. | |
| void | buildDebugMenu (std::initializer_list< ExternalPanel > externalPanels) |
Public Attributes | |
| bool | showHitboxWindow = false |
| Show the Hitbox Debug ImGui window. | |
| bool | drawHitboxOverlay = false |
| Draw 3-D capsule wireframes (independent of window visibility). | |
| bool | showCollisionWindow = false |
| Show the Collision Debug ImGui window. | |
| bool | drawCollisionOverlay = false |
| Draw world collision wireframes (independent of window visibility). | |
| bool | showWeaponSpawnerWindow = false |
| Show the Weapon Spawner Debug ImGui window. | |
| bool | drawWeaponSpawnerOverlay = false |
| Draw weapon spawner wireframes (independent of window visibility). | |
| bool | showSpawnPointWindow = false |
| Show the Spawn Point Debug ImGui window. | |
| bool | drawSpawnPointOverlay = false |
| Draw spawn point markers (independent of window visibility). | |
| std::array< ShotDebugPair, k_shotRingMax > | shotRing {} |
| int | shotRingHead = 0 |
| Next-write slot. | |
| int | shotRingCount = 0 |
| Live entries; saturates at k_shotRingMax. | |
| bool | showShotDebugWindow = false |
| Show the Shot Debug panel + 3D overlay (CSGO sv_showimpacts). | |
| bool | drawShotDebugOverlay = false |
| int | shotDebugVisibleCount = 5 |
| Slider value: how many of the most-recent shots to render (1-k_shotRingMax). | |
| int | shotDebugSelectIdx = 0 |
| 1-based index into the ring (1 = newest) to highlight. | |
| int | shotDebugViewMode = 0 |
| Which side(s) to render in the 3D overlay. | |
| bool | drawCollisionPlanes = true |
| bool | drawCollisionBoxes = true |
| bool | drawCollisionBrushes = true |
| bool | drawCollisionCylinders = true |
| bool | drawCollisionSpheres = true |
| bool | drawCollisionTriMeshes = true |
| bool | showDebugMenu = false |
| Master toggle for the unified debug menu window. | |
| bool | pendingAmmoRefill_ = false |
| Set by Weapon HUD button, consumed by Game::iterate(). | |
Static Public Attributes | |
| static constexpr int | k_shotRingMax = 30 |
Private Member Functions | |
| void | buildInspectorContents (const Registry ®istry, 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). | |
| void | buildMovementChart (const Registry ®istry) |
| Draw the standalone 2-D overhead movement chart window. | |
| void | buildBhopAnalyzer (const Registry ®istry) |
| Draw the bhop analyzer window. | |
Private Attributes | |
| bool | showInspector = false |
| Per-window visibility toggles — persistent across frames. | |
| bool | showRenderToggles = false |
| Show the Render Toggles window. | |
| bool | showLightingControls = false |
| Show the Lighting Controls window. | |
| bool | showSkybox = false |
| Show the Skybox window. | |
| bool | showNetworkStats = false |
| Show the Network Stats window. | |
| bool | showNetworkSim = false |
| Show the Network Simulator (latency + loss) window. | |
| bool | showWeaponHud = false |
| Show the Weapon HUD debug window (disabled by default). | |
| int | simulatedLatencyMs_ = 0 |
| Phase 6 testing: simulated round-trip latency in ms. | |
| int | simulatedLossPct_ = 0 |
| Phase 6 testing: simulated UDP packet loss in percent. | |
| bool | showPosition = true |
| Per-component visibility toggles — persistent across frames. | |
| bool | showPrevPosition = false |
| Show PreviousPosition component row. | |
| bool | showVelocity = true |
| Show Velocity component row. | |
| bool | showCollisionShape = true |
| Show CollisionShape half-extents row. | |
| bool | showPlayerState = true |
| Show PlayerState flags row. | |
| bool | showInputSnapshot = true |
| Show InputSnapshot key-state row. | |
| bool | showViewAngles = true |
| Show yaw/pitch/roll in degrees (easier to read than radians). | |
| bool | showMovementChart = false |
| Show the 2-D overhead movement chart window. | |
| bool | showBhopAnalyzer = false |
| Show the bhop analyzer (player-relative + gain/sync). | |
| float | bhopSpeedHistory_ [k_bhopHistorySize] = {} |
| float | bhopGainHistory_ [k_bhopHistorySize] = {} |
| bool | bhopAirborneHistory_ [k_bhopHistorySize] = {} |
| bool | bhopGainingHistory_ [k_bhopHistorySize] = {} |
| int | bhopHistoryIdx_ = 0 |
| Next write slot in the ring buffers. | |
| int | bhopHistoryFill_ = 0 |
| Samples collected so far (up to k_bhopHistorySize). | |
| float | bhopPrevHSpeed_ = 0.0f |
| Previous frame's horizontal speed (for gain calc). | |
| bool | bhopHasPrevSample_ = false |
| float | particleSpawnDist_ = 200.f |
| Units ahead of camera to spawn effects. | |
| bool | showParticleWindow_ = false |
Static Private Attributes | |
| static constexpr int | k_bhopHistorySize = 256 |
Forward-declared to avoid pulling in heavy particle headers.
Live ECS inspector overlay powered by Dear ImGui.
Ownership split:
Initialisation order in Game::init():
Shutdown order in Game::quit():
|
private |
Draw the bhop analyzer window.
Shows velocity/wish vectors rotated into player-local space (player forward always points screen-up), plus numeric breakdowns, gain-per-frame, sync %, and history plots for horizontal speed and gain.
| void DebugUI::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.
| world | The world geometry to visualise. |
| viewProj | Combined view-projection matrix for the current camera. |
| screenWidth | Viewport width in pixels. |
| screenHeight | Viewport height in pixels. |
| void DebugUI::buildDebugMenu | ( | std::initializer_list< ExternalPanel > | externalPanels | ) |
| void DebugUI::buildHitboxUI | ( | const Registry & | registry, |
| HitboxRig & | hitboxRig, | ||
| const glm::mat4 & | viewProj, | ||
| float | screenWidth, | ||
| float | screenHeight ) |
Draw the Hitbox Debug window and (optionally) capsule wireframe overlay.
The window is always rendered when showHitboxWindow is true. The 3-D capsule overlay is drawn only when the "Draw Hitboxes" checkbox inside the window is checked.
| registry | ECS registry (reads HitboxInstance, Position, Player). |
| viewProj | Combined view-projection matrix for the current camera. |
| screenWidth | Viewport width in pixels. |
| screenHeight | Viewport height in pixels. |
|
private |
Draw the body of the ECS Inspector window (everything after ImGui::Begin).
Factored out of buildUI so the Begin/End wrapping (and early-out when the window is hidden) lives in one place in buildUI, while the content logic lives here. Parameter list mirrors buildUI.
| void DebugUI::buildLightingUI | ( | class Renderer & | renderer | ) |
Build the Lighting Controls window for live parameter tuning.
|
private |
Draw the standalone 2-D overhead movement chart window.
Shows the local player dot on a 3 000 × 3 000 unit grid together with view-direction, velocity, and wish-velocity arrows.
| void DebugUI::buildNetworkSimUI | ( | ) |
Build the Network Simulator window with sliders to add fake round-trip latency and packet loss.
Useful for testing Phase 6 lag compensation and Phase 5b reconciliation under non-LAN conditions without setting up tc qdisc.
Latency slider value (0–200 ms) is written into simulatedLatencyMs_ and read by Game::iterate which forwards it to Client::setSimulatedLatencyMs. Half the value is added to outbound packets and half to inbound, modelling a symmetric network with the slider's RTT.
Packet-loss slider value (0–50 %) is written into simulatedLossPct_, forwarded to Client::setSimulatedLossPercent, and applied as an independent Bernoulli drop in each direction.
| void DebugUI::buildNetworkUI | ( | const NetworkStats & | stats | ) |
Build the Network Stats window showing ping, bandwidth, and update rate.
| void DebugUI::buildParticleUI | ( | ParticleSystem & | ps, |
| glm::vec3 | eyePos, | ||
| glm::vec3 | forward ) |
| void DebugUI::buildRenderTogglesUI | ( | class Renderer & | renderer | ) |
Build the Render Toggles window for live performance profiling.
| renderer | The renderer (for toggles, AA mode). |
| void DebugUI::buildShotDebugUI | ( | const glm::mat4 & | viewProj, |
| float | screenWidth, | ||
| float | screenHeight ) |
Build the Shot Debug ImGui window + 3D overlay.
| viewProj | Camera VP for the world→screen projection. |
| screenWidth | Viewport width in pixels. |
| screenHeight | Viewport height in pixels. |
| void DebugUI::buildSkyboxUI | ( | class Renderer & | renderer | ) |
Build the Skybox selector window for live HDR skybox swapping.
| void DebugUI::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 entities, showing position and cooldown state.
| registry | ECS registry (reads RespawnPoint, Position). |
| viewProj | Combined view-projection matrix for the current camera. |
| screenWidth | Viewport width in pixels. |
| screenHeight | Viewport height in pixels. |
| void DebugUI::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.
| registry | The ECS registry to inspect. |
| tickCount | Total physics ticks elapsed. |
| mouseSensitivity | Radians per pixel; slider (read/write). |
| gamepadLookSensitivity | Radians per second at full right-stick deflection; slider (read/write). |
| aimAssistCfg | Gamepad aim-assist config; sliders + toggle (read/write). |
| renderSeparateFromPhysics | Interpolated unlimited-fps mode toggle (read/write). |
| inputSyncedWithPhysics | Sample input once per tick vs every frame (read/write). |
| limitFPSToMonitor | VSync on/off toggle (read/write). |
| physicsHz | Measured physics tick rate (Hz). |
| fpsCurrent | Most-recent render FPS sample. |
| fpsMin | Minimum FPS in the rolling window. |
| fpsMax | Maximum FPS in the rolling window. |
| fps1pLow | 1st-percentile FPS (1 % low). |
| fps5pLow | 5th-percentile FPS (5 % low). |
| void DebugUI::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 entities, showing their bounding boxes and spawn positions.
| registry | ECS registry (reads WeaponSpawner, Position, CollisionShape). |
| viewProj | Combined view-projection matrix for the current camera. |
| screenWidth | Viewport width in pixels. |
| screenHeight | Viewport height in pixels. |
| void DebugUI::buildWeaponUI | ( | const Registry & | registry | ) |
|
inlinenodiscardnoexcept |
The current latency-simulator setting in milliseconds (0–200).
Read by Game::iterate each frame to push to Client::setSimulatedLatencyMs.
|
inlinenodiscardnoexcept |
The current packet-loss setting (0–50 %).
Read by Game::iterate each frame to push to Client::setSimulatedLossPercent.
| bool DebugUI::init | ( | SDL_Window * | window | ) |
Create the ImGui context and initialise the SDL3 input backend.
| window | The SDL window receiving input events. |
| void DebugUI::newFrame | ( | ) |
Begin a new ImGui frame. Call before any ImGui draw calls.
| void DebugUI::processEvent | ( | const SDL_Event * | event | ) |
Forward an SDL event to the ImGui input backend.
| event | The event to process. |
| void DebugUI::pushClientShot | ( | const net::shotdebug::ShotDebugCapture & | cap | ) |
Append a fire-time snapshot the local client just took.
Pairs with any matching server view (by shotInputTick).
| void DebugUI::pushServerShot | ( | const net::shotdebug::ShotDebugCapture & | cap | ) |
Append a server-reported rewind snapshot.
Pairs with any matching client view (by shotInputTick).
| void DebugUI::render | ( | ) |
Finalise the ImGui frame. Call after all ImGui draw calls, before Renderer::drawFrame().
| void DebugUI::shutdown | ( | ) |
Destroy the ImGui context and shut down the SDL3 input backend.
| void DebugUI::toggleDebugMenu | ( | ) |
Toggle the unified debug menu on/off.
When visible, the debug menu shows one checkbox per debug panel. Individual panels are only drawn when their checkbox is checked.
|
private |
|
private |
|
private |
|
private |
|
private |
Samples collected so far (up to k_bhopHistorySize).
|
private |
Next write slot in the ring buffers.
|
private |
Previous frame's horizontal speed (for gain calc).
|
private |
| bool DebugUI::drawCollisionBoxes = true |
| bool DebugUI::drawCollisionBrushes = true |
| bool DebugUI::drawCollisionCylinders = true |
| bool DebugUI::drawCollisionOverlay = false |
Draw world collision wireframes (independent of window visibility).
| bool DebugUI::drawCollisionPlanes = true |
| bool DebugUI::drawCollisionSpheres = true |
| bool DebugUI::drawCollisionTriMeshes = true |
| bool DebugUI::drawHitboxOverlay = false |
Draw 3-D capsule wireframes (independent of window visibility).
| bool DebugUI::drawShotDebugOverlay = false |
| bool DebugUI::drawSpawnPointOverlay = false |
Draw spawn point markers (independent of window visibility).
| bool DebugUI::drawWeaponSpawnerOverlay = false |
Draw weapon spawner wireframes (independent of window visibility).
|
staticconstexprprivate |
|
staticconstexpr |
|
private |
Units ahead of camera to spawn effects.
| bool DebugUI::pendingAmmoRefill_ = false |
Set by Weapon HUD button, consumed by Game::iterate().
| int DebugUI::shotDebugSelectIdx = 0 |
1-based index into the ring (1 = newest) to highlight.
0 means "show all in the visible window".
| int DebugUI::shotDebugViewMode = 0 |
| int DebugUI::shotDebugVisibleCount = 5 |
Slider value: how many of the most-recent shots to render (1-k_shotRingMax).
All older shots stay in the ring but are hidden from the overlay.
| std::array<ShotDebugPair, k_shotRingMax> DebugUI::shotRing {} |
| int DebugUI::shotRingCount = 0 |
Live entries; saturates at k_shotRingMax.
| int DebugUI::shotRingHead = 0 |
Next-write slot.
|
private |
Show the bhop analyzer (player-relative + gain/sync).
|
private |
Show CollisionShape half-extents row.
| bool DebugUI::showCollisionWindow = false |
Show the Collision Debug ImGui window.
| bool DebugUI::showDebugMenu = false |
Master toggle for the unified debug menu window.
| bool DebugUI::showHitboxWindow = false |
Show the Hitbox Debug ImGui window.
|
private |
Show InputSnapshot key-state row.
|
private |
Per-window visibility toggles — persistent across frames.
Show the main ECS Inspector window.
|
private |
Show the Lighting Controls window.
|
private |
Show the 2-D overhead movement chart window.
|
private |
Show the Network Simulator (latency + loss) window.
|
private |
Show the Network Stats window.
|
private |
|
private |
Show PlayerState flags row.
|
private |
Per-component visibility toggles — persistent across frames.
Show Position component row.
|
private |
Show PreviousPosition component row.
|
private |
Show the Render Toggles window.
| bool DebugUI::showShotDebugWindow = false |
Show the Shot Debug panel + 3D overlay (CSGO sv_showimpacts).
|
private |
Show the Skybox window.
| bool DebugUI::showSpawnPointWindow = false |
Show the Spawn Point Debug ImGui window.
|
private |
Show Velocity component row.
|
private |
Show yaw/pitch/roll in degrees (easier to read than radians).
|
private |
Show the Weapon HUD debug window (disabled by default).
| bool DebugUI::showWeaponSpawnerWindow = false |
Show the Weapon Spawner Debug ImGui window.
|
private |
Phase 6 testing: simulated round-trip latency in ms.
Written by the Network Simulator window's slider, read by Game::iterate to push to Client. Zero = simulator off.
|
private |
Phase 6 testing: simulated UDP packet loss in percent.
Applied independently to each direction. Zero = simulator off.