diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 373a295dc1..a611fb4ff9 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -1011,6 +1011,10 @@ pub fn specialize_material_meshes( let Ok(material_asset_id) = material_instance.asset_id.try_typed::() else { 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 last_specialized_tick = view_specialized_material_pipeline_cache .get(visible_entity) @@ -1022,10 +1026,6 @@ pub fn specialize_material_meshes( if !needs_specialization { 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 { continue; }; diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 5250c8f6a2..77f874c168 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -945,6 +945,10 @@ pub fn specialize_prepass_material_meshes( let Ok(material_asset_id) = material_instance.asset_id.try_typed::() else { 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 last_specialized_tick = view_specialized_material_pipeline_cache .get(visible_entity) @@ -956,10 +960,6 @@ pub fn specialize_prepass_material_meshes( if !needs_specialization { 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 { continue; }; diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index a154c78821..d71dccc71a 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -1817,6 +1817,11 @@ pub fn specialize_shadows( let Ok(material_asset_id) = material_instances.asset_id.try_typed::() else { 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 last_specialized_tick = view_specialized_material_pipeline_cache .get(&visible_entity) @@ -1831,11 +1836,6 @@ pub fn specialize_shadows( let Some(material) = render_materials.get(material_asset_id) else { continue; }; - let Some(mesh_instance) = - render_mesh_instances.render_mesh_queue_data(visible_entity) - else { - continue; - }; if !mesh_instance .flags .contains(RenderMeshInstanceFlags::SHADOW_CASTER) diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index fa40fede65..407062064a 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -780,6 +780,10 @@ pub fn specialize_wireframes( if !render_wireframe_instances.contains_key(visible_entity) { 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 last_specialized_tick = view_specialized_material_pipeline_cache .get(visible_entity) @@ -791,10 +795,6 @@ pub fn specialize_wireframes( if !needs_specialization { 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 { continue; }; diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index 2fd74f676c..ac19697081 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -722,6 +722,9 @@ pub fn specialize_material2d_meshes( let Some(material_asset_id) = render_material_instances.get(visible_entity) else { 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 last_specialized_tick = view_specialized_material_pipeline_cache .get(visible_entity) @@ -733,9 +736,6 @@ pub fn specialize_material2d_meshes( if !needs_specialization { 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 { continue; }; diff --git a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs index aaf3796c1b..63e5280519 100644 --- a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs +++ b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs @@ -771,6 +771,9 @@ pub fn specialize_wireframes( if !render_wireframe_instances.contains_key(visible_entity) { continue; }; + let Some(mesh_instance) = render_mesh_instances.get(visible_entity) else { + continue; + }; let entity_tick = entity_specialization_ticks.get(visible_entity).unwrap(); let last_specialized_tick = view_specialized_material_pipeline_cache .get(visible_entity) @@ -782,9 +785,6 @@ pub fn specialize_wireframes( if !needs_specialization { 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 { continue; };