Module rin::ecs::storage [−][src]
Different storage types used internally to store entities components
By default a component will be stored in a DenseVec
but one can
specify different storage types by using the storage attribute when
deriving Component
#[derive(Component, Debug)] #[storage(VecStorage)] struct Position{ x: f32, y : f32 }
The default storage type, DenseVec
, stores components contiguously using
an index to map entity id to position in a vector. It needs 2 memory reads
to access an element but minimizes memory use in case the component is not
used by most entities.
For components where almost every entity has them, a VecStorage
can be
faster since it doesn’t have an index. A VecStorage
is just a Vec of the
component where the position in the vector is the same as the entity id.
Hierarchical components always use a Forest
storage which is a tree
like structure implemented on a Vec
to maximize memory contiguity.
One to N components, or slice components are always stored in DenseOneToNVec
,
a storage that stores slices contiguosly in memory using a Vec plus an
index to know the range that belongs to each Entity. Right now adding new
elements to already created structures of this type can be really slow so
in those cases you might want to just use a custom component that contains a
collection instead.
Modules
autochanged | |
changed | |
dense_vec | |
forest | |
oneton_densevec | |
tags | |
unique_densevec | |
vec |
Structs
AutoChanged | |
Changed | |
CreationSto | |
Forest | |
HiddenFastIndex | |
MaskedStorage | |
OneToNForest | |
OrderedId | |
SliceView | |
SliceViewMut | |
SubStorages | |
Tags | |
UniqueDenseVec | |
VecStorage |
Traits
Type Definitions
AutoChangedDenseVec | |
AutoChangedForest | |
AutoChangedOneToN | |
AutoChangedVec | |
ChangeDenseOneToNVec | |
ChangedDenseVec | |
ChangedForest | |
ChangedOneToN | |
ChangedVec | |
DenseOneToNVec | |
DenseVec |