@@ -129,7 +129,7 @@ where
129
129
/// entity are simply called in order at rendering time.
130
130
///
131
131
/// See the `custom_phase_item` example for an example of how to use this.
132
- pub non_mesh_items : IndexMap < ( BPI :: BatchSetKey , BPI :: BinKey ) , RenderBin > ,
132
+ pub non_mesh_items : IndexMap < ( BPI :: BatchSetKey , BPI :: BinKey ) , NonMeshEntities > ,
133
133
134
134
/// Information on each batch set.
135
135
///
@@ -322,6 +322,12 @@ pub struct UnbatchableBinnedEntities {
322
322
pub ( crate ) buffer_indices : UnbatchableBinnedEntityIndexSet ,
323
323
}
324
324
325
+ /// Information about [`BinnedRenderPhaseType::NonMesh`] entities.
326
+ pub struct NonMeshEntities {
327
+ /// The entities.
328
+ pub entities : MainEntityHashMap < Entity > ,
329
+ }
330
+
325
331
/// Stores instance indices and dynamic offsets for unbatchable entities in a
326
332
/// binned render phase.
327
333
///
@@ -381,8 +387,6 @@ pub enum BinnedRenderPhaseType {
381
387
382
388
/// The item is a mesh that's eligible for indirect rendering, but can't be
383
389
/// batched with other meshes of the same type.
384
- ///
385
- /// At the moment, this is used for skinned meshes.
386
390
UnbatchableMesh ,
387
391
388
392
/// The item isn't a mesh at all.
@@ -526,10 +530,12 @@ where
526
530
. entry ( ( batch_set_key. clone ( ) , bin_key. clone ( ) ) . clone ( ) )
527
531
{
528
532
indexmap:: map:: Entry :: Occupied ( mut entry) => {
529
- entry. get_mut ( ) . insert ( main_entity, input_uniform_index ) ;
533
+ entry. get_mut ( ) . entities . insert ( main_entity, entity ) ;
530
534
}
531
535
indexmap:: map:: Entry :: Vacant ( entry) => {
532
- entry. insert ( RenderBin :: from_entity ( main_entity, input_uniform_index) ) ;
536
+ let mut entities = MainEntityHashMap :: default ( ) ;
537
+ entities. insert ( main_entity, entity) ;
538
+ entry. insert ( NonMeshEntities { entities } ) ;
533
539
}
534
540
}
535
541
}
@@ -795,14 +801,14 @@ where
795
801
let draw_functions = world. resource :: < DrawFunctions < BPI > > ( ) ;
796
802
let mut draw_functions = draw_functions. write ( ) ;
797
803
798
- for ( ( batch_set_key, bin_key) , bin ) in & self . non_mesh_items {
799
- for & entity in bin . entities . keys ( ) {
804
+ for ( ( batch_set_key, bin_key) , non_mesh_entities ) in & self . non_mesh_items {
805
+ for ( main_entity , entity) in non_mesh_entities . entities . iter ( ) {
800
806
// Come up with a fake batch range and extra index. The draw
801
807
// function is expected to manage any sort of batching logic itself.
802
808
let binned_phase_item = BPI :: new (
803
809
batch_set_key. clone ( ) ,
804
810
bin_key. clone ( ) ,
805
- ( Entity :: PLACEHOLDER , entity ) ,
811
+ ( * entity , * main_entity ) ,
806
812
0 ..1 ,
807
813
PhaseItemExtraIndex :: None ,
808
814
) ;
@@ -921,7 +927,7 @@ fn remove_entity_from_bin<BPI>(
921
927
multidrawable_meshes : & mut IndexMap < BPI :: BatchSetKey , IndexMap < BPI :: BinKey , RenderBin > > ,
922
928
batchable_meshes : & mut IndexMap < ( BPI :: BatchSetKey , BPI :: BinKey ) , RenderBin > ,
923
929
unbatchable_meshes : & mut IndexMap < ( BPI :: BatchSetKey , BPI :: BinKey ) , UnbatchableBinnedEntities > ,
924
- non_mesh_items : & mut IndexMap < ( BPI :: BatchSetKey , BPI :: BinKey ) , RenderBin > ,
930
+ non_mesh_items : & mut IndexMap < ( BPI :: BatchSetKey , BPI :: BinKey ) , NonMeshEntities > ,
925
931
) where
926
932
BPI : BinnedPhaseItem ,
927
933
{
@@ -984,10 +990,10 @@ fn remove_entity_from_bin<BPI>(
984
990
entity_bin_key. batch_set_key . clone ( ) ,
985
991
entity_bin_key. bin_key . clone ( ) ,
986
992
) ) {
987
- bin_entry. get_mut ( ) . remove ( entity) ;
993
+ bin_entry. get_mut ( ) . entities . remove ( & entity) ;
988
994
989
995
// If the bin is now empty, remove the bin.
990
- if bin_entry. get_mut ( ) . is_empty ( ) {
996
+ if bin_entry. get_mut ( ) . entities . is_empty ( ) {
991
997
bin_entry. swap_remove ( ) ;
992
998
}
993
999
}
0 commit comments