move get_insert_bundle_info (#2508)
				
					
				
			I had to move this out in my relations PR and its causing a large diff so I figure I could just do this separately
This commit is contained in:
		
							parent
							
								
									2c28331297
								
							
						
					
					
						commit
						ba2916c45a
					
				@ -189,9 +189,9 @@ impl<'w> EntityMut<'w> {
 | 
			
		||||
            })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO: move relevant methods to World (add/remove bundle)
 | 
			
		||||
    pub fn insert_bundle<T: Bundle>(&mut self, bundle: T) -> &mut Self {
 | 
			
		||||
        // Use a non-generic function to cut down on monomorphization
 | 
			
		||||
    /// # Safety:
 | 
			
		||||
    /// Partially moves the entity to a new archetype based on the provided bundle info
 | 
			
		||||
    /// You must handle the other part of moving the entity yourself
 | 
			
		||||
    unsafe fn get_insert_bundle_info<'a>(
 | 
			
		||||
        entities: &mut Entities,
 | 
			
		||||
        archetypes: &'a mut Archetypes,
 | 
			
		||||
@ -228,12 +228,10 @@ impl<'w> EntityMut<'w> {
 | 
			
		||||
            let new_location = if old_table_id == new_table_id {
 | 
			
		||||
                archetypes[new_archetype_id].allocate(entity, old_table_row)
 | 
			
		||||
            } else {
 | 
			
		||||
                    let (old_table, new_table) =
 | 
			
		||||
                        storages.tables.get_2_mut(old_table_id, new_table_id);
 | 
			
		||||
                let (old_table, new_table) = storages.tables.get_2_mut(old_table_id, new_table_id);
 | 
			
		||||
                // PERF: store "non bundle" components in edge, then just move those to avoid
 | 
			
		||||
                // redundant copies
 | 
			
		||||
                    let move_result =
 | 
			
		||||
                        old_table.move_to_superset_unchecked(old_table_row, new_table);
 | 
			
		||||
                let move_result = old_table.move_to_superset_unchecked(old_table_row, new_table);
 | 
			
		||||
 | 
			
		||||
                let new_location =
 | 
			
		||||
                    archetypes[new_archetype_id].allocate(entity, move_result.new_row);
 | 
			
		||||
@ -259,6 +257,8 @@ impl<'w> EntityMut<'w> {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO: move relevant methods to World (add/remove bundle)
 | 
			
		||||
    pub fn insert_bundle<T: Bundle>(&mut self, bundle: T) -> &mut Self {
 | 
			
		||||
        let change_tick = self.world.change_tick();
 | 
			
		||||
        let bundle_info = self
 | 
			
		||||
            .world
 | 
			
		||||
@ -266,7 +266,7 @@ impl<'w> EntityMut<'w> {
 | 
			
		||||
            .init_info::<T>(&mut self.world.components);
 | 
			
		||||
 | 
			
		||||
        let (archetype, bundle_status, new_location) = unsafe {
 | 
			
		||||
            get_insert_bundle_info(
 | 
			
		||||
            Self::get_insert_bundle_info(
 | 
			
		||||
                &mut self.world.entities,
 | 
			
		||||
                &mut self.world.archetypes,
 | 
			
		||||
                &mut self.world.components,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user