diff --git a/src/pipeline/debug_render_pipeline/debug_render_backend.rs b/src/pipeline/debug_render_pipeline/debug_render_backend.rs index 47673c5..69049f1 100644 --- a/src/pipeline/debug_render_pipeline/debug_render_backend.rs +++ b/src/pipeline/debug_render_pipeline/debug_render_backend.rs @@ -1,3 +1,4 @@ +use super::DebugColor; use crate::dynamics::{ ImpulseJoint, ImpulseJointHandle, Multibody, MultibodyLink, RigidBody, RigidBodyHandle, }; @@ -43,7 +44,7 @@ pub trait DebugRenderBackend { object: DebugRenderObject, a: Point, b: Point, - color: [f32; 4], + color: DebugColor, ); /// Draws a set of lines. @@ -54,7 +55,7 @@ pub trait DebugRenderBackend { indices: &[[u32; 2]], transform: &Isometry, scale: &Vector, - color: [f32; 4], + color: DebugColor, ) { for idx in indices { let a = transform * (Scale::from(*scale) * vertices[idx[0] as usize]); @@ -70,7 +71,7 @@ pub trait DebugRenderBackend { vertices: &[Point], transform: &Isometry, scale: &Vector, - color: [f32; 4], + color: DebugColor, closed: bool, ) { for vtx in vertices.windows(2) { diff --git a/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs b/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs index 4d1a21e..d12eee2 100644 --- a/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs +++ b/src/pipeline/debug_render_pipeline/debug_render_pipeline.rs @@ -1,4 +1,4 @@ -use super::{outlines, DebugRenderBackend}; +use super::{outlines, DebugColor, DebugRenderBackend}; use crate::dynamics::{ GenericJoint, ImpulseJointSet, MultibodyJointSet, RigidBodySet, RigidBodyType, }; @@ -180,8 +180,8 @@ impl DebugRenderPipeline { let mut render_joint = |body1, body2, data: &GenericJoint, - mut anchor_color: [f32; 4], - mut separation_color: [f32; 4], + mut anchor_color: DebugColor, + mut separation_color: DebugColor, object| { if !backend.filter_object(object) { return; @@ -363,7 +363,7 @@ impl DebugRenderPipeline { backend: &mut impl DebugRenderBackend, shape: &dyn Shape, pos: &Isometry, - color: [f32; 4], + color: DebugColor, ) { match shape.as_typed_shape() { TypedShape::Ball(s) => { @@ -471,7 +471,7 @@ impl DebugRenderPipeline { backend: &mut impl DebugRenderBackend, shape: &dyn Shape, pos: &Isometry, - color: [f32; 4], + color: DebugColor, ) { match shape.as_typed_shape() { TypedShape::Ball(s) => { diff --git a/src/pipeline/debug_render_pipeline/debug_render_style.rs b/src/pipeline/debug_render_pipeline/debug_render_style.rs index fd9acfa..9919e0b 100644 --- a/src/pipeline/debug_render_pipeline/debug_render_style.rs +++ b/src/pipeline/debug_render_pipeline/debug_render_style.rs @@ -35,11 +35,11 @@ pub struct DebugRenderStyle { /// 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], + pub sleep_color_multiplier: DebugColor, /// If a rigid-body is disabled, its attached entities will have their colors /// multiplied by this array. (For a joint, both attached rigid-bodies must be disabled /// for this multiplier to be applied). - pub disabled_color_multiplier: [f32; 4], + pub disabled_color_multiplier: DebugColor, /// The length of the local coordinate axes rendered for a rigid-body. pub rigid_body_axes_length: Real, /// The color for the segments joining the two contact points. diff --git a/src_testbed/debug_render.rs b/src_testbed/debug_render.rs index 3138546..6bd538b 100644 --- a/src_testbed/debug_render.rs +++ b/src_testbed/debug_render.rs @@ -5,7 +5,7 @@ use bevy::gizmos::gizmos::Gizmos; use bevy::prelude::*; use rapier::math::{Point, Real}; use rapier::pipeline::{ - DebugRenderBackend, DebugRenderMode, DebugRenderObject, DebugRenderPipeline, + DebugColor, DebugRenderBackend, DebugRenderMode, DebugRenderObject, DebugRenderPipeline, }; #[derive(Resource)] @@ -36,7 +36,13 @@ struct BevyLinesRenderBackend<'w, 's> { impl<'w, 's> DebugRenderBackend for BevyLinesRenderBackend<'w, 's> { #[cfg(feature = "dim2")] - fn draw_line(&mut self, _: DebugRenderObject, a: Point, b: Point, color: [f32; 4]) { + fn draw_line( + &mut self, + _: DebugRenderObject, + a: Point, + b: Point, + color: DebugColor, + ) { self.gizmos.line( [a.x as f32, a.y as f32, 1.0e-8].into(), [b.x as f32, b.y as f32, 1.0e-8].into(), @@ -44,7 +50,13 @@ impl<'w, 's> DebugRenderBackend for BevyLinesRenderBackend<'w, 's> { ) } #[cfg(feature = "dim3")] - fn draw_line(&mut self, _: DebugRenderObject, a: Point, b: Point, color: [f32; 4]) { + fn draw_line( + &mut self, + _: DebugRenderObject, + a: Point, + b: Point, + color: DebugColor, + ) { self.gizmos.line( [a.x as f32, a.y as f32, a.z as f32].into(), [b.x as f32, b.y as f32, b.z as f32].into(),