Skip to content
Closed
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
5 changes: 4 additions & 1 deletion crates/bevy_ecs/src/storage/blob_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use std::{
ptr::NonNull,
};

/// A flat, type-erased data storage type
///
/// Used to densely store homogeneous ECS data.
#[derive(Debug)]
pub struct BlobVec {
item_layout: Layout,
Expand Down Expand Up @@ -122,7 +125,7 @@ impl BlobVec {
self.len = old_len;
}

/// increases the length by one (and grows the vec if needed) with uninitialized memory and
/// Increases the length by one (and grows the vec if needed) with uninitialized memory and
/// returns the index
///
/// # Safety
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_ecs/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub use blob_vec::*;
pub use sparse_set::*;
pub use table::*;

/// The raw data stores of a [World](crate::world::World)
#[derive(Default)]
pub struct Storages {
pub sparse_sets: SparseSets,
Expand Down
9 changes: 9 additions & 0 deletions crates/bevy_ecs/src/storage/sparse_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ impl<I: SparseSetIndex, V> SparseArray<I, V> {
}
}

/// A sparse data structure of [Components](crate::component::Component)
///
/// Designed for relatively fast insertions and deletions.
#[derive(Debug)]
pub struct ComponentSparseSet {
dense: BlobVec,
Expand Down Expand Up @@ -228,6 +231,9 @@ impl ComponentSparseSet {
}
}

/// A data structure that blends dense and sparse storage
///
/// `I` is the type of the indices, while `V` is the type of data stored in the dense storage.
#[derive(Debug)]
pub struct SparseSet<I, V: 'static> {
dense: Vec<V>,
Expand Down Expand Up @@ -391,6 +397,9 @@ macro_rules! impl_sparse_set_index {

impl_sparse_set_index!(u8, u16, u32, u64, usize);

/// A collection of [ComponentSparseSet] storages, indexed by [ComponentId]
///
/// Can be accessed via [Storages](crate::storage::Storages)
#[derive(Default)]
pub struct SparseSets {
sets: SparseSet<ComponentId, ComponentSparseSet>,
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_ecs/src/storage/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ impl Table {
}
}

/// A collection of [Table] storages, indexed by [TableId]
///
/// Can be accessed via [Storages](crate::storage::Storages)
pub struct Tables {
tables: Vec<Table>,
table_ids: HashMap<u64, TableId>,
Expand Down