|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Type-erased base class for sparse set operations. More...
#include <SparseSet.hpp>

Classes | |
| struct | AuditCopy |
What the audit kept of a pool: its entities and their components' bytes, as they were at tick. More... | |
Public Member Functions | |
| virtual | ~SparseSetBase ()=default |
| Virtual destructor for proper cleanup. | |
| virtual bool | contains (Entity entity) const =0 |
| Checks if an entity exists in the set. | |
| virtual void | remove (Entity entity)=0 |
| Removes an entity's component from the set. | |
| virtual usize | size () const =0 |
| Gets the number of components in the set. | |
| virtual bool | empty () const =0 |
| Checks if the set is empty. | |
| virtual void | clear ()=0 |
| Removes all components from the set. | |
| virtual const std::vector< Entity > & | entities () const =0 |
| Gets the dense entity array for iteration. | |
| virtual u32 | version () const =0 |
| Monotonic version, bumped whenever stored components may have moved in memory (buffer reallocation on growth, or swap-and-pop relocation on removal). | |
| virtual void | reorderBy (const std::vector< u32 > &rank)=0 |
Permutes storage so iteration follows rank. | |
| virtual u32 | changedTickOf (Entity entity) const =0 |
The tick of entity's last write here, 0 where it has no component: the type-erased changedTick. | |
| virtual void | markChanged (Entity entity, u32 tick)=0 |
Stamps entity's component as written at tick (no-op where it has none): the type-erased markChanged. | |
| virtual u32 | lastChangedTick () const =0 |
| The tick of the last write to any component of this pool, or of the last add or remove: "anything since?" in O(1). | |
| virtual void | noteStructural (u32 tick)=0 |
Notes an add or a remove at tick, which no stamp of a component that is still there records. | |
| virtual void | clampStamps (u32 floor)=0 |
Lifts every stamp older than floor to it, so a stamp never reads as newer after the tick wraps. | |
| virtual std::string_view | typeName () const =0 |
| The component type's name, for what the audit says. | |
| virtual bool | auditable () const =0 |
| Whether this pool's components can be audited (see above). | |
| virtual void | auditKeep (AuditCopy ©, u32 tick) const =0 |
Keeps the pool's state as it is at tick. | |
| virtual u32 | auditCompare (const AuditCopy ©, void(*report)(void *user, Entity entity), void *user) const =0 |
Calls report for each entity whose component changed since copy without a stamp after copy.tick. | |
Static Public Member Functions | |
| static std::vector< usize > | stablePermutation (const std::vector< Entity > &dense, const std::vector< u32 > &rank) |
| Which current slot belongs at each position when dense is put in rank order (stable). | |
Static Public Attributes | |
| static constexpr u32 | UNRANKED = 0xFFFFFFFFu |
| Rank for an entity the caller did not order — sorts last, stably. | |
Type-erased base class for sparse set operations.
Provides a common interface for type-erased operations on component pools. Used by Registry to manage pools of different component types uniformly.
Definition at line 51 of file SparseSet.hpp.
|
virtualdefault |
Virtual destructor for proper cleanup.
|
pure virtual |
Whether this pool's components can be audited (see above).
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Calls report for each entity whose component changed since copy without a stamp after copy.tick.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Keeps the pool's state as it is at tick.
Implemented in esengine::ecs::SparseSet< T >.
The tick of entity's last write here, 0 where it has no component: the type-erased changedTick.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Lifts every stamp older than floor to it, so a stamp never reads as newer after the tick wraps.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Removes all components from the set.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Checks if an entity exists in the set.
| entity | The entity to check |
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Checks if the set is empty.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Gets the dense entity array for iteration.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
The tick of the last write to any component of this pool, or of the last add or remove: "anything since?" in O(1).
Implemented in esengine::ecs::SparseSet< T >.
Stamps entity's component as written at tick (no-op where it has none): the type-erased markChanged.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Notes an add or a remove at tick, which no stamp of a component that is still there records.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Removes an entity's component from the set.
| entity | The entity whose component to remove |
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Permutes storage so iteration follows rank.
| rank | Rank per ENTITY INDEX (Entity::index()); lower ranks iterate first |
Storage order is iteration order, and iteration order is the renderer's within-layer painter order, so this is how a scene's authored entity order reaches the draw list without respawning anything. Entities with no rank (index past the end, or the UNRANKED sentinel) keep their relative order after the ranked ones — the sort is stable. A no-op reorder leaves storage (and therefore every handed-out component pointer) untouched.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Gets the number of components in the set.
Implemented in esengine::ecs::SparseSet< T >.
|
inlinestatic |
Which current slot belongs at each position when dense is put in rank order (stable).
Not a member of the template: the sort does not depend on the component type, and a copy of std::stable_sort and its merge helpers for each of the hundred-odd component types was 227KB of the engine's wasm — over a tenth of its code. Entities with no rank sort after the ranked ones, in their present order.
Definition at line 166 of file SparseSet.hpp.
References UNRANKED.
Referenced by esengine::ecs::SparseSet< T >::reorderBy().
|
pure virtual |
The component type's name, for what the audit says.
Implemented in esengine::ecs::SparseSet< T >.
|
pure virtual |
Monotonic version, bumped whenever stored components may have moved in memory (buffer reallocation on growth, or swap-and-pop relocation on removal).
Single source of truth for the cross-boundary pointer-staleness guard: a raw component pointer handed to JS (e.g. getTransformPtr) is only valid while this value is unchanged. Replaces the old SchemaComponentPool::poolVersion (which lived in a now-deleted parallel store and, notably, was not bumped on remove).
Implemented in esengine::ecs::SparseSet< T >.
|
staticconstexpr |
Rank for an entity the caller did not order — sorts last, stably.
Definition at line 119 of file SparseSet.hpp.
Referenced by esengine::ecs::Registry::buildEntityRank(), and stablePermutation().