Skip to content

Commit e37eb7e

Browse files
committed
don't use let else in debug rendering
1 parent a8d66d0 commit e37eb7e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/render/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ impl Plugin for RapierDebugRenderPlugin {
111111

112112
struct BevyLinesRenderBackend<'world, 'state, 'a, 'b> {
113113
custom_colors: Query<'world, 'state, &'a ColliderDebugColor>,
114-
global: bool,
115-
visible: Query<'world, 'state, &'a ColliderDebug>,
114+
visible_colliders: Option<Query<'world, 'state, &'a ColliderDebug>>,
116115
context: &'b RapierContext,
117116
gizmos: Gizmos<'world, 'state>,
118117
}
@@ -133,16 +132,16 @@ impl<'world, 'state, 'a, 'b> BevyLinesRenderBackend<'world, 'state, 'a, 'b> {
133132
}
134133

135134
fn drawing_enabled(&self, object: DebugRenderObject) -> bool {
136-
match object {
137-
DebugRenderObject::Collider(h, ..) => self
138-
.context
139-
.colliders
140-
.get(h)
141-
.map(|co| {
142-
let entity = Entity::from_bits(co.user_data as u64);
143-
self.global || self.visible.contains(entity)
144-
})
145-
.unwrap_or(false),
135+
match (object, &self.visible_colliders) {
136+
(DebugRenderObject::Collider(h, ..), Some(visible_colliders)) => {
137+
let collider = self.context.colliders.get(h);
138+
collider
139+
.map(|co| {
140+
let entity = Entity::from_bits(co.user_data as u64);
141+
visible_colliders.contains(entity)
142+
})
143+
.unwrap_or(false)
144+
}
146145
_ => true,
147146
}
148147
}
@@ -195,7 +194,7 @@ fn debug_render_scene<'a>(
195194
mut render_context: ResMut<DebugRenderContext>,
196195
gizmos: Gizmos,
197196
custom_colors: Query<&'a ColliderDebugColor>,
198-
visible: Query<&'a ColliderDebug>,
197+
visible_colliders: Query<&'a ColliderDebug>,
199198
) {
200199
if !render_context.enabled {
201200
return;
@@ -204,7 +203,7 @@ fn debug_render_scene<'a>(
204203
let mut backend = BevyLinesRenderBackend {
205204
global: render_context.global,
206205
custom_colors,
207-
visible,
206+
visible_colliders: render_context.global.then(|| visible_colliders),
208207
context: &rapier_context,
209208
gizmos,
210209
};

0 commit comments

Comments
 (0)