Skip to content

Commit

Permalink
check entity presence before splitting archetypes
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf authored and cart committed Nov 15, 2020
1 parent bcdf30d commit a788af0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crates/bevy_ecs/hecs/src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,18 +709,17 @@ impl World {
}
};
let old_index = loc.index;
let bundle = if check_presence {
let source = &self.archetypes[loc.archetype as usize];
Some(T::get(|ty, size| source.get_dynamic(ty, size, old_index))?)
} else {
None
};
let (source_arch, target_arch) = index2(
&mut self.archetypes,
loc.archetype as usize,
target as usize,
);
let bundle = if check_presence {
Some(T::get(|ty, size| {
source_arch.get_dynamic(ty, size, old_index)
})?)
} else {
None
};
let target_index = target_arch.allocate(entity);
loc.archetype = target;
loc.index = target_index;
Expand Down

0 comments on commit a788af0

Please sign in to comment.