feat: parent-child transform hierarchy (UE Actor attach semantics)

- TransformComponent TRS = local (relative to parent); cached world SRT
  composed hierarchically (parent pos/rot/scale, no matrix decomposition
  shear under non-uniform parent scale)
- HierarchyComponent (parent + children, lazily attached); Scene::
  SetParent (keepWorld, cycle-safe) / GetParent / IsDescendantOf /
  SetWorldPose (world->local inverse, used by physics writeback & gizmo)
- UpdateTransforms: DFS from roots, recompose only dirty-or-dirty-
  ancestor subtrees (parents before children)
- DestroyEntity: descendants buried with parent (UE cascade)
- Serialization v2: optional Parent uuid key, two-pass relink on load
- Hierarchy panel: tree view, drag-drop reparent / drop-to-root detach,
  Create Child / Detach context menu; Inspector shows parent name
- Consumers moved to world-space reads: lights, camera pos, physics
  bodies/characters/joints/collider baking, gizmo, F-focus, AlignTo
This commit is contained in:
2026-10-04 15:22:25 +08:00
parent 97408e506c
commit ee5ab8e94e
13 changed files with 550 additions and 135 deletions
+11
View File
@@ -215,6 +215,17 @@ void InspectorPanel::Draw(const EditorContext& ctx, entt::entity selected)
{
if (ComponentHeader("Transform", nullptr, false, nullptr))
{
// 父级提示(UE Details 语义:此处编辑的是 Relative 值)
if (ctx.scene) {
const Engine::ECS::Entity p = ctx.scene->GetParent(selected);
if (p != entt::null) {
std::string pname = "(unnamed)";
if (const auto* n = reg.try_get<Engine::ECS::NameComponent>(p)) {
pname = n->name;
}
ImGui::TextDisabled("parent: %s", pname.c_str());
}
}
glm::vec3 pos = t->GetPosition();
if (DragVec3Row("position", pos, 0.05f))
{