Make sure the mesh actually exists before we try to specialize. (#18836)
Fixes #18809 Fixes #18823 Meshes despawned in `Last` can still be in visisible entities if they were visible as of `PostUpdate`. Sanity check that the mesh actually exists before we specialize. We still want to unconditionally assume that the entity is in `EntitySpecializationTicks` as its absence from that cache would likely suggest another bug.
This commit is contained in:
parent
5291d1af87
commit
495798c00b
@ -1011,6 +1011,10 @@ pub fn specialize_material_meshes<M: Material>(
|
|||||||
let Ok(material_asset_id) = material_instance.asset_id.try_typed::<M>() else {
|
let Ok(material_asset_id) = material_instance.asset_id.try_typed::<M>() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
||||||
let last_specialized_tick = view_specialized_material_pipeline_cache
|
let last_specialized_tick = view_specialized_material_pipeline_cache
|
||||||
.get(visible_entity)
|
.get(visible_entity)
|
||||||
@ -1022,10 +1026,6 @@ pub fn specialize_material_meshes<M: Material>(
|
|||||||
if !needs_specialization {
|
if !needs_specialization {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
|
||||||
else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -945,6 +945,10 @@ pub fn specialize_prepass_material_meshes<M>(
|
|||||||
let Ok(material_asset_id) = material_instance.asset_id.try_typed::<M>() else {
|
let Ok(material_asset_id) = material_instance.asset_id.try_typed::<M>() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
||||||
let last_specialized_tick = view_specialized_material_pipeline_cache
|
let last_specialized_tick = view_specialized_material_pipeline_cache
|
||||||
.get(visible_entity)
|
.get(visible_entity)
|
||||||
@ -956,10 +960,6 @@ pub fn specialize_prepass_material_meshes<M>(
|
|||||||
if !needs_specialization {
|
if !needs_specialization {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
|
||||||
else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let Some(material) = render_materials.get(material_asset_id) else {
|
let Some(material) = render_materials.get(material_asset_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -1817,6 +1817,11 @@ pub fn specialize_shadows<M: Material>(
|
|||||||
let Ok(material_asset_id) = material_instances.asset_id.try_typed::<M>() else {
|
let Ok(material_asset_id) = material_instances.asset_id.try_typed::<M>() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
let Some(mesh_instance) =
|
||||||
|
render_mesh_instances.render_mesh_queue_data(visible_entity)
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let entity_tick = entity_specialization_ticks.get(&visible_entity).unwrap();
|
let entity_tick = entity_specialization_ticks.get(&visible_entity).unwrap();
|
||||||
let last_specialized_tick = view_specialized_material_pipeline_cache
|
let last_specialized_tick = view_specialized_material_pipeline_cache
|
||||||
.get(&visible_entity)
|
.get(&visible_entity)
|
||||||
@ -1831,11 +1836,6 @@ pub fn specialize_shadows<M: Material>(
|
|||||||
let Some(material) = render_materials.get(material_asset_id) else {
|
let Some(material) = render_materials.get(material_asset_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Some(mesh_instance) =
|
|
||||||
render_mesh_instances.render_mesh_queue_data(visible_entity)
|
|
||||||
else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
if !mesh_instance
|
if !mesh_instance
|
||||||
.flags
|
.flags
|
||||||
.contains(RenderMeshInstanceFlags::SHADOW_CASTER)
|
.contains(RenderMeshInstanceFlags::SHADOW_CASTER)
|
||||||
|
@ -780,6 +780,10 @@ pub fn specialize_wireframes(
|
|||||||
if !render_wireframe_instances.contains_key(visible_entity) {
|
if !render_wireframe_instances.contains_key(visible_entity) {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
||||||
let last_specialized_tick = view_specialized_material_pipeline_cache
|
let last_specialized_tick = view_specialized_material_pipeline_cache
|
||||||
.get(visible_entity)
|
.get(visible_entity)
|
||||||
@ -791,10 +795,6 @@ pub fn specialize_wireframes(
|
|||||||
if !needs_specialization {
|
if !needs_specialization {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
|
||||||
else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -722,6 +722,9 @@ pub fn specialize_material2d_meshes<M: Material2d>(
|
|||||||
let Some(material_asset_id) = render_material_instances.get(visible_entity) else {
|
let Some(material_asset_id) = render_material_instances.get(visible_entity) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
let Some(mesh_instance) = render_mesh_instances.get_mut(visible_entity) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
||||||
let last_specialized_tick = view_specialized_material_pipeline_cache
|
let last_specialized_tick = view_specialized_material_pipeline_cache
|
||||||
.get(visible_entity)
|
.get(visible_entity)
|
||||||
@ -733,9 +736,6 @@ pub fn specialize_material2d_meshes<M: Material2d>(
|
|||||||
if !needs_specialization {
|
if !needs_specialization {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let Some(mesh_instance) = render_mesh_instances.get_mut(visible_entity) else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let Some(material_2d) = render_materials.get(*material_asset_id) else {
|
let Some(material_2d) = render_materials.get(*material_asset_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -771,6 +771,9 @@ pub fn specialize_wireframes(
|
|||||||
if !render_wireframe_instances.contains_key(visible_entity) {
|
if !render_wireframe_instances.contains_key(visible_entity) {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
let Some(mesh_instance) = render_mesh_instances.get(visible_entity) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap();
|
||||||
let last_specialized_tick = view_specialized_material_pipeline_cache
|
let last_specialized_tick = view_specialized_material_pipeline_cache
|
||||||
.get(visible_entity)
|
.get(visible_entity)
|
||||||
@ -782,9 +785,6 @@ pub fn specialize_wireframes(
|
|||||||
if !needs_specialization {
|
if !needs_specialization {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let Some(mesh_instance) = render_mesh_instances.get(visible_entity) else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user