Skip to content

Commit 3f6ca06

Browse files
committed
don't use let else in debug rendering
1 parent 32a0b41 commit 3f6ca06

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/render/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ impl Plugin for RapierDebugRenderPlugin {
112112
struct BevyLinesRenderBackend<'world, 'state, 'a, 'b> {
113113
physics_scale: f32,
114114
custom_colors: Query<'world, 'state, &'a ColliderDebugColor>,
115-
global: bool,
116-
visible: Query<'world, 'state, &'a ColliderDebug>,
115+
visible_colliders: Option<Query<'world, 'state, &'a ColliderDebug>>,
117116
context: &'b RapierContext,
118117
gizmos: Gizmos<'state>,
119118
}
@@ -134,16 +133,16 @@ impl<'world, 'state, 'a, 'b> BevyLinesRenderBackend<'world, 'state, 'a, 'b> {
134133
}
135134

136135
fn drawing_enabled(&self, object: DebugRenderObject) -> bool {
137-
match object {
138-
DebugRenderObject::Collider(h, ..) => self
139-
.context
140-
.colliders
141-
.get(h)
142-
.map(|co| {
143-
let entity = Entity::from_bits(co.user_data as u64);
144-
self.global || self.visible.contains(entity)
145-
})
146-
.unwrap_or(false),
136+
match (object, &self.visible_colliders) {
137+
(DebugRenderObject::Collider(h, ..), Some(visible_colliders)) => {
138+
let collider = self.context.colliders.get(h);
139+
collider
140+
.map(|co| {
141+
let entity = Entity::from_bits(co.user_data as u64);
142+
visible_colliders.contains(entity)
143+
})
144+
.unwrap_or(false)
145+
}
147146
_ => true,
148147
}
149148
}
@@ -198,17 +197,16 @@ fn debug_render_scene<'a>(
198197
mut render_context: ResMut<DebugRenderContext>,
199198
gizmos: Gizmos,
200199
custom_colors: Query<&'a ColliderDebugColor>,
201-
visible: Query<&'a ColliderDebug>,
200+
visible_colliders: Query<&'a ColliderDebug>,
202201
) {
203202
if !render_context.enabled {
204203
return;
205204
}
206205

207206
let mut backend = BevyLinesRenderBackend {
208-
global: render_context.global,
209207
physics_scale: rapier_context.physics_scale,
210208
custom_colors,
211-
visible,
209+
visible_colliders: render_context.global.then(|| visible_colliders),
212210
context: &rapier_context,
213211
gizmos,
214212
};

0 commit comments

Comments
 (0)