Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
PackedId.hpp File Reference

Single source of truth for index+generation bit-packing. More...

#include <cstdint>
Include dependency graph for PackedId.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esengine::PackedId< IndexBits, GenBits >
 Index+generation packing into a u32, parameterized by the bit split. More...

Namespaces

namespace  esengine

Detailed Description

Single source of truth for index+generation bit-packing.

Both the ECS esengine::Entity and the resource esengine::resource::Handle pack a slot index plus a reuse generation into one integer. They used to each copy-paste the masks/shifts (three independent packings drifted apart — see the RC re-architecture's "multiple sources of truth" root cause). This template is the one definition both delegate to; the bit split is a parameter.

The u32 storage is deliberate and structurally enforced by the static_assert below: a packed id must fit in 32 bits so that

  • Entity stays 4 bytes (cache-friendly ECS dense arrays, cheap FFI),
  • the value is a JS safe integer (< 2^53) and crosses embind as a plain number,
  • it fits box2d's 32-bit wasm32 body user-data. Widening to a 64-bit id is therefore a deliberate, ABI-versioned change, not something a bit-split tweak can do by accident.
Author
ESEngine Team
Date
2026

Definition in file PackedId.hpp.