From ab51ca6e705e8110db9e14e7e40f7e16bf8c93c3 Mon Sep 17 00:00:00 2001 From: Menotdan <32620310+Menotdan@users.noreply.github.com> Date: Mon, 1 Jan 2024 21:35:18 -0500 Subject: [PATCH] Change behavior when Use Local Origin is checked. --- .../Engine/ContentImporters/ImportModel.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/Engine/ContentImporters/ImportModel.cpp b/Source/Engine/ContentImporters/ImportModel.cpp index ac2bacd25..a2629baf4 100644 --- a/Source/Engine/ContentImporters/ImportModel.cpp +++ b/Source/Engine/ContentImporters/ImportModel.cpp @@ -666,11 +666,20 @@ CreateAssetResult ImportModel::CreatePrefab(CreateAssetContext& context, ModelDa nodeToActor.Add(nodeIndex, nodeActor); nodeActor->SetName(node.Name); - Transform positionOffset = Transform::Identity; - positionOffset.Translation = node.LocalTransform.Translation; - LOG(Warning, "node name: {0}, offset transform: {1}", node.Name, positionOffset); - // Only set translation, since scale and rotation is applied earlier. - nodeActor->SetLocalTransform(positionOffset); + // When use local origin is checked, it shifts everything over the same amount, including the root. This tries to work around that. + if (!(nodeIndex == 0 && options.UseLocalOrigin)) + { + // Only set translation, since scale and rotation is applied earlier. + Transform positionOffset = Transform::Identity; + positionOffset.Translation = node.LocalTransform.Translation; + if (options.UseLocalOrigin) + { + positionOffset.Translation += data.Nodes[0].LocalTransform.Translation; + } + + nodeActor->SetLocalTransform(positionOffset); + } + if (nodeIndex == 0) { // Special case for root actor to link any unlinked nodes