Skip to content

Commit

Permalink
Adding some docs for archetype internals (#12578)
Browse files Browse the repository at this point in the history
# Objective


I was reading some of the Archetype and Bundle code and was getting
confused a little bit in some places (is the `archetype_id` in
`AddBundle` the source or the target archetype id?).
Small PR that adds some docstrings to make it easier for first-time
readers.
  • Loading branch information
cBournhonesque committed Mar 23, 2024
1 parent fdf2ea7 commit 0b5f7b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/bevy_ecs/src/archetype.rs
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
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
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

0 comments on commit 0b5f7b4

Please sign in to comment.