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 committed Oct 31, 2020
1 parent 1ba9e28 commit 768ae8c
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 @@ -633,18 +633,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 768ae8c

Please sign in to comment.