Skip to content

Commit 29ddce2

Browse files
committed
Unified identifer for entities & relations
1 parent 06bf928 commit 29ddce2

File tree

7 files changed

+614
-152
lines changed

7 files changed

+614
-152
lines changed

crates/bevy_ecs/src/entity/map_entities.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use crate::{entity::Entity, world::World};
1+
use crate::{entity::Entity, identifier::masks::IdentifierMask, world::World};
22
use bevy_utils::EntityHashMap;
33

4-
use super::inc_generation_by;
5-
64
/// Operation to map all contained [`Entity`] fields in a type to new values.
75
///
86
/// As entity IDs are valid only for the [`World`] they're sourced from, using [`Entity`]
@@ -70,10 +68,10 @@ impl<'m> EntityMapper<'m> {
7068
}
7169

7270
// this new entity reference is specifically designed to never represent any living entity
73-
let new = Entity {
74-
generation: inc_generation_by(self.dead_start.generation, self.generations),
75-
index: self.dead_start.index,
76-
};
71+
let new = Entity::new(
72+
self.dead_start.index(),
73+
IdentifierMask::inc_masked_high_by(self.dead_start.generation, self.generations),
74+
);
7775
self.generations += 1;
7876

7977
self.map.insert(entity, new);
@@ -109,7 +107,7 @@ impl<'m> EntityMapper<'m> {
109107
// SAFETY: Entities data is kept in a valid state via `EntityMap::world_scope`
110108
let entities = unsafe { world.entities_mut() };
111109
assert!(entities.free(self.dead_start).is_some());
112-
assert!(entities.reserve_generations(self.dead_start.index, self.generations));
110+
assert!(entities.reserve_generations(self.dead_start.index(), self.generations));
113111
}
114112

115113
/// Creates an [`EntityMapper`] from a provided [`World`] and [`EntityHashMap<Entity, Entity>`], then calls the

0 commit comments

Comments
 (0)