Skip to content

[Feature] Scene graph — parent-child hierarchy with propagated world transforms #629

Description

@JeanPhilippeKernel

Type

  • Feature

Overview

The ECS currently has no parent-child hierarchy between entities. Every entity is a root — the Outliner's flat list is a direct consequence. Adding a scene graph unblocks tree-view display in the Outliner, grouped transforms (e.g. a vehicle and its wheels), and instanced prefab attachment.

What's missing

1. ParentComponent and ChildrenComponent

struct ParentComponent   { EntityID Parent = INVALID_ENTITY; };
struct ChildrenComponent { Core::Containers::Array<EntityID> Children; };

Nothing exists today to link entities in a hierarchy.

2. Local vs World transform split

TransformComponent currently stores one transform that is treated as both local and world (valid only because everything is a root). A scene graph needs:

  • TransformComponent — local (relative to parent); what the Inspector edits
  • WorldTransformComponent — computed by the propagation system; what the renderer reads
struct WorldTransformComponent {
    Core::Maths::Mat4f Matrix = {};  // ParentWorld × TRS(local)
};

3. TransformDirtyComponent or dirty flag

Without a dirty flag, all transforms are recomputed every frame. A bool Dirty = true on TransformComponent (or a zero-size tag component) allows the propagation system to skip unchanged subtrees.

4. Transform propagation WorldTick system

A system that walks the hierarchy in depth order and writes WorldTransformComponent:

Pass 1 — roots (no ParentComponent): WorldMatrix = TRS(local)
Pass 2 — depth-1 children:           WorldMatrix = Parent.WorldMatrix × TRS(local)
Pass N — repeat until no dirty flags remain

Topological sort or multi-pass with dirty flags; multi-pass is simpler to start.

5. Outliner tree view

Once ParentComponent exists, HierarchyViewUIComponent can render a tree (ImGui TreeNode) instead of a flat list. Drag-to-reparent becomes a context-menu or drag-drop operation.

Acceptance criteria

  • ParentComponent and ChildrenComponent defined
  • WorldTransformComponent defined; TransformComponent explicitly documented as local-only
  • TransformPropagationSystem registered in WorldTick; world transforms correct for 3+ levels of nesting
  • WorldTransformComponent is what FillRenderableTransforms and the render bridge read (not TransformComponent)
  • Outliner renders a tree (indented children, collapse/expand toggle)
  • Reparent via Outliner drag-drop or context menu
  • All ECS and scheduler tests pass

Depends on

Estimated effort

3–4 days

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions