rapier3d/pipeline/debug_render_pipeline/
debug_render_style.rs

1use crate::math::Real;
2
3/// A color for debug-rendering.
4///
5/// The default colors are provided in HSLA (Hue Saturation Lightness Alpha) format.
6pub type DebugColor = [f32; 4];
7
8/// Style used for computing colors when rendering the scene.
9#[derive(Copy, Clone, Debug, PartialEq)]
10pub struct DebugRenderStyle {
11    /// The number of subdivisions used to approximate the curved
12    /// parts of a shape with smooth faces.
13    pub subdivisions: u32,
14    /// The number of subdivisions used to approximate the curved
15    /// borders of round shapes.
16    pub border_subdivisions: u32,
17    /// The color of colliders attached to dynamic rigid-bodies.
18    pub collider_dynamic_color: DebugColor,
19    /// The color of colliders attached to fixed rigid-bodies.
20    pub collider_fixed_color: DebugColor,
21    /// The color of colliders attached to kinematic rigid-bodies.
22    pub collider_kinematic_color: DebugColor,
23    /// The color of colliders not attached to any rigid-body.
24    pub collider_parentless_color: DebugColor,
25    /// The color of the line between a rigid-body’s center-of-mass and the
26    /// anchors of its attached impulse joints.
27    pub impulse_joint_anchor_color: DebugColor,
28    /// The color of the line between the two anchors of an impulse joint.
29    pub impulse_joint_separation_color: DebugColor,
30    /// The color of the line between a rigid-body’s center-of-mass and the
31    /// anchors of its attached multibody joints.
32    pub multibody_joint_anchor_color: DebugColor,
33    /// The color of the line between the two anchors of a multibody joint.
34    pub multibody_joint_separation_color: DebugColor,
35    /// If a rigid-body is sleeping, its attached entities will have their colors
36    /// multiplied by this array. (For a joint, both attached rigid-bodies must be sleeping
37    /// or non-dynamic for this multiplier to be applied).
38    pub sleep_color_multiplier: DebugColor,
39    /// If a rigid-body is disabled, its attached entities will have their colors
40    /// multiplied by this array. (For a joint, both attached rigid-bodies must be disabled
41    /// for this multiplier to be applied).
42    pub disabled_color_multiplier: DebugColor,
43    /// The length of the local coordinate axes rendered for a rigid-body.
44    pub rigid_body_axes_length: Real,
45    /// The color for the segments joining the two contact points.
46    pub contact_depth_color: DebugColor,
47    /// The color of the contact normals.
48    pub contact_normal_color: DebugColor,
49    /// The length of the contact normals.
50    pub contact_normal_length: Real,
51    /// The color of the colliders' [`Aabb`](crate::geometry::Aabb)s.
52    pub collider_aabb_color: DebugColor,
53}
54
55impl Default for DebugRenderStyle {
56    fn default() -> Self {
57        Self {
58            subdivisions: 20,
59            border_subdivisions: 5,
60            collider_dynamic_color: [340.0, 1.0, 0.3, 1.0],
61            collider_kinematic_color: [20.0, 1.0, 0.3, 1.0],
62            collider_fixed_color: [30.0, 1.0, 0.4, 1.0],
63            collider_parentless_color: [30.0, 1.0, 0.4, 1.0],
64            impulse_joint_anchor_color: [240.0, 0.5, 0.4, 1.0],
65            impulse_joint_separation_color: [0.0, 0.5, 0.4, 1.0],
66            multibody_joint_anchor_color: [300.0, 1.0, 0.4, 1.0],
67            multibody_joint_separation_color: [0.0, 1.0, 0.4, 1.0],
68            sleep_color_multiplier: [1.0, 1.0, 0.2, 1.0],
69            disabled_color_multiplier: [0.0, 0.0, 1.0, 1.0],
70            rigid_body_axes_length: 0.5,
71            contact_depth_color: [120.0, 1.0, 0.4, 1.0],
72            contact_normal_color: [0.0, 1.0, 1.0, 1.0],
73            contact_normal_length: 0.3,
74            collider_aabb_color: [124.0, 1.0, 0.4, 1.0],
75        }
76    }
77}