diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-05 16:40:27 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-05 16:40:27 +0100 |
| commit | f6f3c13fcd287774a458730722854baab8a17366 (patch) | |
| tree | 44420eecdd2e2dd84d68be12cb12641064eb1c5a /src/3d/visual_debug.cc | |
| parent | 93a65b43094641b4c188b4fc260b8ed44c883728 (diff) | |
feat(physics): Implement SDF-based physics engine and BVH
Completed Task #49.
- Implemented CPU-side SDF library (sphere, box, torus, plane).
- Implemented Dynamic BVH construction (rebuilt every frame).
- Implemented PhysicsSystem with semi-implicit Euler integration and collision resolution.
- Added visual debugging for BVH nodes.
- Created test_3d_physics interactive test and test_physics unit tests.
- Updated project docs and triaged new tasks.
Diffstat (limited to 'src/3d/visual_debug.cc')
| -rw-r--r-- | src/3d/visual_debug.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/3d/visual_debug.cc b/src/3d/visual_debug.cc index f8d9bed..ab4cb6c 100644 --- a/src/3d/visual_debug.cc +++ b/src/3d/visual_debug.cc @@ -182,6 +182,25 @@ void VisualDebug::add_box(const mat4& transform, const vec3& local_extent, } } +void VisualDebug::add_aabb(const vec3& min, const vec3& max, const vec3& color) { + vec3 p[] = {{min.x, min.y, min.z}, {max.x, min.y, min.z}, {max.x, max.y, min.z}, + {min.x, max.y, min.z}, {min.x, min.y, max.z}, {max.x, min.y, max.z}, + {max.x, max.y, max.z}, {min.x, max.y, max.z}}; + + DebugLine edges[] = { + {p[0], p[1], color}, {p[1], p[2], color}, {p[2], p[3], color}, + {p[3], p[0], color}, // Front + {p[4], p[5], color}, {p[5], p[6], color}, {p[6], p[7], color}, + {p[7], p[4], color}, // Back + {p[0], p[4], color}, {p[1], p[5], color}, {p[2], p[6], color}, + {p[3], p[7], color} // Connections + }; + + for (const auto& l : edges) { + lines_.push_back(l); + } +} + void VisualDebug::update_buffers(const mat4& view_proj) { // Update Uniforms wgpuQueueWriteBuffer(wgpuDeviceGetQueue(device_), uniform_buffer_, 0, |
