diff options
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, |
