feat(ecs/editor): scene graph — local transforms, HierarchySystem, UE5-style outliner - #673
Merged
Merged
Conversation
TransformComponent: Position/Rotation/Scale become local-space. WorldTransform (Mat4f) added as a computed field — never user-edited. ParentComponent: new, EntityID Parent field. Entities without it are roots. HierarchySystem::SyncHierarchy(Scene&): Pass 1 — roots: WorldTransform = ComposeTransformMatrix(local) Pass 2+ — children: WorldTransform = parent.World × local_mat Repeats until stable for arbitrary hierarchy depth. Runs in Engine::MainThreadRun before SyncECSToRenderScene. TransformSyncSystem: uses tc.WorldTransform directly. LightSyncSystem: direction from WorldTransform col 2, position from col 3. Gizmo: reads WorldTransform, decomposes result to local (with parent inverse). Closes #629 EOF )
…xpand/collapse - Rewrite HierarchyViewUIComponent to match UE5 Outliner layout: custom ImDrawList rendering (no TreeNodeEx), per-type icons drawn with AddTriangleFilled/AddCircle/AddRectFilled, Item Label / Type columns, filter bar, status bar actor count. - O(n) DFS using first_child/next_sib linked-list arrays built in one pass from ParentComponent; stack allocated on scratch arena; no std::vector, no std::function, no recursion. - Fix expand/collapse never re-expanding: scene root was using INVALID_ENTITY as its collapse key and as the removal sentinel in m_collapsed — toggling it replaced the value with itself so IsCollapsed always returned true. Replace with a dedicated m_scene_root_collapsed bool. - RenderGuizmo reads WorldTransform for gizmo position and decomposes back to local space when the actor has a parent (parent-inverse multiply), writing local Position/Rotation/Scale.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TransformComponent.Position/Rotation/Scaleare now local-space values. A newWorldTransform(Mat4f) field is computed each frame byHierarchySystemand consumed byTransformSyncSystemandLightSyncSystem. A newParentComponentrecords the parentEntityID.WorldTransform = local, children getparent.WorldTransform × local; iterates until stable to handle arbitrary nesting depth.HierarchyViewUIComponent— O(n) DFS using first_child/next_sib linked-list arrays on a scratch arena, customImDrawListrendering (noTreeNodeEx), per-type icons (World, Collection, Light, Camera, StaticMesh), Item Label / Type / Level columns, filter bar, status bar, folder+ button.INVALID_ENTITYas its collapse key and as the removal sentinel — replaced with a dedicatedbool m_scene_root_collapsed.WorldTransformfor position; decomposes back to local space via parent-inverse multiply when actor has a parent.Files changed
ZEngine/ZEngine/ECS/Components/TransformComponent.hMat4f WorldTransform; Position/Rotation/Scale are now localZEngine/ZEngine/ECS/Components/ParentComponent.hEntityID ParentZEngine/ZEngine/ECS/Systems/HierarchySystem.h/.cppSyncHierarchy(Scene&)ZEngine/ZEngine/Engine.cppSyncHierarchybefore other sync systemsZEngine/ZEngine/ECS/Systems/TransformSyncSystem.cpptc.WorldTransformZEngine/ZEngine/ECS/Systems/LightSyncSystem.cppWorldTransformTetragrama/Components/HierarchyViewUIComponent.h/.cppTest plan