Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ impl<'world, 'state, 'world2, 'state2, 'a, 'c, 'd, 'v, 'p>
impl<'world, 'state, 'world2, 'state2, 'a, 'c, 'd, 'v, 'p> DebugRenderBackend
for BevyLinesRenderBackend<'world, 'state, 'world2, 'state2, 'a, 'c, 'd, 'v, 'p>
{
fn filter_object(&self, object: DebugRenderObject) -> bool {
self.drawing_enabled(object)
}

#[cfg(feature = "dim2")]
fn draw_line(&mut self, object: DebugRenderObject, a: Vector, b: Vector, color: [f32; 4]) {
if !self.drawing_enabled(object) {
return;
}

let color = self.object_color(object, color);
self.gizmos.line(
[a.x, a.y, 0.0].into(),
Expand All @@ -190,17 +190,53 @@ impl<'world, 'state, 'world2, 'state2, 'a, 'c, 'd, 'v, 'p> DebugRenderBackend

#[cfg(feature = "dim3")]
fn draw_line(&mut self, object: DebugRenderObject, a: Vector, b: Vector, color: [f32; 4]) {
if !self.drawing_enabled(object) {
return;
}

let color = self.object_color(object, color);
self.gizmos.line(
[a.x, a.y, a.z].into(),
[b.x, b.y, b.z].into(),
Color::hsla(color[0], color[1], color[2], color[3]),
)
}

#[cfg(feature = "dim2")]
fn draw_polyline(
&mut self,
object: DebugRenderObject,
vertices: &[Vector],
indices: &[[u32; 2]],
transform: &rapier::prelude::Pose,
scale: Vector,
color: rapier::prelude::DebugColor,
) {
let color = self.object_color(object, color);
let color_hsla = Color::hsla(color[0], color[1], color[2], color[3]);
for idx in indices {
let a = *transform * (vertices[idx[0] as usize] * scale);
let b = *transform * (vertices[idx[1] as usize] * scale);
self.gizmos
.line([a.x, a.y, 0.0].into(), [b.x, b.y, 0.0].into(), color_hsla)
}
}

#[cfg(feature = "dim3")]
fn draw_polyline(
&mut self,
object: DebugRenderObject,
vertices: &[Vector],
indices: &[[u32; 2]],
transform: &rapier::prelude::Pose,
scale: Vector,
color: rapier::prelude::DebugColor,
) {
let color = self.object_color(object, color);
let color_hsla = Color::hsla(color[0], color[1], color[2], color[3]);
for idx in indices {
let a = *transform * (vertices[idx[0] as usize] * scale);
let b = *transform * (vertices[idx[1] as usize] * scale);
self.gizmos
.line([a.x, a.y, a.z].into(), [b.x, b.y, b.z].into(), color_hsla)
}
}
}

fn debug_render_scene<'a>(
Expand Down