From 9e076db1fea6c91a7318cae5fa6f4e12b096e716 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich <43751992+amzn-jillich@users.noreply.github.com> Date: Fri, 19 Nov 2021 14:48:10 +0100 Subject: [PATCH] [EMotion FX] In-place option isn't working correctly (#5743) The in-place option for the simple motion component, the motion anim graph node as well as in the motion window were not working in case the motion extraction node was not the root joint. The convention is to keep the motion extraction joint the root joint to make it work correctly - the isolated issue can be solved by only evaluating the motion extraction joint animation in case in-place is disabled and replace the is root joint check with one that checks if we are actually dealing with the motion extraction joint. Resolves #5636 Signed-off-by: Benjamin Jillich --- .../EMotionFX/Source/MotionData/NonUniformMotionData.cpp | 6 ++---- .../Code/EMotionFX/Source/MotionData/UniformMotionData.cpp | 6 ++---- Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp index 6ced6152e1..50f3a1f73f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/NonUniformMotionData.cpp @@ -78,7 +78,6 @@ namespace EMotionFX { const Actor* actor = settings.m_actorInstance->GetActor(); const MotionLinkData* motionLinkData = FindMotionLinkData(actor); - const Skeleton* skeleton = actor->GetSkeleton(); const size_t jointDataIndex = motionLinkData->GetJointDataLinks()[jointSkeletonIndex]; if (m_additive && jointDataIndex == InvalidIndex) @@ -88,7 +87,7 @@ namespace EMotionFX // Sample the interpolated data. Transform result; - const bool inPlace = (settings.m_inPlace && skeleton->GetNode(jointSkeletonIndex)->GetIsRootNode()); + const bool inPlace = (settings.m_inPlace && jointSkeletonIndex == actor->GetMotionExtractionNodeIndex()); if (jointDataIndex != InvalidIndex && !inPlace) { const JointData& jointData = m_jointData[jointDataIndex]; @@ -139,14 +138,13 @@ namespace EMotionFX const MotionLinkData* motionLinkData = FindMotionLinkData(actor); const ActorInstance* actorInstance = settings.m_actorInstance; - const Skeleton* skeleton = actor->GetSkeleton(); const Pose* bindPose = actorInstance->GetTransformData()->GetBindPose(); const size_t numNodes = actorInstance->GetNumEnabledNodes(); for (size_t i = 0; i < numNodes; ++i) { const uint16 jointIndex = actorInstance->GetEnabledNode(i); const size_t jointDataIndex = motionLinkData->GetJointDataLinks()[jointIndex]; - const bool inPlace = (settings.m_inPlace && skeleton->GetNode(jointIndex)->GetIsRootNode()); + const bool inPlace = (settings.m_inPlace && jointIndex == actor->GetMotionExtractionNodeIndex()); // Sample the interpolated data. Transform result; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/UniformMotionData.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/UniformMotionData.cpp index c4451ff902..881604c7ff 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/UniformMotionData.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/MotionData/UniformMotionData.cpp @@ -147,8 +147,7 @@ namespace EMotionFX size_t indexB; CalculateInterpolationIndicesUniform(settings.m_sampleTime, m_sampleSpacing, m_duration, m_numSamples, indexA, indexB, t); - const Skeleton* skeleton = actor->GetSkeleton(); - const bool inPlace = (settings.m_inPlace && skeleton->GetNode(jointSkeletonIndex)->GetIsRootNode()); + const bool inPlace = (settings.m_inPlace && jointSkeletonIndex == actor->GetMotionExtractionNodeIndex()); // Sample the interpolated data. Transform result; @@ -210,13 +209,12 @@ namespace EMotionFX const AZStd::vector& jointLinks = motionLinkData->GetJointDataLinks(); const ActorInstance* actorInstance = settings.m_actorInstance; - const Skeleton* skeleton = actor->GetSkeleton(); const Pose* bindPose = actorInstance->GetTransformData()->GetBindPose(); const size_t numNodes = actorInstance->GetNumEnabledNodes(); for (size_t i = 0; i < numNodes; ++i) { const size_t skeletonJointIndex = actorInstance->GetEnabledNode(i); - const bool inPlace = (settings.m_inPlace && skeleton->GetNode(skeletonJointIndex)->GetIsRootNode()); + const bool inPlace = (settings.m_inPlace && skeletonJointIndex == actor->GetMotionExtractionNodeIndex()); // Sample the interpolated data. Transform result; diff --git a/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp b/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp index a377495d6c..efff992564 100644 --- a/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp @@ -161,6 +161,8 @@ namespace EMotionFX // Make sure all nodes exist. ASSERT_TRUE(rootNode && pelvisNode && lHandNode && lLoArmNode && lLoLegNode && lAnkleNode && rHandNode && rLoArmNode && rLoLegNode && rAnkleNode) << "All nodes used should exist."; + + m_actor->SetMotionExtractionNodeIndex(m_jackRootIndex); } void SetupMirrorNodes()