From 5189a3c2992719b2c2704f622530605323a82427 Mon Sep 17 00:00:00 2001 From: Yuwei Zhao Date: Mon, 3 Aug 2026 22:22:09 +0800 Subject: [PATCH] Render zero-radius round cuboids as cuboids in debug output --- .../debug_render_pipeline.rs | 65 +++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs b/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs index 9a6eb6568..d4b49dde2 100644 --- a/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs +++ b/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs @@ -456,8 +456,12 @@ impl DebugRenderPipeline { * Round shapes. */ TypedShape::RoundCuboid(s) => { - let vtx = s.to_polyline(self.style.border_subdivisions); - backend.draw_line_strip(object, &vtx, pos, Vector::splat(1.0), color, true) + if s.border_radius == 0.0 { + self.render_shape(object, backend, &s.inner_shape, pos, color) + } else { + let vtx = s.to_polyline(self.style.border_subdivisions); + backend.draw_line_strip(object, &vtx, pos, Vector::splat(1.0), color, true) + } } TypedShape::RoundTriangle(s) => { // TODO: take roundness into account. @@ -590,8 +594,12 @@ impl DebugRenderPipeline { * Round shapes. */ TypedShape::RoundCuboid(s) => { - let (vtx, idx) = s.to_outline(self.style.border_subdivisions); - backend.draw_polyline(object, &vtx, &idx, pos, Vector::splat(1.0), color) + if s.border_radius == 0.0 { + self.render_shape(object, backend, &s.inner_shape, pos, color) + } else { + let (vtx, idx) = s.to_outline(self.style.border_subdivisions); + backend.draw_polyline(object, &vtx, &idx, pos, Vector::splat(1.0), color) + } } TypedShape::RoundTriangle(s) => { // TODO: take roundness into account. @@ -623,3 +631,52 @@ impl DebugRenderPipeline { } } } + +#[cfg(all(test, feature = "dim3"))] +mod tests { + use super::*; + use crate::geometry::ColliderBuilder; + + #[derive(Default)] + struct LineCountingBackend { + lines: usize, + } + + impl DebugRenderBackend for LineCountingBackend { + fn draw_line( + &mut self, + _object: DebugRenderObject, + _a: Vector, + _b: Vector, + _color: DebugColor, + ) { + self.lines += 1; + } + } + + #[test] + fn debug_render_round_cuboid_with_zero_radius() { + let bodies = RigidBodySet::new(); + let mut colliders = ColliderSet::new(); + colliders.insert(ColliderBuilder::round_cuboid(1.0, 1.0, 1.0, 0.0).build()); + let impulse_joints = ImpulseJointSet::new(); + let multibody_joints = MultibodyJointSet::new(); + let narrow_phase = NarrowPhase::new(); + + let mut pipeline = DebugRenderPipeline::new( + DebugRenderStyle::default(), + DebugRenderMode::COLLIDER_SHAPES, + ); + let mut backend = LineCountingBackend::default(); + pipeline.render( + &mut backend, + &bodies, + &colliders, + &impulse_joints, + &multibody_joints, + &narrow_phase, + ); + + assert!(backend.lines > 0); + } +}