Skip to content

Commit cb54e7d

Browse files
committed
skip disabled entities in scenes
1 parent 820feea commit cb54e7d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

crates/bevy_ecs/src/archetype.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,10 @@ impl Archetype {
488488
&self.entities
489489
}
490490

491-
/// Fetches the disabled entities contained in this archetype.
491+
/// Fetches the enabled entities contained in this archetype.
492492
#[inline]
493-
pub fn disabled_entities(&self) -> &[ArchetypeEntity] {
494-
&self.entities[..self.disabled_entities as usize]
493+
pub fn enabled_entities(&self) -> &[ArchetypeEntity] {
494+
&self.entities[self.disabled_entities as usize..]
495495
}
496496

497497
/// Get the valid table rows (i.e. non-disabled entities).
@@ -507,8 +507,7 @@ impl Archetype {
507507
#[inline]
508508
pub fn entities_with_location(
509509
&self,
510-
) -> impl Iterator<Item = (Entity, EntityLocation)> + DoubleEndedIterator + ExactSizeIterator
511-
{
510+
) -> impl DoubleEndedIterator<Item = (Entity, EntityLocation)> + ExactSizeIterator {
512511
self.entities.iter().enumerate().map(
513512
|(archetype_row, &ArchetypeEntity { entity, table_row })| {
514513
(

crates/bevy_scene/src/dynamic_scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl DynamicScene {
6060
world
6161
.archetypes()
6262
.iter()
63-
.flat_map(bevy_ecs::archetype::Archetype::entities)
63+
.flat_map(bevy_ecs::archetype::Archetype::enabled_entities)
6464
.map(bevy_ecs::archetype::ArchetypeEntity::id),
6565
)
6666
.extract_resources()

crates/bevy_scene/src/scene.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ impl Scene {
106106
// Ensure that all scene entities have been allocated in the destination
107107
// world before handling components that may contain references that need mapping.
108108
for archetype in self.world.archetypes().iter() {
109-
for scene_entity in archetype.entities() {
109+
for scene_entity in archetype.enabled_entities() {
110110
entity_map
111111
.entry(scene_entity.id())
112112
.or_insert_with(|| world.spawn_empty().id());
113113
}
114114
}
115115

116116
for archetype in self.world.archetypes().iter() {
117-
for scene_entity in archetype.entities() {
117+
for scene_entity in archetype.enabled_entities() {
118118
let entity = *entity_map
119119
.get(&scene_entity.id())
120120
.expect("should have previously spawned an entity");

0 commit comments

Comments
 (0)