[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 <jillich@amazon.com>
This commit is contained in:
Benjamin Jillich
2021-11-19 14:48:10 +01:00
committed by GitHub
parent e804fd2a42
commit 9e076db1fe
3 changed files with 6 additions and 8 deletions
@@ -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;
@@ -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<size_t>& 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;
@@ -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()