Fix unit test

Signed-off-by: rhhong <rhhong@amazon.com>
This commit is contained in:
rhhong
2021-08-24 11:36:13 -07:00
parent 5369df4195
commit 4767d2a891
31 changed files with 341 additions and 232 deletions
@@ -26,7 +26,7 @@ namespace EMotionFX
public:
void CreateSubMotionLikeBindPose(const std::string& name)
{
const Skeleton* skeleton = m_actor->GetSkeleton();
const Skeleton* skeleton = GetActor()->GetSkeleton();
size_t jointIndex = InvalidIndex;
const Node* node = skeleton->FindNodeAndIndexByName(name.c_str(), jointIndex);
ASSERT_NE(node, nullptr);
@@ -40,7 +40,7 @@ namespace EMotionFX
void CreateSubMotion(const std::string& name, const Transform& transform)
{
// Find and store the joint index.
const Skeleton* skeleton = m_actor->GetSkeleton();
const Skeleton* skeleton = GetActor()->GetSkeleton();
size_t jointIndex = InvalidIndex;
const Node* node = skeleton->FindNodeAndIndexByName(name.c_str(), jointIndex);
ASSERT_NE(node, nullptr);
@@ -55,7 +55,7 @@ namespace EMotionFX
ActorFixture::SetUp();
// Get the joint that isn't in the motion data.
Node* footNode = m_actor->GetSkeleton()->FindNodeAndIndexByName("l_ball", m_footIndex);
Node* footNode = GetActor()->GetSkeleton()->FindNodeAndIndexByName("l_ball", m_footIndex);
ASSERT_NE(footNode, nullptr);
ASSERT_NE(m_footIndex, InvalidIndex32);
@@ -98,7 +98,7 @@ namespace EMotionFX
TEST_F(MotionSamplingFixture, SampleAdditiveJoint)
{
const Skeleton* skeleton = m_actor->GetSkeleton();
const Skeleton* skeleton = GetActor()->GetSkeleton();
// Sample the joints that exist in our actor skeleton as well as inside the motion data.
const Pose* bindPose = m_actorInstance->GetTransformData()->GetBindPose();
@@ -106,7 +106,7 @@ namespace EMotionFX
{
// Sample the motion.
Transform transform = Transform::CreateZero(); // Set all to Zero, not identity as this methods might return identity and we want to verify that.
m_motion->CalcNodeTransform(m_motionInstance, &transform, m_actor.get(), skeleton->GetNode(jointIndex), /*timeValue=*/0.0f, /*enableRetargeting=*/false);
m_motion->CalcNodeTransform(m_motionInstance, &transform, GetActor(), skeleton->GetNode(jointIndex), /*timeValue=*/0.0f, /*enableRetargeting=*/false);
const Transform& bindTransform = bindPose->GetLocalSpaceTransform(jointIndex);
EXPECT_THAT(transform, IsClose(bindTransform));
@@ -114,7 +114,7 @@ namespace EMotionFX
// Sample the motion for the foot node.
Transform footTransform = Transform::CreateZero(); // Set all to Zero, not identity as this methods might return identity and we want to verify that.
m_motion->CalcNodeTransform(m_motionInstance, &footTransform, m_actor.get(), skeleton->GetNode(m_footIndex), /*timeValue=*/0.0f, /*enableRetargeting=*/false);
m_motion->CalcNodeTransform(m_motionInstance, &footTransform, GetActor(), skeleton->GetNode(m_footIndex), /*timeValue=*/0.0f, /*enableRetargeting=*/false);
// Make sure we get an identity transform back as we try to sample a node that doesn't have a submotion in an additive motion.
EXPECT_THAT(footTransform, IsClose(Transform::CreateIdentity()));
@@ -125,7 +125,7 @@ namespace EMotionFX
// Make sure we do not get an identity transform back now that it is a non-additive motion.
footTransform.Zero(); // Set all to Zero, not identity as this methods might return identity and we want to verify that.
const Transform& expectedFootTransform = m_actorInstance->GetTransformData()->GetCurrentPose()->GetLocalSpaceTransform(m_footIndex);
m_motion->CalcNodeTransform(m_motionInstance, &footTransform, m_actor.get(), skeleton->GetNode(m_footIndex), /*timeValue=*/0.0f, /*enableRetargeting=*/false);
m_motion->CalcNodeTransform(m_motionInstance, &footTransform, GetActor(), skeleton->GetNode(m_footIndex), /*timeValue=*/0.0f, /*enableRetargeting=*/false);
EXPECT_THAT(footTransform, IsClose(expectedFootTransform));
}
@@ -134,7 +134,7 @@ namespace EMotionFX
// Sample a pose from the motion.
Pose pose;
pose.LinkToActorInstance(m_actorInstance);
pose.InitFromBindPose(m_actor.get());
pose.InitFromBindPose(GetActor());
pose.Zero();
m_motion->Update(&pose, &pose, m_motionInstance);