Skip to content

Commit

Permalink
Tweaked: Archetypes keep their index in the list for fast lookup duri…
Browse files Browse the repository at this point in the history
…ng removals

Tweaked: Cleanup of core component registration
  • Loading branch information
richardbiely committed Mar 7, 2024
1 parent ac198f4 commit 0d3a770
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 386 deletions.
13 changes: 12 additions & 1 deletion include/gaia/ecs/archetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ namespace gaia {
//! Number of ticks before empty chunks are removed
static constexpr uint16_t MAX_ARCHETYPE_LIFESPAN = (1 << ARCHETYPE_LIFESPAN_BITS) - 1;

//! Archetype list index
uint32_t m_listIdx;

//! Delete requested
uint32_t m_deleteReq : 1;
//! Remaining lifespan of the archetype
Expand All @@ -138,7 +141,7 @@ namespace gaia {

//! Constructor is hidden. Create archetypes via Archetype::Create
Archetype(const ComponentCache& cc, uint32_t& worldVersion):
m_cc(cc), m_worldVersion(worldVersion),
m_cc(cc), m_worldVersion(worldVersion), m_listIdx(BadIndex),
//
m_deleteReq(0), m_lifespanCountdown(0), m_dead(0), m_pairCnt(0), m_pairCnt_is(0) {}

Expand Down Expand Up @@ -260,6 +263,14 @@ namespace gaia {
Chunk::free(pChunk);
}

void list_idx(uint32_t idx) {
m_listIdx = idx;
}

uint32_t list_idx() const {
return m_listIdx;
}

GAIA_NODISCARD bool cmp_comps(const ArchetypeLookupChecker& other) const {
return ecs::cmp_comps({m_ids.data(), m_ids.size()}, other.m_comps);
}
Expand Down
5 changes: 3 additions & 2 deletions include/gaia/ecs/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ namespace gaia {
struct Acyclic_ {};
struct All_ {};
struct ChildOf_ {};
struct AliasOf_ {};
struct Is_ {};

//----------------------------------------------------------------------
// Core component entities
Expand All @@ -473,7 +473,8 @@ namespace gaia {
inline Entity Acyclic = Entity(10, false, false, false, EntityKind::EK_Gen);
//! Wildcard query entity
inline Entity All = Entity(11, 0, false, false, EntityKind::EK_Gen);
//! Entity representing a physical hierarchy
//! Entity representing a physical hierarchy.
//! When the relationship target is deleted all children are deleted as well.
inline Entity ChildOf = Entity(12, 0, false, false, EntityKind::EK_Gen);
//! Alias for a base entity
inline Entity Is = Entity(13, 0, false, false, EntityKind::EK_Gen);
Expand Down
Loading

0 comments on commit 0d3a770

Please sign in to comment.