Swap order of eviction/extraction when extracting for specialization (#18846)
# Objective Fixes #18843 ## Solution We need to account for the material being added and removed in the course of the same frame. We evict the caches first because the entity will be re-added if it was marked as needing specialization, which avoids another check on removed components to see if it was "really" despawned.
This commit is contained in:
parent
6eaa6a6a03
commit
18e1bf1c3d
@ -822,11 +822,9 @@ pub fn extract_entities_needs_specialization<M>(
|
|||||||
) where
|
) where
|
||||||
M: Material,
|
M: Material,
|
||||||
{
|
{
|
||||||
for entity in entities_needing_specialization.iter() {
|
// Clean up any despawned entities, we do this first in case the removed material was re-added
|
||||||
// Update the entity's specialization tick with this run's tick
|
// the same frame, thus will appear both in the removed components list and have been added to
|
||||||
entity_specialization_ticks.insert((*entity).into(), ticks.this_run());
|
// the `EntitiesNeedingSpecialization` collection by triggering the `Changed` filter
|
||||||
}
|
|
||||||
// Clean up any despawned entities
|
|
||||||
for entity in removed_mesh_material_components.read() {
|
for entity in removed_mesh_material_components.read() {
|
||||||
entity_specialization_ticks.remove(&MainEntity::from(entity));
|
entity_specialization_ticks.remove(&MainEntity::from(entity));
|
||||||
for view in views {
|
for view in views {
|
||||||
@ -849,6 +847,11 @@ pub fn extract_entities_needs_specialization<M>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for entity in entities_needing_specialization.iter() {
|
||||||
|
// Update the entity's specialization tick with this run's tick
|
||||||
|
entity_specialization_ticks.insert((*entity).into(), ticks.this_run());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Deref, DerefMut, Clone, Debug)]
|
#[derive(Resource, Deref, DerefMut, Clone, Debug)]
|
||||||
|
@ -564,11 +564,9 @@ pub fn extract_entities_needs_specialization<M>(
|
|||||||
) where
|
) where
|
||||||
M: Material2d,
|
M: Material2d,
|
||||||
{
|
{
|
||||||
for entity in entities_needing_specialization.iter() {
|
// Clean up any despawned entities, we do this first in case the removed material was re-added
|
||||||
// Update the entity's specialization tick with this run's tick
|
// the same frame, thus will appear both in the removed components list and have been added to
|
||||||
entity_specialization_ticks.insert((*entity).into(), ticks.this_run());
|
// the `EntitiesNeedingSpecialization` collection by triggering the `Changed` filter
|
||||||
}
|
|
||||||
// Clean up any despawned entities
|
|
||||||
for entity in removed_mesh_material_components.read() {
|
for entity in removed_mesh_material_components.read() {
|
||||||
entity_specialization_ticks.remove(&MainEntity::from(entity));
|
entity_specialization_ticks.remove(&MainEntity::from(entity));
|
||||||
for view in views {
|
for view in views {
|
||||||
@ -577,6 +575,10 @@ pub fn extract_entities_needs_specialization<M>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for entity in entities_needing_specialization.iter() {
|
||||||
|
// Update the entity's specialization tick with this run's tick
|
||||||
|
entity_specialization_ticks.insert((*entity).into(), ticks.this_run());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Resource, Deref, DerefMut, Debug)]
|
#[derive(Clone, Resource, Deref, DerefMut, Debug)]
|
||||||
|
Loading…
Reference in New Issue
Block a user