15#include <unordered_map>
31 struct Task {
Entity entity;
u32 cullBit; };
32 std::vector<Task> pending{{entity, cullBit}};
33 std::vector<u8> visited;
34 while (!pending.empty()) {
35 const auto task = pending.back();
38 if (!registry.
valid(entity))
continue;
39 const auto index = entity.
index();
40 if (index >= visited.size()) visited.resize(index + 1, 0);
41 if (visited[index])
continue;
44 const u32 inheritedBit = canvas
45 ? ((canvas->layer < 0 || canvas->layer >= 32) ? 0u : (1u << canvas->layer))
50 uiVisual->uiOrder = counter;
51 uiVisual->uiCullBit = inheritedBit;
53 }
else if (registry.
has<
Sprite>(entity)) {
54 auto& sprite = registry.
get<
Sprite>(entity);
55 if (sprite.layer != counter) {
56 sprite.layer = counter;
64 tree->layers[entity.
id()] = tree->base + counter;
68 if (!children)
continue;
69 for (
auto child = children->entities.rbegin(); child != children->entities.rend(); ++child)
70 pending.push_back({*child, inheritedBit});
76 if (tree) tree->layers.clear();
79 const auto& canvas = registry.
get<
Canvas>(entity);
80 const u32 bit = (canvas.layer < 0 || canvas.layer >= 32) ? 0u : (1u << canvas.layer);
Canvas component for 2D game resolution management.
Hierarchy components for parent-child relationships.
Central ECS registry for entity and component management.
Spine skeletal animation component.
2D sprite rendering component
Central container for all entities and components.
T & get(Entity entity)
Gets a component from an entity (must exist).
bool has(Entity entity) const
Checks if an entity has a specific component.
bool valid(Entity entity) const
Checks if an entity is currently valid.
T * tryGet(Entity entity)
Tries to get a component from an entity.
void uiRenderOrderUpdate(Registry ®istry, UITreeOrder *tree=nullptr)
std::vector< Entity > canvasRoots(Registry ®istry, bool layoutOnly)
i32 assignRenderOrder(Registry ®istry, Entity entity, i32 counter, u32 cullBit, UITreeOrder *tree=nullptr)
std::int32_t i32
Signed 32-bit integer.
std::uint32_t u32
Unsigned 32-bit integer.
Entity identifier with packed index + generation.
constexpr u32 id() const
Returns the raw packed value for FFI serialization.
constexpr u32 index() const
Gets the entity index.
Canvas component for 2D game resolution management.
Spine skeletal animation component.
UINode — the CSS box-model layout input (the CSS/Flex primary layout model).
The draw layer of what a Canvas holds that has no uiOrder of its own: an emitter, a Spine skeleton,...
std::unordered_map< u32, i32 > layers
UIVisual — the single UI visual component, merging the former low-level UIRenderer (what the renderer...