![]() |
ImagoEngine
A C++ 2D game engine built on a sparse-set ECS, with scenes, scheduled systems, events, and action-based input
|
Defines the Entity alias and the free functions used to pack and unpack it. More...
#include <cstdint>#include <cassert>

Go to the source code of this file.
Typedefs | |
| using | Imago::ECS::Entity = uint32_t |
| A packed identifier: 20 bits of index, 12 bits of generation. | |
Functions | |
| constexpr uint32_t | Imago::ECS::get_entity_index (Entity entity) |
| Extracts the index bits from a packed Entity. | |
| constexpr uint32_t | Imago::ECS::get_entity_generation (Entity entity) |
| Extracts the generation bits from a packed Entity. | |
| constexpr Entity | Imago::ECS::make_entity (uint32_t index, uint32_t generation) |
| Packs an index and generation into a single Entity. | |
Variables | |
| constexpr uint32_t | Imago::ECS::ENTITY_INDEX_BITS = 20 |
| Number of bits allocated to an Entity's index. | |
| constexpr uint32_t | Imago::ECS::ENTITY_GENERATION_BITS = 12 |
| Number of bits allocated to an Entity's generation. | |
| constexpr uint32_t | Imago::ECS::ENTITY_INDEX_MASK = (1u << ENTITY_INDEX_BITS) - 1 |
| Mask isolating the low 20 index bits of a packed Entity. | |
| constexpr uint32_t | Imago::ECS::ENTITY_GENERATION_MASK = (1u << ENTITY_GENERATION_BITS) -1 |
| Mask isolating the low 12 bits of a right shifted generation value. | |
| constexpr Entity | Imago::ECS::NULL_ENTITY = 0xFFFFFFFFu |
| Sentinel value representing "no entity". | |
Defines the Entity alias and the free functions used to pack and unpack it.
An Entity is a lightweight identifier, a single packed uint32_t containing both an index (which slot this entity occupies), and a generation (how many times that slot has been destroyed and recreated). Entities carry no data and no behavior; they are pure IDs used to look up components in component pools.
|
constexpr |
Extracts the generation bits from a packed Entity.
| entity | The packed Entity to decode. |
|
constexpr |
Extracts the index bits from a packed Entity.
| entity | The packed Entity to decode. |
|
constexpr |
Packs an index and generation into a single Entity.
| index | Index value. |
| generation | Generation value. |
|
constexpr |
Sentinel value representing "no entity".
Decodes to index == ENTITY_INDEX_MASK and generation == ENTITY_GENERATION_MASK, a bit pattern EntityManager never hands out as a real, live Entity.