Removed hardcoded values for DebugColor in various places (#774)
This commit is contained in:
@@ -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<Real>,
|
||||
b: Point<Real>,
|
||||
color: [f32; 4],
|
||||
color: DebugColor,
|
||||
);
|
||||
|
||||
/// Draws a set of lines.
|
||||
@@ -54,7 +55,7 @@ pub trait DebugRenderBackend {
|
||||
indices: &[[u32; 2]],
|
||||
transform: &Isometry<Real>,
|
||||
scale: &Vector<Real>,
|
||||
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<Real>],
|
||||
transform: &Isometry<Real>,
|
||||
scale: &Vector<Real>,
|
||||
color: [f32; 4],
|
||||
color: DebugColor,
|
||||
closed: bool,
|
||||
) {
|
||||
for vtx in vertices.windows(2) {
|
||||
|
||||
@@ -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<Real>,
|
||||
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<Real>,
|
||||
color: [f32; 4],
|
||||
color: DebugColor,
|
||||
) {
|
||||
match shape.as_typed_shape() {
|
||||
TypedShape::Ball(s) => {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<Real>, b: Point<Real>, color: [f32; 4]) {
|
||||
fn draw_line(
|
||||
&mut self,
|
||||
_: DebugRenderObject,
|
||||
a: Point<Real>,
|
||||
b: Point<Real>,
|
||||
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<Real>, b: Point<Real>, color: [f32; 4]) {
|
||||
fn draw_line(
|
||||
&mut self,
|
||||
_: DebugRenderObject,
|
||||
a: Point<Real>,
|
||||
b: Point<Real>,
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user