Skip to content

Commit

Permalink
don't use let else in debug rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
barsoosayque committed Nov 12, 2023
1 parent 32a0b41 commit 3f6ca06
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ impl Plugin for RapierDebugRenderPlugin {
struct BevyLinesRenderBackend<'world, 'state, 'a, 'b> {
physics_scale: f32,
custom_colors: Query<'world, 'state, &'a ColliderDebugColor>,
global: bool,
visible: Query<'world, 'state, &'a ColliderDebug>,
visible_colliders: Option<Query<'world, 'state, &'a ColliderDebug>>,
context: &'b RapierContext,
gizmos: Gizmos<'state>,
}
Expand All @@ -134,16 +133,16 @@ impl<'world, 'state, 'a, 'b> BevyLinesRenderBackend<'world, 'state, 'a, 'b> {
}

fn drawing_enabled(&self, object: DebugRenderObject) -> bool {
match object {
DebugRenderObject::Collider(h, ..) => self
.context
.colliders
.get(h)
.map(|co| {
let entity = Entity::from_bits(co.user_data as u64);
self.global || self.visible.contains(entity)
})
.unwrap_or(false),
match (object, &self.visible_colliders) {
(DebugRenderObject::Collider(h, ..), Some(visible_colliders)) => {
let collider = self.context.colliders.get(h);
collider
.map(|co| {
let entity = Entity::from_bits(co.user_data as u64);
visible_colliders.contains(entity)
})
.unwrap_or(false)
}
_ => true,
}
}
Expand Down Expand Up @@ -198,17 +197,16 @@ fn debug_render_scene<'a>(
mut render_context: ResMut<DebugRenderContext>,
gizmos: Gizmos,
custom_colors: Query<&'a ColliderDebugColor>,
visible: Query<&'a ColliderDebug>,
visible_colliders: Query<&'a ColliderDebug>,
) {
if !render_context.enabled {
return;
}

let mut backend = BevyLinesRenderBackend {
global: render_context.global,
physics_scale: rapier_context.physics_scale,
custom_colors,
visible,
visible_colliders: render_context.global.then(|| visible_colliders),
context: &rapier_context,
gizmos,
};
Expand Down

0 comments on commit 3f6ca06

Please sign in to comment.