Skip to content
4 changes: 2 additions & 2 deletions crates/bevy_ecs/macros/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
}
}

fn update_component_access(&self, _access: &mut #path::query::FilteredAccess<#path::component::ComponentId>) {
fn update_component_access(&self, _access: &mut #path::query::FilteredAccess<#path::component::DataId>) {
#(self.#field_idents.update_component_access(_access);)*
}

fn update_archetype_component_access(&self, _archetype: &#path::archetype::Archetype, _access: &mut #path::query::Access<#path::archetype::ArchetypeComponentId>) {
#(self.#field_idents.update_archetype_component_access(_archetype, _access);)*
}

fn matches_component_set(&self, _set_contains_id: &impl Fn(#path::component::ComponentId) -> bool) -> bool {
fn matches_component_set(&self, _set_contains_id: &impl Fn(#path::component::DataId) -> bool) -> bool {
true #(&& self.#field_idents.matches_component_set(_set_contains_id))*

}
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
let struct_name = &ast.ident;

TokenStream::from(quote! {
/// SAFE: ComponentId is returned in field-definition-order. [from_components] and [get_components] use field-definition-order
/// SAFE: DataId is returned in field-definition-order. [from_components] and [get_components] use field-definition-order
unsafe impl #impl_generics #ecs_path::bundle::Bundle for #struct_name #ty_generics #where_clause {
fn component_ids(
components: &mut #ecs_path::component::Components,
components: &mut #ecs_path::component::WorldData,
storages: &mut #ecs_path::storage::Storages,
) -> Vec<#ecs_path::component::ComponentId> {
) -> Vec<#ecs_path::component::DataId> {
let mut component_ids = Vec::with_capacity(#field_len);
#(#field_component_ids)*
component_ids
Expand Down Expand Up @@ -219,7 +219,7 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream {
where #(#param_fetch: ReadOnlySystemParamFetch,)*
{ }

// SAFE: Relevant parameter ComponentId and ArchetypeComponentId access is applied to SystemMeta. If any ParamState conflicts
// SAFE: Relevant parameter DataId and ArchetypeComponentId access is applied to SystemMeta. If any ParamState conflicts
// with any prior access, a panic will occur.

unsafe impl<#(#param_fetch: for<'w1, 's1> SystemParamFetch<'w1, 's1>,)*> SystemParamState for ParamSetState<(#(#param_fetch,)*)>
Expand Down
41 changes: 19 additions & 22 deletions crates/bevy_ecs/src/archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{
bundle::BundleId,
component::{ComponentId, StorageType},
component::{DataId, StorageType},
entity::{Entity, EntityLocation},
storage::{Column, SparseArray, SparseSet, SparseSetIndex, TableId},
};
Expand Down Expand Up @@ -120,18 +120,18 @@ pub struct Archetype {
entities: Vec<Entity>,
edges: Edges,
table_info: TableInfo,
table_components: Box<[ComponentId]>,
sparse_set_components: Box<[ComponentId]>,
pub(crate) unique_components: SparseSet<ComponentId, Column>,
pub(crate) components: SparseSet<ComponentId, ArchetypeComponentInfo>,
table_components: Box<[DataId]>,
sparse_set_components: Box<[DataId]>,
pub(crate) unique_components: SparseSet<DataId, Column>,
pub(crate) components: SparseSet<DataId, ArchetypeComponentInfo>,
}

impl Archetype {
pub fn new(
id: ArchetypeId,
table_id: TableId,
table_components: Box<[ComponentId]>,
sparse_set_components: Box<[ComponentId]>,
table_components: Box<[DataId]>,
sparse_set_components: Box<[DataId]>,
table_archetype_components: Vec<ArchetypeComponentId>,
sparse_set_archetype_components: Vec<ArchetypeComponentId>,
) -> Self {
Expand Down Expand Up @@ -197,27 +197,27 @@ impl Archetype {
}

#[inline]
pub fn table_components(&self) -> &[ComponentId] {
pub fn table_components(&self) -> &[DataId] {
&self.table_components
}

#[inline]
pub fn sparse_set_components(&self) -> &[ComponentId] {
pub fn sparse_set_components(&self) -> &[DataId] {
&self.sparse_set_components
}

#[inline]
pub fn unique_components(&self) -> &SparseSet<ComponentId, Column> {
pub fn unique_components(&self) -> &SparseSet<DataId, Column> {
&self.unique_components
}

#[inline]
pub fn unique_components_mut(&mut self) -> &mut SparseSet<ComponentId, Column> {
pub fn unique_components_mut(&mut self) -> &mut SparseSet<DataId, Column> {
&mut self.unique_components
}

#[inline]
pub fn components(&self) -> impl Iterator<Item = ComponentId> + '_ {
pub fn components(&self) -> impl Iterator<Item = DataId> + '_ {
self.components.indices()
}

Expand Down Expand Up @@ -285,22 +285,19 @@ impl Archetype {
}

#[inline]
pub fn contains(&self, component_id: ComponentId) -> bool {
pub fn contains(&self, component_id: DataId) -> bool {
self.components.contains(component_id)
}

#[inline]
pub fn get_storage_type(&self, component_id: ComponentId) -> Option<StorageType> {
pub fn get_storage_type(&self, component_id: DataId) -> Option<StorageType> {
self.components
.get(component_id)
.map(|info| info.storage_type)
}

#[inline]
pub fn get_archetype_component_id(
&self,
component_id: ComponentId,
) -> Option<ArchetypeComponentId> {
pub fn get_archetype_component_id(&self, component_id: DataId) -> Option<ArchetypeComponentId> {
self.components
.get(component_id)
.map(|info| info.archetype_component_id)
Expand Down Expand Up @@ -330,8 +327,8 @@ impl ArchetypeGeneration {

#[derive(Hash, PartialEq, Eq)]
pub struct ArchetypeIdentity {
table_components: Box<[ComponentId]>,
sparse_set_components: Box<[ComponentId]>,
table_components: Box<[DataId]>,
sparse_set_components: Box<[DataId]>,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
Expand Down Expand Up @@ -473,8 +470,8 @@ impl Archetypes {
pub(crate) fn get_id_or_insert(
&mut self,
table_id: TableId,
table_components: Vec<ComponentId>,
sparse_set_components: Vec<ComponentId>,
table_components: Vec<DataId>,
sparse_set_components: Vec<DataId>,
) -> ArchetypeId {
let table_components = table_components.into_boxed_slice();
let sparse_set_components = sparse_set_components.into_boxed_slice();
Expand Down
36 changes: 18 additions & 18 deletions crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use bevy_ecs_macros::Bundle;

use crate::{
archetype::{AddBundle, Archetype, ArchetypeId, Archetypes, ComponentStatus},
component::{Component, ComponentId, ComponentTicks, Components, StorageType},
component::{Component, ComponentTicks, DataId, StorageType, WorldData},
entity::{Entities, Entity, EntityLocation},
storage::{SparseSetIndex, SparseSets, Storages, Table},
};
Expand Down Expand Up @@ -72,26 +72,26 @@ use std::{any::TypeId, collections::HashMap};
///
/// # Safety
///
/// - [`Bundle::component_ids`] must return the [`ComponentId`] for each component type in the
/// - [`Bundle::component_ids`] must return the [`DataId`] for each component type in the
/// bundle, in the _exact_ order that [`Bundle::get_components`] is called.
/// - [`Bundle::from_components`] must call `func` exactly once for each [`ComponentId`] returned by
/// - [`Bundle::from_components`] must call `func` exactly once for each [`DataId`] returned by
/// [`Bundle::component_ids`].
pub unsafe trait Bundle: Send + Sync + 'static {
/// Gets this [`Bundle`]'s component ids, in the order of this bundle's [`Component`]s
fn component_ids(components: &mut Components, storages: &mut Storages) -> Vec<ComponentId>;
/// Gets this [`Bundle`]'s component ids, in the order of this bundle's [`DataId`]s
fn component_ids(components: &mut WorldData, storages: &mut Storages) -> Vec<DataId>;

/// Calls `func`, which should return data for each component in the bundle, in the order of
/// this bundle's [`Component`]s
/// this bundle's [`WorldData`]s
///
/// # Safety
/// Caller must return data for each component in the bundle, in the order of this bundle's
/// [`Component`]s
/// [`DataId`]s
unsafe fn from_components<T, F>(ctx: &mut T, func: F) -> Self
where
F: FnMut(&mut T) -> OwningPtr<'_>,
Self: Sized;

/// Calls `func` on each value, in the order of this bundle's [`Component`]s. This will
/// Calls `func` on each value, in the order of this bundle's [`DataId`]s. This will
/// [`std::mem::forget`] the bundle fields, so callers are responsible for dropping the fields
/// if that is desirable.
fn get_components(self, func: impl FnMut(OwningPtr<'_>));
Expand All @@ -101,7 +101,7 @@ macro_rules! tuple_impl {
($($name: ident),*) => {
unsafe impl<$($name: Component),*> Bundle for ($($name,)*) {
#[allow(unused_variables)]
fn component_ids(components: &mut Components, storages: &mut Storages) -> Vec<ComponentId> {
fn component_ids(components: &mut WorldData, storages: &mut Storages) -> Vec<DataId> {
vec![$(components.init_component::<$name>(storages)),*]
}

Expand Down Expand Up @@ -152,7 +152,7 @@ impl SparseSetIndex for BundleId {

pub struct BundleInfo {
pub(crate) id: BundleId,
pub(crate) component_ids: Vec<ComponentId>,
pub(crate) component_ids: Vec<DataId>,
pub(crate) storage_types: Vec<StorageType>,
}

Expand All @@ -163,7 +163,7 @@ impl BundleInfo {
}

#[inline]
pub fn components(&self) -> &[ComponentId] {
pub fn components(&self) -> &[DataId] {
&self.component_ids
}

Expand All @@ -176,7 +176,7 @@ impl BundleInfo {
&'b self,
entities: &'a mut Entities,
archetypes: &'a mut Archetypes,
components: &mut Components,
components: &mut WorldData,
storages: &'a mut Storages,
archetype_id: ArchetypeId,
change_tick: u32,
Expand Down Expand Up @@ -236,7 +236,7 @@ impl BundleInfo {
&'b self,
entities: &'a mut Entities,
archetypes: &'a mut Archetypes,
components: &mut Components,
components: &mut WorldData,
storages: &'a mut Storages,
change_tick: u32,
) -> BundleSpawner<'a, 'b> {
Expand Down Expand Up @@ -309,7 +309,7 @@ impl BundleInfo {
&self,
archetypes: &mut Archetypes,
storages: &mut Storages,
components: &mut Components,
components: &mut WorldData,
archetype_id: ArchetypeId,
) -> ArchetypeId {
if let Some(add_bundle) = archetypes[archetype_id].edges().get_add_bundle(self.id) {
Expand Down Expand Up @@ -592,7 +592,7 @@ impl Bundles {

pub(crate) fn init_info<'a, T: Bundle>(
&'a mut self,
components: &mut Components,
components: &mut WorldData,
storages: &mut Storages,
) -> &'a BundleInfo {
let bundle_infos = &mut self.bundle_infos;
Expand All @@ -613,12 +613,12 @@ impl Bundles {

/// # Safety
///
/// `component_id` must be valid [`ComponentId`]'s
/// `component_id` must be valid [`DataId`]'s
unsafe fn initialize_bundle(
bundle_type_name: &'static str,
component_ids: Vec<ComponentId>,
component_ids: Vec<DataId>,
id: BundleId,
components: &mut Components,
components: &mut WorldData,
) -> BundleInfo {
let mut storage_types = Vec::new();

Expand Down
Loading