diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index ca9b63e95d..903daab5c0 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -18,6 +18,7 @@ use bevy_core_pipeline::{ }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ + entity::EntityHashMap, prelude::*, system::{lifetimeless::SRes, SystemParamItem}, }; @@ -25,7 +26,6 @@ use bevy_reflect::std_traits::ReflectDefault; use bevy_reflect::Reflect; use bevy_render::{ camera::TemporalJitter, - extract_instances::ExtractedInstances, extract_resource::ExtractResource, mesh::{Mesh3d, MeshVertexBufferLayoutRef, RenderMesh}, render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, @@ -276,7 +276,7 @@ where if let Some(render_app) = app.get_sub_app_mut(RenderApp) { render_app .init_resource::>() - .init_resource::>>() + .init_resource::>() .add_render_command::>() .add_render_command::>() .add_render_command::>() @@ -490,7 +490,15 @@ impl RenderCommand

for SetMaterial } } -pub type RenderMaterialInstances = ExtractedInstances>; +/// Stores all extracted instances of a [`Material`] in the render world. +#[derive(Resource, Deref, DerefMut)] +pub struct RenderMaterialInstances(pub EntityHashMap>); + +impl Default for RenderMaterialInstances { + fn default() -> Self { + Self(Default::default()) + } +} pub const fn alpha_mode_pipeline_key(alpha_mode: AlphaMode, msaa: &Msaa) -> MeshPipelineKey { match alpha_mode { diff --git a/crates/bevy_render/src/extract_component.rs b/crates/bevy_render/src/extract_component.rs index 29c9d229ab..2000046548 100644 --- a/crates/bevy_render/src/extract_component.rs +++ b/crates/bevy_render/src/extract_component.rs @@ -7,12 +7,10 @@ use crate::{ Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; -use bevy_asset::{Asset, Handle}; use bevy_ecs::{ component::Component, prelude::*, query::{QueryFilter, QueryItem, ReadOnlyQueryData}, - system::lifetimeless::Read, }; use core::{marker::PhantomData, ops::Deref}; @@ -197,17 +195,6 @@ impl Plugin for ExtractComponentPlugin { } } -impl ExtractComponent for Handle { - type QueryData = Read>; - type QueryFilter = (); - type Out = Handle; - - #[inline] - fn extract_component(handle: QueryItem<'_, Self::QueryData>) -> Option { - Some(handle.clone_weak()) - } -} - /// This system extracts all components of the corresponding [`ExtractComponent`], for entities that are synced via [`crate::sync_world::SyncToRenderWorld`]. fn extract_components( mut commands: Commands, diff --git a/crates/bevy_render/src/extract_instances.rs b/crates/bevy_render/src/extract_instances.rs index 37edd85076..24cde74619 100644 --- a/crates/bevy_render/src/extract_instances.rs +++ b/crates/bevy_render/src/extract_instances.rs @@ -7,13 +7,12 @@ use core::marker::PhantomData; use bevy_app::{App, Plugin}; -use bevy_asset::{Asset, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ entity::EntityHashMap, prelude::Entity, query::{QueryFilter, QueryItem, ReadOnlyQueryData}, - system::{lifetimeless::Read, Query, ResMut, Resource}, + system::{Query, ResMut, Resource}, }; use crate::{prelude::ViewVisibility, Extract, ExtractSchedule, RenderApp}; @@ -134,15 +133,3 @@ fn extract_visible( } } } - -impl ExtractInstance for AssetId -where - A: Asset, -{ - type QueryData = Read>; - type QueryFilter = (); - - fn extract(item: QueryItem<'_, Self::QueryData>) -> Option { - Some(item.id()) - } -}