@@ -42,7 +42,7 @@ use bevy_render::{
4242 mesh:: { allocator:: MeshAllocator , RenderMesh , RenderMeshBufferInfo } ,
4343 render_asset:: RenderAssets ,
4444 render_phase:: {
45- BinnedRenderPhasePlugin , InputUniformIndex , PhaseItem , PhaseItemExtraIndex , RenderCommand ,
45+ BinnedRenderPhasePlugin , PhaseItem , PhaseItemExtraIndex , RenderCommand ,
4646 RenderCommandResult , SortedRenderPhasePlugin , TrackedRenderPass ,
4747 } ,
4848 render_resource:: * ,
@@ -522,124 +522,6 @@ pub struct RenderMeshInstanceGpuQueues(Parallel<RenderMeshInstanceGpuQueue>);
522522#[ derive( Resource , Default , Deref , DerefMut ) ]
523523pub struct MeshesToReextractNextFrame ( MainEntityHashSet ) ;
524524
525- /// Information that the render world keeps about each entity that contains a
526- /// mesh.
527- ///
528- /// The set of information needed is different depending on whether CPU or GPU
529- /// [`MeshUniform`] building is in use.
530- #[ derive( Resource ) ]
531- pub enum RenderMeshInstances {
532- /// Information needed when using CPU mesh instance data building.
533- CpuBuilding ( RenderMeshInstancesCpu ) ,
534- /// Information needed when using GPU mesh instance data building.
535- GpuBuilding ( RenderMeshInstancesGpu ) ,
536- }
537-
538- /// Information that the render world keeps about each entity that contains a
539- /// mesh, when using CPU mesh instance data building.
540- #[ derive( Default , Deref , DerefMut ) ]
541- pub struct RenderMeshInstancesCpu ( MainEntityHashMap < RenderMeshInstanceCpu > ) ;
542-
543- /// Information that the render world keeps about each entity that contains a
544- /// mesh, when using GPU mesh instance data building.
545- #[ derive( Default , Deref , DerefMut ) ]
546- pub struct RenderMeshInstancesGpu ( MainEntityHashMap < RenderMeshInstanceGpu > ) ;
547-
548- impl RenderMeshInstances {
549- /// Creates a new [`RenderMeshInstances`] instance.
550- fn new ( use_gpu_instance_buffer_builder : bool ) -> RenderMeshInstances {
551- if use_gpu_instance_buffer_builder {
552- RenderMeshInstances :: GpuBuilding ( RenderMeshInstancesGpu :: default ( ) )
553- } else {
554- RenderMeshInstances :: CpuBuilding ( RenderMeshInstancesCpu :: default ( ) )
555- }
556- }
557-
558- /// Returns the ID of the mesh asset attached to the given entity, if any.
559- pub fn mesh_asset_id ( & self , entity : MainEntity ) -> Option < AssetId < Mesh > > {
560- match * self {
561- RenderMeshInstances :: CpuBuilding ( ref instances) => instances. mesh_asset_id ( entity) ,
562- RenderMeshInstances :: GpuBuilding ( ref instances) => instances. mesh_asset_id ( entity) ,
563- }
564- }
565-
566- /// Constructs [`RenderMeshQueueData`] for the given entity, if it has a
567- /// mesh attached.
568- pub fn render_mesh_queue_data ( & self , entity : MainEntity ) -> Option < RenderMeshQueueData < ' _ > > {
569- match * self {
570- RenderMeshInstances :: CpuBuilding ( ref instances) => {
571- instances. render_mesh_queue_data ( entity)
572- }
573- RenderMeshInstances :: GpuBuilding ( ref instances) => {
574- instances. render_mesh_queue_data ( entity)
575- }
576- }
577- }
578-
579- /// Inserts the given flags into the CPU or GPU render mesh instance data
580- /// for the given mesh as appropriate.
581- fn insert_mesh_instance_flags ( & mut self , entity : MainEntity , flags : RenderMeshInstanceFlags ) {
582- match * self {
583- RenderMeshInstances :: CpuBuilding ( ref mut instances) => {
584- instances. insert_mesh_instance_flags ( entity, flags) ;
585- }
586- RenderMeshInstances :: GpuBuilding ( ref mut instances) => {
587- instances. insert_mesh_instance_flags ( entity, flags) ;
588- }
589- }
590- }
591- }
592-
593- impl RenderMeshInstancesCpu {
594- fn mesh_asset_id ( & self , entity : MainEntity ) -> Option < AssetId < Mesh > > {
595- self . get ( & entity)
596- . map ( |render_mesh_instance| render_mesh_instance. mesh_asset_id )
597- }
598-
599- pub fn render_mesh_queue_data ( & self , entity : MainEntity ) -> Option < RenderMeshQueueData < ' _ > > {
600- self . get ( & entity)
601- . map ( |render_mesh_instance| RenderMeshQueueData {
602- shared : & render_mesh_instance. shared ,
603- translation : render_mesh_instance. transforms . world_from_local . translation ,
604- current_uniform_index : InputUniformIndex :: default ( ) ,
605- } )
606- }
607-
608- /// Inserts the given flags into the render mesh instance data for the given
609- /// mesh.
610- fn insert_mesh_instance_flags ( & mut self , entity : MainEntity , flags : RenderMeshInstanceFlags ) {
611- if let Some ( instance) = self . get_mut ( & entity) {
612- instance. flags . insert ( flags) ;
613- }
614- }
615- }
616-
617- impl RenderMeshInstancesGpu {
618- fn mesh_asset_id ( & self , entity : MainEntity ) -> Option < AssetId < Mesh > > {
619- self . get ( & entity)
620- . map ( |render_mesh_instance| render_mesh_instance. mesh_asset_id )
621- }
622-
623- fn render_mesh_queue_data ( & self , entity : MainEntity ) -> Option < RenderMeshQueueData < ' _ > > {
624- self . get ( & entity)
625- . map ( |render_mesh_instance| RenderMeshQueueData {
626- shared : & render_mesh_instance. shared ,
627- translation : render_mesh_instance. translation ,
628- current_uniform_index : InputUniformIndex (
629- render_mesh_instance. current_uniform_index . into ( ) ,
630- ) ,
631- } )
632- }
633-
634- /// Inserts the given flags into the render mesh instance data for the given
635- /// mesh.
636- fn insert_mesh_instance_flags ( & mut self , entity : MainEntity , flags : RenderMeshInstanceFlags ) {
637- if let Some ( instance) = self . get_mut ( & entity) {
638- instance. flags . insert ( flags) ;
639- }
640- }
641- }
642-
643525impl RenderMeshInstanceGpuQueue {
644526 /// Clears out a [`RenderMeshInstanceGpuQueue`], creating or recreating it
645527 /// as necessary.
@@ -912,20 +794,6 @@ impl Default for MeshCullingDataBuffer {
912794 }
913795}
914796
915- /// Data that [`crate::material::queue_material_meshes`] and similar systems
916- /// need in order to place entities that contain meshes in the right batch.
917- #[ derive( Deref ) ]
918- pub struct RenderMeshQueueData < ' a > {
919- /// General information about the mesh instance.
920- #[ deref]
921- pub shared : & ' a RenderMeshInstanceShared ,
922- /// The translation of the mesh instance.
923- pub translation : Vec3 ,
924- /// The index of the [`MeshInputUniform`] in the GPU buffer for this mesh
925- /// instance.
926- pub current_uniform_index : InputUniformIndex ,
927- }
928-
929797/// A [`SystemSet`] that encompasses both [`extract_meshes_for_cpu_building`]
930798/// and [`extract_meshes_for_gpu_building`].
931799#[ derive( SystemSet , Clone , PartialEq , Eq , Debug , Hash ) ]
0 commit comments