pub fn sweep_entities_needing_specialization<M>(
entity_specialization_ticks: ResMut<'_, EntitySpecializationTicks>,
removed_mesh_material_components: Extract<'_, '_, RemovedComponents<'_, '_, MeshMaterial3d<M>>>,
specialized_material_pipeline_cache: ResMut<'_, SpecializedMaterialPipelineCache>,
specialized_prepass_material_pipeline_cache: Option<ResMut<'_, SpecializedPrepassMaterialPipelineCache>>,
specialized_shadow_material_pipeline_cache: Option<ResMut<'_, SpecializedShadowMaterialPipelineCache>>,
render_material_instances: Res<'_, RenderMaterialInstances>,
views: Query<'_, '_, &ExtractedView>,
)where
M: Material,Expand description
A system that runs after all instances of
extract_entities_needs_specialization in order to delete specialization
ticks for entities that are no longer renderable.
We delete entities from the EntitySpecializationTicks table after
updating it with newly-discovered renderable entities in order to handle the
case in which a single entity changes material types. If we naïvely removed
entities from that table when their MeshMaterial3d<M> components were
removed, and an entity changed material types, we might end up adding a new
set of EntitySpecializationTickPair for the new material and then
deleting it upon detecting the removed component for the old material.
Deferring sweep_entities_needing_specialization to the end allows us to
detect the case in which another material type updated the entity
specialization ticks this frame and avoid deleting it if so.