Skip to content

Engine → Scene → hierarchy.h

hierarchy

Syntax

class CONJURE_API hierarchy

Constructors

AccessSignatureDescription
publichierarchy( ecs::world &world, const scene_component_ids &ids) noexcept;
publichierarchy( const hierarchy &) = default;

Destructors

AccessSignatureDescription
public~hierarchy();

Variables

AccessNameTypeDefaultDescription
privatemIdsconst scene_component_ids *nullptr
privatemWorldecs::world *nullptr

Functions

Public

children_of

[[nodiscard]] std::span<const ecs::entity> children_of(
    ecs::entity target) const noexcept;

The children in sibling order; empty for leaves and dead entities. The span is valid until the next structural change.

collect_subtree

void collect_subtree(
    ecs::entity target,
    std::vector<ecs::entity> &out) const;

Appends the entity and every descendant to out, depth first in sibling order.

depth_of

[[nodiscard]] u8 depth_of(
    ecs::entity target) const noexcept;

Hierarchy depth from the depth tag: 0 for roots and dead entities.

for_each_in_subtree

template <typename Callable> void for_each_in_subtree(
    ecs::entity target,
    Callable &&callable) const;

Invokes callable(entity) for the entity and every descendant, depth first in sibling order, with an explicit stack (never recursive). Nothing happens for a dead entity.

ids

[[nodiscard]] const scene_component_ids &ids() const noexcept;

The component ids the tree reads.

is_alive

[[nodiscard]] bool is_alive(
    ecs::entity target) const noexcept;

True when the entity is alive in the world.

is_ancestor_of

[[nodiscard]] bool is_ancestor_of(
    ecs::entity ancestor,
    ecs::entity target) const noexcept;

True when ancestor is a strict ancestor of target.

parent_of

[[nodiscard]] ecs::entity parent_of(
    ecs::entity target) const noexcept;

The parent entity; NULL_ENTITY for roots and dead entities.

root_of

[[nodiscard]] ecs::entity root_of(
    ecs::entity target) const noexcept;

The topmost ancestor (the entity itself for a root); NULL_ENTITY for a dead entity.

sibling_index

[[nodiscard]] u32 sibling_index(
    ecs::entity target) const noexcept;

Position among the parent's children; 0 for roots (their order is scene::roots()) and for dead entities.

subtree_height

[[nodiscard]] u8 subtree_height(
    ecs::entity target) const noexcept;

Number of levels below the entity: 0 for a leaf, 1 when it has children without grandchildren, and so on. 0 for a dead entity.

subtree_size

[[nodiscard]] u32 subtree_size(
    ecs::entity target) const noexcept;

Number of entities in the subtree, the entity included; 0 for a dead entity.

world

[[nodiscard]] ecs::world &world() const noexcept;

The world the tree lives in.

Operator Overloads

Public

operator=

hierarchy &operator=(
    const hierarchy &) = default;