@@ -112,8 +112,7 @@ impl Plugin for RapierDebugRenderPlugin {
112
112
struct BevyLinesRenderBackend < ' world , ' state , ' a , ' b > {
113
113
physics_scale : f32 ,
114
114
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 > > ,
117
116
context : & ' b RapierContext ,
118
117
gizmos : Gizmos < ' state > ,
119
118
}
@@ -134,16 +133,16 @@ impl<'world, 'state, 'a, 'b> BevyLinesRenderBackend<'world, 'state, 'a, 'b> {
134
133
}
135
134
136
135
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
+ }
147
146
_ => true ,
148
147
}
149
148
}
@@ -198,17 +197,16 @@ fn debug_render_scene<'a>(
198
197
mut render_context : ResMut < DebugRenderContext > ,
199
198
gizmos : Gizmos ,
200
199
custom_colors : Query < & ' a ColliderDebugColor > ,
201
- visible : Query < & ' a ColliderDebug > ,
200
+ visible_colliders : Query < & ' a ColliderDebug > ,
202
201
) {
203
202
if !render_context. enabled {
204
203
return ;
205
204
}
206
205
207
206
let mut backend = BevyLinesRenderBackend {
208
- global : render_context. global ,
209
207
physics_scale : rapier_context. physics_scale ,
210
208
custom_colors,
211
- visible ,
209
+ visible_colliders : render_context . global . then ( || visible_colliders ) ,
212
210
context : & rapier_context,
213
211
gizmos,
214
212
} ;
0 commit comments