M3: Hierarchy panel — click a GameObject to select it

HierarchyPanel walks IWorld.Roots/GameObject.Children recursively as
ImGui tree nodes, clicking one sets EditorState.Selected — the shared
selection the not-yet-built Inspector panel will read from the same
instance. PushID(go.GetHashCode()) scopes each node's ID by object
identity rather than name, since nothing stops two sibling GameObjects
sharing a Name and ImGui's default label-based IDs would otherwise merge
their open/selected state.

Also gives samples/WindowDemo/scene.json a child GameObject (offset,
half-scale, parented under Quad) — the existing scene only had one root,
nothing to show a tree with. Verified by screenshot: both quads render at
their correct composed WorldMatrix (the child visibly smaller and offset,
confirming parent/child composition is still correct through this
change), and Hierarchy lists "Quad" as a collapsible node.

Full suite still green: 65 tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
This commit is contained in:
Emil
2026-09-02 16:19:36 +03:00
co-authored by Claude Sonnet 5
parent 4c67c2c905
commit bccb8c3ba7
4 changed files with 87 additions and 6 deletions
@@ -19,14 +19,15 @@ namespace Engine.Editor;
/// split exists at all.
///
/// Nothing here reads or writes a Component through GetComponent/Query —
/// the Hierarchy and Inspector panels (not built yet) will walk
/// IWorld.Roots and GameObject.Components directly instead, which is why
/// this plugin never needs to declare Reads/Writes on its system: those
/// checks only guard the typed accessors, not plain property reads. See
/// GameObject.AddComponent's own doc comment on the same gap.
/// HierarchyPanel walks IWorld.Roots/GameObject.Children directly, and the
/// not-yet-built Inspector will walk GameObject.Components the same way —
/// which is why this plugin never needs to declare Reads/Writes on its
/// system: those checks only guard the typed accessors, not plain property
/// reads. See GameObject.AddComponent's own doc comment on the same gap.
/// </summary>
public sealed class EditorPlugin : IPlugin
{
private readonly EditorState _state = new();
private GL? _gl;
private ImGuiController? _controller;
private ITime? _time;
@@ -64,6 +65,8 @@ public sealed class EditorPlugin : IPlugin
ImGui.Text($"Frame: {_time.FrameCount}");
ImGui.End();
HierarchyPanel.Draw(world, _state);
_controller.Render();
}
}