From bc2ae4b512b8bc7a2b61dd24d9685289453681c5 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Fri, 22 Apr 2022 15:45:53 +0200 Subject: Add a basic lines-based debug-renderer --- .../debug_render_pipeline/debug_render_style.rs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/pipeline/debug_render_pipeline/debug_render_style.rs (limited to 'src/pipeline/debug_render_pipeline/debug_render_style.rs') diff --git a/src/pipeline/debug_render_pipeline/debug_render_style.rs b/src/pipeline/debug_render_pipeline/debug_render_style.rs new file mode 100644 index 0000000..9d4b6cc --- /dev/null +++ b/src/pipeline/debug_render_pipeline/debug_render_style.rs @@ -0,0 +1,37 @@ +/// A color for debug-rendering. +/// +/// The default colors are provided in HSLA (Hue Saturation Lightness Alpha) format. +pub type DebugColor = [f32; 4]; + +#[derive(Clone, Debug, PartialEq)] +pub struct DebugRenderStyle { + pub subdivisions: u32, + pub collider_dynamic_color: DebugColor, + pub collider_fixed_color: DebugColor, + pub collider_kinematic_color: DebugColor, + pub collider_parentless_color: DebugColor, + pub impulse_joint_anchor_color: DebugColor, + pub impulse_joint_separation_color: DebugColor, + pub multibody_joint_anchor_color: DebugColor, + pub multibody_joint_separation_color: DebugColor, + pub sleep_color_multiplier: [f32; 4], + pub rigid_body_axes_length: f32, +} + +impl Default for DebugRenderStyle { + fn default() -> Self { + Self { + subdivisions: 20, + collider_dynamic_color: [340.0, 1.0, 0.3, 1.0], + collider_kinematic_color: [20.0, 1.0, 0.3, 1.0], + collider_fixed_color: [30.0, 1.0, 0.4, 1.0], + collider_parentless_color: [30.0, 1.0, 0.4, 1.0], + impulse_joint_anchor_color: [240.0, 0.5, 0.4, 1.0], + impulse_joint_separation_color: [0.0, 0.5, 0.4, 1.0], + multibody_joint_anchor_color: [300.0, 1.0, 0.4, 1.0], + multibody_joint_separation_color: [0.0, 1.0, 0.4, 1.0], + sleep_color_multiplier: [1.0, 1.0, 0.2, 1.0], + rigid_body_axes_length: 0.5, + } + } +} -- cgit From 8ffb0d1658d448074f5ca2b77aee33f755761e24 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Thu, 28 Apr 2022 13:05:00 +0200 Subject: Take round shapes into account in 2D debug render --- src/pipeline/debug_render_pipeline/debug_render_style.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/pipeline/debug_render_pipeline/debug_render_style.rs') diff --git a/src/pipeline/debug_render_pipeline/debug_render_style.rs b/src/pipeline/debug_render_pipeline/debug_render_style.rs index 9d4b6cc..5401596 100644 --- a/src/pipeline/debug_render_pipeline/debug_render_style.rs +++ b/src/pipeline/debug_render_pipeline/debug_render_style.rs @@ -3,9 +3,10 @@ /// The default colors are provided in HSLA (Hue Saturation Lightness Alpha) format. pub type DebugColor = [f32; 4]; -#[derive(Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] pub struct DebugRenderStyle { pub subdivisions: u32, + pub border_subdivisions: u32, pub collider_dynamic_color: DebugColor, pub collider_fixed_color: DebugColor, pub collider_kinematic_color: DebugColor, @@ -22,6 +23,7 @@ impl Default for DebugRenderStyle { fn default() -> Self { Self { subdivisions: 20, + border_subdivisions: 5, collider_dynamic_color: [340.0, 1.0, 0.3, 1.0], collider_kinematic_color: [20.0, 1.0, 0.3, 1.0], collider_fixed_color: [30.0, 1.0, 0.4, 1.0], -- cgit From 65824e74f3a949343059b3bf5ab51bc7920f416d Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Thu, 28 Apr 2022 17:30:35 +0200 Subject: Add comments for the debug-renderer --- .../debug_render_pipeline/debug_render_style.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/pipeline/debug_render_pipeline/debug_render_style.rs') diff --git a/src/pipeline/debug_render_pipeline/debug_render_style.rs b/src/pipeline/debug_render_pipeline/debug_render_style.rs index 5401596..0b6fa46 100644 --- a/src/pipeline/debug_render_pipeline/debug_render_style.rs +++ b/src/pipeline/debug_render_pipeline/debug_render_style.rs @@ -3,19 +3,38 @@ /// The default colors are provided in HSLA (Hue Saturation Lightness Alpha) format. pub type DebugColor = [f32; 4]; +/// Style used for computing colors when rendering the scene. #[derive(Copy, Clone, Debug, PartialEq)] pub struct DebugRenderStyle { + /// The number of subdivision used to approximate the curved + /// parts of a shape with smooth faces. pub subdivisions: u32, + /// The number of subdivision used to approimate the curved + /// borders of round shapes. pub border_subdivisions: u32, + /// The color of colliders attached to dynamic rigid-bodies. pub collider_dynamic_color: DebugColor, + /// The color of colliders attached to fixed rigid-bodies. pub collider_fixed_color: DebugColor, + /// The color of colliders attached to kinematic rigid-bodies. pub collider_kinematic_color: DebugColor, + /// The color of colliders not attached to any rigid-body. pub collider_parentless_color: DebugColor, + /// The color of the line between a rigid-body’s center-of-mass and the + /// anchors of its attached impulse joints. pub impulse_joint_anchor_color: DebugColor, + /// The color of the line between the two anchors of an impulse joint. pub impulse_joint_separation_color: DebugColor, + /// The color of the line between a rigid-body’s center-of-mass and the + /// anchors of its attached multibody joints. pub multibody_joint_anchor_color: DebugColor, + /// The color of the line between the two anchors of a multibody joint. pub multibody_joint_separation_color: DebugColor, + /// If a rigid-body is sleeping, its attached entities will have their colors + /// multiplied by this array. (For a joint, both attached rigid-bodies must be sleeping + /// or non-dynamic for this multiplier to be applied). pub sleep_color_multiplier: [f32; 4], + /// The length of the local coordinate axes rendered for a rigid-body. pub rigid_body_axes_length: f32, } -- cgit From 7dc038aec66783d72abda446d6251385e6ad30f4 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Thu, 28 Apr 2022 17:51:17 +0200 Subject: Fix test build --- src/pipeline/debug_render_pipeline/debug_render_style.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/pipeline/debug_render_pipeline/debug_render_style.rs') diff --git a/src/pipeline/debug_render_pipeline/debug_render_style.rs b/src/pipeline/debug_render_pipeline/debug_render_style.rs index 0b6fa46..ac2b3a3 100644 --- a/src/pipeline/debug_render_pipeline/debug_render_style.rs +++ b/src/pipeline/debug_render_pipeline/debug_render_style.rs @@ -1,3 +1,5 @@ +use crate::math::Real; + /// A color for debug-rendering. /// /// The default colors are provided in HSLA (Hue Saturation Lightness Alpha) format. @@ -35,7 +37,7 @@ pub struct DebugRenderStyle { /// or non-dynamic for this multiplier to be applied). pub sleep_color_multiplier: [f32; 4], /// The length of the local coordinate axes rendered for a rigid-body. - pub rigid_body_axes_length: f32, + pub rigid_body_axes_length: Real, } impl Default for DebugRenderStyle { -- cgit