From 59c563630ed15fa60b393a9d11c25f4d35668f5a Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 07:07:24 +0100 Subject: feat(3d): Implement Visual Debug primitives (Sphere, Cone, Cross, Trajectory) --- doc/VISUAL_DEBUG.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 doc/VISUAL_DEBUG.md (limited to 'doc/VISUAL_DEBUG.md') diff --git a/doc/VISUAL_DEBUG.md b/doc/VISUAL_DEBUG.md new file mode 100644 index 0000000..f0adcba --- /dev/null +++ b/doc/VISUAL_DEBUG.md @@ -0,0 +1,48 @@ +# Visual Debugging System + +The `VisualDebug` class provides immediate-mode style 3D wireframe rendering for debugging purposes. It is stripped from the final binary when `STRIP_ALL` is defined. + +## Features + +- **Wireframe Primitives**: Boxes, AABBs, Spheres, Cones, Crosses, Lines. +- **Trajectories**: Visualize paths with `add_trajectory`. +- **Mesh Normals**: Visualize vertex normals. +- **Zero Overhead**: Code is compiled out in release builds. + +## Usage + +Access the instance via `Renderer3D::GetVisualDebug()` (only available if `!STRIP_ALL`). + +```cpp +#if !defined(STRIP_ALL) + VisualDebug& dbg = renderer.GetVisualDebug(); + + // Draw a red box at origin + dbg.add_box(mat4::identity(), vec3(1,1,1), vec3(1,0,0)); + + // Draw a trajectory + std::vector path = { ... }; + dbg.add_trajectory(path, vec3(0,1,0)); + + // Draw a light cone + dbg.add_cone(light_pos, light_dir, range, radius, vec3(1,1,0)); +#endif +``` + +## Primitives + +- `add_line(start, end, color)`: Basic line segment. +- `add_cross(center, size, color)`: 3D cross (useful for points). +- `add_sphere(center, radius, color)`: Wireframe sphere (3 axis circles). +- `add_cone(apex, dir, height, radius, color)`: Wireframe cone (useful for spotlights). +- `add_box(transform, half_extent, color)`: OBB. +- `add_aabb(min, max, color)`: Axis-aligned box. +- `add_trajectory(points, color)`: Polyline. + +## Integration + +The `VisualDebug::render` method is called automatically by `Renderer3D::draw` if `s_debug_enabled_` is true. +To enable globally: +```cpp +Renderer3D::SetDebugEnabled(true); +``` -- cgit v1.2.3