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