Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding some docs for archetype internals #12578

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/bevy_ecs/src/archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ pub(crate) enum ComponentStatus {
}

pub(crate) struct AddBundle {
/// The target archetype after the bundle is added to the source archetype
pub archetype_id: ArchetypeId,
/// For each component iterated in the same order as the source [`Bundle`](crate::bundle::Bundle),
/// indicate if the component is newly added to the target archetype or if it already existed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's the status on the entity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry; of which entity?

From what I understand, the bundle_status is computed just by comparing the components of the bundle with the components of the source archetype; no entities are involved.
(https://github.com/cBournhonesque/bevy/blob/7281b0e06c531cac4b9073cbb119b036a2ddfacb/crates/bevy_ecs/src/bundle.rs#L442)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep @cBournhonesque is right here. The entity's components are based on which archetype it's in, so this comment makes perfect sense.

pub bundle_status: Vec<ComponentStatus>,
}

Expand Down Expand Up @@ -285,8 +288,12 @@ impl ArchetypeEntity {
}
}

/// Internal metadata for an [`Entity`] getting removed from an [`Archetype`].
pub(crate) struct ArchetypeSwapRemoveResult {
/// If the [`Entity`] was not the last in the [`Archetype`], it gets removed by swapping it out
/// with the last entity in the archetype. In that case, this field contains the swapped entity.
pub(crate) swapped_entity: Option<Entity>,
/// The [`TableRow`] where the removed entity's components are stored.
pub(crate) table_row: TableRow,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ impl World {
}

/// # Panics
/// panics if `component_id` is not registered in this world
/// Panics if `component_id` is not registered in this world
#[inline]
pub(crate) fn initialize_non_send_internal(
&mut self,
Expand Down