@@ -126,27 +126,6 @@ fn directional_light_gizmo(
126
126
. with_tip_length ( 0.3 ) ;
127
127
}
128
128
129
- fn draw_gizmos < ' a , P , S , D > (
130
- point_lights : P ,
131
- spot_lights : S ,
132
- directional_lights : D ,
133
- gizmos : & mut Gizmos < LightGizmoConfigGroup > ,
134
- ) where
135
- P : ' a + IntoIterator < Item = ( & ' a PointLight , & ' a GlobalTransform , Color ) > ,
136
- S : ' a + IntoIterator < Item = ( & ' a SpotLight , & ' a GlobalTransform , Color ) > ,
137
- D : ' a + IntoIterator < Item = ( & ' a GlobalTransform , Color ) > ,
138
- {
139
- for ( point_light, transform, color) in point_lights {
140
- point_light_gizmo ( transform, point_light, color, gizmos) ;
141
- }
142
- for ( spot_light, transform, color) in spot_lights {
143
- spot_light_gizmo ( transform, spot_light, color, gizmos) ;
144
- }
145
- for ( transform, color) in directional_lights {
146
- directional_light_gizmo ( transform, color, gizmos) ;
147
- }
148
- }
149
-
150
129
/// A [`Plugin`] that provides visualization of [`PointLight`]s, [`SpotLight`]s
151
130
/// and [`DirectionalLight`]s for debugging.
152
131
pub struct LightGizmoPlugin ;
@@ -244,51 +223,33 @@ fn draw_lights(
244
223
LightGizmoColor :: ByLightType => type_color,
245
224
}
246
225
} ;
247
-
248
- draw_gizmos (
249
- point_query
250
- . iter ( )
251
- . map ( |( entity, light, transform, light_gizmo) | {
252
- (
253
- light,
254
- transform,
255
- color (
256
- entity,
257
- light_gizmo. color ,
258
- light. color ,
259
- gizmos. config_ext . point_light_color ,
260
- ) ,
261
- )
262
- } ) ,
263
- spot_query
264
- . iter ( )
265
- . map ( |( entity, light, transform, light_gizmo) | {
266
- (
267
- light,
268
- transform,
269
- color (
270
- entity,
271
- light_gizmo. color ,
272
- light. color ,
273
- gizmos. config_ext . point_light_color ,
274
- ) ,
275
- )
276
- } ) ,
277
- directional_query
278
- . iter ( )
279
- . map ( |( entity, light, transform, light_gizmo) | {
280
- (
281
- transform,
282
- color (
283
- entity,
284
- light_gizmo. color ,
285
- light. color ,
286
- gizmos. config_ext . point_light_color ,
287
- ) ,
288
- )
289
- } ) ,
290
- & mut gizmos,
291
- ) ;
226
+ for ( entity, light, transform, light_gizmo) in & point_query {
227
+ let color = color (
228
+ entity,
229
+ light_gizmo. color ,
230
+ light. color ,
231
+ gizmos. config_ext . point_light_color ,
232
+ ) ;
233
+ point_light_gizmo ( transform, light, color, & mut gizmos) ;
234
+ }
235
+ for ( entity, light, transform, light_gizmo) in & spot_query {
236
+ let color = color (
237
+ entity,
238
+ light_gizmo. color ,
239
+ light. color ,
240
+ gizmos. config_ext . point_light_color ,
241
+ ) ;
242
+ spot_light_gizmo ( transform, light, color, & mut gizmos) ;
243
+ }
244
+ for ( entity, light, transform, light_gizmo) in & directional_query {
245
+ let color = color (
246
+ entity,
247
+ light_gizmo. color ,
248
+ light. color ,
249
+ gizmos. config_ext . point_light_color ,
250
+ ) ;
251
+ directional_light_gizmo ( transform, color, & mut gizmos) ;
252
+ }
292
253
}
293
254
294
255
fn draw_all_lights (
@@ -301,38 +262,64 @@ fn draw_all_lights(
301
262
mut gizmos : Gizmos < LightGizmoConfigGroup > ,
302
263
) {
303
264
match gizmos. config_ext . color {
304
- LightGizmoColor :: Manual ( color) => draw_gizmos (
305
- point_query. iter ( ) . map ( |( _, l, t) | ( l, t, color) ) ,
306
- spot_query. iter ( ) . map ( |( _, l, t) | ( l, t, color) ) ,
307
- directional_query. iter ( ) . map ( |( _, _, t) | ( t, color) ) ,
308
- & mut gizmos,
309
- ) ,
265
+ LightGizmoColor :: Manual ( color) => {
266
+ for ( _, light, transform) in & point_query {
267
+ point_light_gizmo ( transform, light, color, & mut gizmos) ;
268
+ }
269
+ for ( _, light, transform) in & spot_query {
270
+ spot_light_gizmo ( transform, light, color, & mut gizmos) ;
271
+ }
272
+ for ( _, _, transform) in & directional_query {
273
+ directional_light_gizmo ( transform, color, & mut gizmos) ;
274
+ }
275
+ }
310
276
LightGizmoColor :: Varied => {
311
277
let color = |entity : Entity | Oklcha :: sequential_dispersed ( entity. index ( ) ) . into ( ) ;
312
- draw_gizmos (
313
- point_query. iter ( ) . map ( |( e, l, t) | ( l, t, color ( e) ) ) ,
314
- spot_query. iter ( ) . map ( |( e, l, t) | ( l, t, color ( e) ) ) ,
315
- directional_query. iter ( ) . map ( |( e, _, t) | ( t, color ( e) ) ) ,
316
- & mut gizmos,
317
- ) ;
278
+ for ( entity, light, transform) in & point_query {
279
+ point_light_gizmo ( transform, light, color ( entity) , & mut gizmos) ;
280
+ }
281
+ for ( entity, light, transform) in & spot_query {
282
+ spot_light_gizmo ( transform, light, color ( entity) , & mut gizmos) ;
283
+ }
284
+ for ( entity, _, transform) in & directional_query {
285
+ directional_light_gizmo ( transform, color ( entity) , & mut gizmos) ;
286
+ }
287
+ }
288
+ LightGizmoColor :: MatchLightColor => {
289
+ for ( _, light, transform) in & point_query {
290
+ point_light_gizmo ( transform, light, light. color , & mut gizmos) ;
291
+ }
292
+ for ( _, light, transform) in & spot_query {
293
+ spot_light_gizmo ( transform, light, light. color , & mut gizmos) ;
294
+ }
295
+ for ( _, light, transform) in & directional_query {
296
+ directional_light_gizmo ( transform, light. color , & mut gizmos) ;
297
+ }
298
+ }
299
+ LightGizmoColor :: ByLightType => {
300
+ for ( _, light, transform) in & point_query {
301
+ point_light_gizmo (
302
+ transform,
303
+ light,
304
+ gizmos. config_ext . point_light_color ,
305
+ & mut gizmos,
306
+ ) ;
307
+ }
308
+ for ( _, light, transform) in & spot_query {
309
+ spot_light_gizmo (
310
+ transform,
311
+ light,
312
+ gizmos. config_ext . spot_light_color ,
313
+ & mut gizmos,
314
+ ) ;
315
+ }
316
+ for ( _, _, transform) in & directional_query {
317
+ directional_light_gizmo (
318
+ transform,
319
+ gizmos. config_ext . directional_light_color ,
320
+ & mut gizmos,
321
+ ) ;
322
+ }
318
323
}
319
- LightGizmoColor :: MatchLightColor => draw_gizmos (
320
- point_query. iter ( ) . map ( |( _, l, t) | ( l, t, l. color ) ) ,
321
- spot_query. iter ( ) . map ( |( _, l, t) | ( l, t, l. color ) ) ,
322
- directional_query. iter ( ) . map ( |( _, l, t) | ( t, l. color ) ) ,
323
- & mut gizmos,
324
- ) ,
325
- LightGizmoColor :: ByLightType => draw_gizmos (
326
- point_query
327
- . iter ( )
328
- . map ( |( _, l, t) | ( l, t, gizmos. config_ext . point_light_color ) ) ,
329
- spot_query
330
- . iter ( )
331
- . map ( |( _, l, t) | ( l, t, gizmos. config_ext . spot_light_color ) ) ,
332
- directional_query
333
- . iter ( )
334
- . map ( |( _, _, t) | ( t, gizmos. config_ext . directional_light_color ) ) ,
335
- & mut gizmos,
336
- ) ,
337
324
}
338
325
}
0 commit comments