@@ -421,17 +421,6 @@ pub fn extract_lights(
421421 & mut RenderExtractedShadowMapVisibleEntities ,
422422 & mut RenderShadowMapVisibleEntities ,
423423 ) > ,
424- (
425- mut removed_point_lights,
426- mut removed_spot_lights,
427- mut removed_directional_lights,
428- mut removed_rect_lights,
429- ) : (
430- Extract < RemovedComponents < PointLight > > ,
431- Extract < RemovedComponents < SpotLight > > ,
432- Extract < RemovedComponents < DirectionalLight > > ,
433- Extract < RemovedComponents < RectLight > > ,
434- ) ,
435424) {
436425 let mapper = & visibility_extraction_system_param. mapper ;
437426
@@ -453,14 +442,6 @@ pub fn extract_lights(
453442 // https://catlikecoding.com/unity/tutorials/custom-srp/point-and-spot-shadows/
454443 let point_light_texel_size = 2.0 / point_light_shadow_map. size as f32 ;
455444
456- // Keep track of all entities of a type that we updated this frame, so that
457- // we don't incorrectly remove the components later even if they show up in
458- // `RemovedComponents`.
459- let mut seen_point_light_main_entities = MainEntityHashSet :: default ( ) ;
460- let mut seen_spot_light_main_entities = MainEntityHashSet :: default ( ) ;
461- let mut seen_directional_light_main_entities = MainEntityHashSet :: default ( ) ;
462- let mut seen_rect_light_main_entities = MainEntityHashSet :: default ( ) ;
463-
464445 for (
465446 main_entity,
466447 render_entity,
@@ -472,8 +453,6 @@ pub fn extract_lights(
472453 volumetric_light,
473454 ) in point_lights. iter ( )
474455 {
475- seen_point_light_main_entities. insert ( main_entity. into ( ) ) ;
476-
477456 if !view_visibility. get ( ) {
478457 if let Ok ( mut entity_commands) = commands. get_entity ( render_entity) {
479458 entity_commands. remove :: < ExtractedPointLight > ( ) ;
@@ -586,8 +565,6 @@ pub fn extract_lights(
586565 volumetric_light,
587566 ) in spot_lights. iter ( )
588567 {
589- seen_spot_light_main_entities. insert ( main_entity. into ( ) ) ;
590-
591568 if !view_visibility. get ( ) {
592569 if let Ok ( mut entity_commands) = commands. get_entity ( render_entity) {
593570 entity_commands. remove :: < ExtractedPointLight > ( ) ;
@@ -706,8 +683,6 @@ pub fn extract_lights(
706683 sun_disk,
707684 ) in & directional_lights
708685 {
709- seen_directional_light_main_entities. insert ( main_entity. into ( ) ) ;
710-
711686 if !view_visibility. get ( ) {
712687 commands
713688 . get_entity ( entity)
@@ -850,8 +825,6 @@ pub fn extract_lights(
850825 }
851826
852827 for ( main_entity, render_entity, rect_light, transform, view_visibility) in & rect_lights {
853- seen_rect_light_main_entities. insert ( main_entity. into ( ) ) ;
854-
855828 if !view_visibility. get ( ) {
856829 if let Ok ( mut entity_commands) = commands. get_entity ( render_entity) {
857830 entity_commands. remove :: < ExtractedRectLight > ( ) ;
@@ -879,64 +852,6 @@ pub fn extract_lights(
879852 ) ) ;
880853 }
881854
882- // Remove extracted light components from entities that have had their
883- // light components removed.
884- remove_components :: < PointLight , ExtractedPointLight > (
885- & mut commands,
886- mapper,
887- & mut removed_point_lights,
888- & seen_point_light_main_entities,
889- ) ;
890- remove_components :: < SpotLight , ExtractedPointLight > (
891- & mut commands,
892- mapper,
893- & mut removed_spot_lights,
894- & seen_spot_light_main_entities,
895- ) ;
896- remove_components :: < DirectionalLight , ExtractedDirectionalLight > (
897- & mut commands,
898- mapper,
899- & mut removed_directional_lights,
900- & seen_directional_light_main_entities,
901- ) ;
902- remove_components :: < RectLight , ExtractedRectLight > (
903- & mut commands,
904- mapper,
905- & mut removed_rect_lights,
906- & seen_rect_light_main_entities,
907- ) ;
908-
909- // A helper function that removes a render-world component `RWC` when a
910- // main-world component `MC` is removed.
911- //
912- // `seen_entities` is the list of all entities with that component that were
913- // updated this frame. It's needed because presence in the
914- // `RemovedComponents` table for the main-world component isn't enough to
915- // determine whether the render-world component can be removed, as the
916- // main-world component might have been removed and then re-added in the
917- // same frame.
918- fn remove_components < MC , RWC > (
919- commands : & mut Commands ,
920- mapper : & Query < & RenderEntity > ,
921- removed_components : & mut RemovedComponents < MC > ,
922- seen_entities : & MainEntityHashSet ,
923- ) where
924- MC : Component ,
925- RWC : Component ,
926- {
927- // As usual, only remove components if we didn't process them in the
928- // outer extraction function, because of the possibility that the
929- // component might have been removed and re-added in the same frame.
930- for main_entity in removed_components. read ( ) {
931- if !seen_entities. contains ( & MainEntity :: from ( main_entity) )
932- && let Ok ( render_entity) = mapper. get ( main_entity)
933- && let Ok ( mut entity_commands) = commands. get_entity ( * * render_entity)
934- {
935- entity_commands. remove :: < RWC > ( ) ;
936- }
937- }
938- }
939-
940855 /// Clears out any shadow maps that may be present for a light with shadow
941856 /// mapping turned off.
942857 fn clear_shadow_maps ( commands : & mut Commands , render_entity : Entity ) {
0 commit comments