@@ -69,6 +69,11 @@ namespace CommandSystem
|
||||
AZ::Data::AssetId actorAssetId;
|
||||
EBUS_EVENT_RESULT(
|
||||
actorAssetId, AZ::Data::AssetCatalogRequestBus, GetAssetIdByPath, filename.c_str(), AZ::Data::s_invalidAssetType, false);
|
||||
if (!actorAssetId.IsValid())
|
||||
{
|
||||
outResult = AZStd::string::format("Cannot import actor. Cannot find asset at path %s.", filename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if we have already loaded the actor
|
||||
const size_t actorIndex = EMotionFX::GetActorManager().FindActorIndex(actorAssetId);
|
||||
|
||||
@@ -10,12 +10,15 @@
|
||||
#include <MCore/Source/ReflectionSerializer.h>
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/ActorInstance.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
#include <EMotionFX/Source/Importer/Importer.h>
|
||||
#include <EMotionFX/Source/EMotionFXManager.h>
|
||||
#include <EMotionFX/Source/SimulatedObjectSetup.h>
|
||||
|
||||
#include <Tests/TestAssetCode/JackActor.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
@@ -23,8 +26,9 @@ namespace EMotionFX
|
||||
{
|
||||
SystemComponentFixture::SetUp();
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<JackNoMeshesActor>();
|
||||
m_actorInstance = ActorInstance::Create(m_actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<JackNoMeshesActor>(actorAssetId);
|
||||
m_actorInstance = ActorInstance::Create(m_actorAsset->GetActor());
|
||||
}
|
||||
|
||||
void ActorFixture::TearDown()
|
||||
@@ -35,6 +39,7 @@ namespace EMotionFX
|
||||
m_actorInstance = nullptr;
|
||||
}
|
||||
|
||||
GetEMotionFX().GetActorManager()->UnregisterAllActors();
|
||||
SystemComponentFixture::TearDown();
|
||||
}
|
||||
|
||||
@@ -71,7 +76,7 @@ namespace EMotionFX
|
||||
|
||||
AZ::ObjectStream::FilterDescriptor loadFilter(nullptr, AZ::ObjectStream::FILTERFLAG_IGNORE_UNKNOWN_CLASSES);
|
||||
SimulatedObjectSetup* setup = AZ::Utils::LoadObjectFromBuffer<EMotionFX::SimulatedObjectSetup>(data.data(), data.size(), serializeContext, loadFilter);
|
||||
setup->InitAfterLoad(m_actor.get());
|
||||
setup->InitAfterLoad(m_actorAsset->GetActor());
|
||||
return setup;
|
||||
}
|
||||
|
||||
@@ -80,4 +85,10 @@ namespace EMotionFX
|
||||
{
|
||||
return { "Bip01__pelvis", "l_upLeg", "l_loLeg", "l_ankle" };
|
||||
}
|
||||
|
||||
|
||||
Actor* ActorFixture::GetActor()
|
||||
{
|
||||
return m_actorAsset->GetActor();
|
||||
}
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "SystemComponentFixture.h"
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
|
||||
#include <Integration/Assets/ActorAsset.h>
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
@@ -31,7 +30,9 @@ namespace EMotionFX
|
||||
AZStd::vector<AZStd::string> GetTestJointNames() const;
|
||||
|
||||
protected:
|
||||
AutoRegisteredActor m_actor{};
|
||||
Actor* GetActor();
|
||||
|
||||
AZ::Data::Asset<Integration::ActorAsset> m_actorAsset;
|
||||
ActorInstance* m_actorInstance = nullptr;
|
||||
};
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <EMotionFX/Source/BlendTreeBlend2Node.h>
|
||||
#include <EMotionFX/Source/BlendTreeBlendNNode.h>
|
||||
#include <EMotionFX/Source/BlendTreeParameterNode.h>
|
||||
#include <EMotionFX/Source/EMotionFXManager.h>
|
||||
#include <EMotionFX/Source/Parameter/FloatSliderParameter.h>
|
||||
#include <EMotionFX/Source/Parameter/ParameterFactory.h>
|
||||
#include <MCore/Source/AttributeFloat.h>
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace EMotionFX
|
||||
|
||||
TEST_P(RagdollRootNodeFixture, RagdollRootNodeIsSimulatedTests)
|
||||
{
|
||||
Physics::RagdollConfiguration& ragdollConfig = m_actor->GetPhysicsSetup()->GetRagdollConfig();
|
||||
Physics::RagdollConfiguration& ragdollConfig = GetActor()->GetPhysicsSetup()->GetRagdollConfig();
|
||||
AZStd::vector<Physics::RagdollNodeConfiguration>& ragdollNodes = ragdollConfig.m_nodes;
|
||||
const RagdollRootNodeParam& param = GetParam();
|
||||
const AZStd::string ragdollRootNodeName = param.m_ragdollRootNode.c_str();
|
||||
|
||||
@@ -24,13 +24,13 @@ namespace EMotionFX
|
||||
CommandSystem::CommandManager commandManager;
|
||||
MCore::CommandGroup commandGroup;
|
||||
|
||||
const AZ::u32 actorId = m_actor->GetID();
|
||||
const AZ::u32 actorId = GetActor()->GetID();
|
||||
const AZStd::vector<AZStd::string> jointNames = GetTestJointNames();
|
||||
const size_t jointCount = jointNames.size();
|
||||
|
||||
|
||||
// 1. Add colliders
|
||||
const AZStd::string serializedBeforeAdd = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeAdd = SerializePhysicsSetup(GetActor());
|
||||
for (const AZStd::string& jointName : jointNames)
|
||||
{
|
||||
CommandColliderHelpers::AddCollider(actorId, jointName, PhysicsSetup::HitDetection, azrtti_typeid<Physics::BoxShapeConfiguration>(), &commandGroup);
|
||||
@@ -39,23 +39,27 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
const AZStd::string serializedAfterAdd = SerializePhysicsSetup(m_actor.get());
|
||||
EXPECT_EQ(jointCount * 3, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(jointCount, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
const AZStd::string serializedAfterAdd = SerializePhysicsSetup(GetActor());
|
||||
EXPECT_EQ(jointCount * 3, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(
|
||||
jointCount,
|
||||
PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/ false, Physics::ShapeType::Box));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializePhysicsSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(jointCount * 3, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(jointCount, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(jointCount * 3, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(
|
||||
jointCount,
|
||||
PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/ false, Physics::ShapeType::Box));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializePhysicsSetup(GetActor()));
|
||||
|
||||
|
||||
// 2. Remove colliders
|
||||
commandGroup.RemoveAllCommands();
|
||||
const AZStd::string serializedBeforeRemove = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeRemove = SerializePhysicsSetup(GetActor());
|
||||
|
||||
size_t colliderIndexToRemove = 1;
|
||||
for (const AZStd::string& jointName : jointNames)
|
||||
@@ -64,18 +68,24 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
const AZStd::string serializedAfterRemove = SerializePhysicsSetup(m_actor.get());
|
||||
EXPECT_EQ(jointCount * 2, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Capsule));
|
||||
const AZStd::string serializedAfterRemove = SerializePhysicsSetup(GetActor());
|
||||
EXPECT_EQ(jointCount * 2, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(
|
||||
0,
|
||||
PhysicsSetupUtils::CountColliders(
|
||||
GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/ false, Physics::ShapeType::Capsule));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(jointCount * 3, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeRemove, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(jointCount * 3, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeRemove, SerializePhysicsSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(jointCount * 2, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Capsule));
|
||||
EXPECT_EQ(serializedAfterRemove, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(jointCount * 2, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(
|
||||
0,
|
||||
PhysicsSetupUtils::CountColliders(
|
||||
GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/ false, Physics::ShapeType::Capsule));
|
||||
EXPECT_EQ(serializedAfterRemove, SerializePhysicsSetup(GetActor()));
|
||||
}
|
||||
|
||||
TEST_F(ColliderCommandTests, AddRemove1000Colliders)
|
||||
@@ -84,11 +94,11 @@ namespace EMotionFX
|
||||
CommandSystem::CommandManager commandManager;
|
||||
MCore::CommandGroup commandGroup;
|
||||
|
||||
const AZ::u32 actorId = m_actor->GetID();
|
||||
const AZ::u32 actorId = GetActor()->GetID();
|
||||
const AZStd::string jointName = "Bip01__pelvis";
|
||||
|
||||
// 1. Add colliders
|
||||
const AZStd::string serializedBeforeAdd = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeAdd = SerializePhysicsSetup(GetActor());
|
||||
const size_t colliderCount = 1000;
|
||||
for (AZ::u32 i = 0; i < colliderCount; ++i)
|
||||
{
|
||||
@@ -96,51 +106,51 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
const AZStd::string serializedAfterAdd = SerializePhysicsSetup(m_actor.get());
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
const AZStd::string serializedAfterAdd = SerializePhysicsSetup(GetActor());
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializePhysicsSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializePhysicsSetup(GetActor()));
|
||||
|
||||
// 2. Clear colliders
|
||||
commandGroup.RemoveAllCommands();
|
||||
const AZStd::string serializedBeforeRemove = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeRemove = SerializePhysicsSetup(GetActor());
|
||||
CommandColliderHelpers::ClearColliders(actorId, jointName, PhysicsSetup::HitDetection, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
|
||||
const AZStd::string serializedAfterRemove = SerializePhysicsSetup(m_actor.get());
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
const AZStd::string serializedAfterRemove = SerializePhysicsSetup(GetActor());
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeRemove, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(colliderCount, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(serializedBeforeRemove, SerializePhysicsSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
EXPECT_EQ(serializedAfterRemove, SerializePhysicsSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection));
|
||||
EXPECT_EQ(0, PhysicsSetupUtils::CountColliders(GetActor(), PhysicsSetup::HitDetection, /*ignoreShapeType*/false, Physics::ShapeType::Box));
|
||||
EXPECT_EQ(serializedAfterRemove, SerializePhysicsSetup(GetActor()));
|
||||
}
|
||||
|
||||
TEST_F(ColliderCommandTests, AutoSizingColliders)
|
||||
{
|
||||
CommandSystem::CommandManager commandManager;
|
||||
|
||||
const AZ::u32 actorId = m_actor->GetID();
|
||||
const AZ::u32 actorId = GetActor()->GetID();
|
||||
const AZStd::vector<AZStd::string> jointNames = GetTestJointNames();
|
||||
ASSERT_TRUE(jointNames.size() > 0) << "The joint names test data needs at least one joint for this test.";
|
||||
const AZStd::string& jointName = jointNames[0];
|
||||
|
||||
CommandColliderHelpers::AddCollider(actorId, jointName, PhysicsSetup::HitDetection, azrtti_typeid<Physics::BoxShapeConfiguration>());
|
||||
|
||||
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = m_actor->GetPhysicsSetup();
|
||||
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = GetActor()->GetPhysicsSetup();
|
||||
Physics::CharacterColliderConfiguration* colliderConfig = physicsSetup->GetColliderConfigByType(PhysicsSetup::HitDetection);
|
||||
EXPECT_NE(colliderConfig, nullptr) << "Collider config should be valid after we added a collider to it.";
|
||||
|
||||
@@ -184,11 +194,11 @@ namespace EMotionFX
|
||||
const PhysicsSetup::ColliderConfigType m_configType = PhysicsSetup::ColliderConfigType::HitDetection;
|
||||
|
||||
// Add collider to the given joint first.
|
||||
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = m_actor->GetPhysicsSetup();
|
||||
EXPECT_TRUE(CommandColliderHelpers::AddCollider(m_actor->GetID(), m_jointName, m_configType, param.m_shapeType));
|
||||
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = GetActor()->GetPhysicsSetup();
|
||||
EXPECT_TRUE(CommandColliderHelpers::AddCollider(GetActor()->GetID(), m_jointName, m_configType, param.m_shapeType));
|
||||
Physics::CharacterColliderConfiguration* characterColliderConfig = physicsSetup->GetColliderConfigByType(m_configType);
|
||||
ASSERT_TRUE(characterColliderConfig != nullptr);
|
||||
Physics::CharacterColliderNodeConfiguration* nodeConfig = CommandColliderHelpers::GetCreateNodeConfig(m_actor.get(), m_jointName, *characterColliderConfig, result);
|
||||
Physics::CharacterColliderNodeConfiguration* nodeConfig = CommandColliderHelpers::GetCreateNodeConfig(GetActor(), m_jointName, *characterColliderConfig, result);
|
||||
ASSERT_TRUE(nodeConfig != nullptr);
|
||||
EXPECT_EQ(nodeConfig->m_shapes.size(), 1);
|
||||
|
||||
@@ -200,7 +210,8 @@ namespace EMotionFX
|
||||
|
||||
// Create the adjust collider command and using the data from the test parameter.
|
||||
MCore::Command* orgCommand = CommandSystem::GetCommandManager()->FindCommand(CommandAdjustCollider::s_commandName);
|
||||
CommandAdjustCollider* command = aznew CommandAdjustCollider(m_actor->GetID(), m_jointName, m_configType, /*colliderIndex=*/0, orgCommand);
|
||||
CommandAdjustCollider* command =
|
||||
aznew CommandAdjustCollider(GetActor()->GetID(), m_jointName, m_configType, /*colliderIndex=*/0, orgCommand);
|
||||
command->SetOldIsTrigger(colliderConfig->m_isTrigger);
|
||||
command->SetIsTrigger(param.m_isTrigger);
|
||||
command->SetOldPosition(colliderConfig->m_position);
|
||||
@@ -223,9 +234,9 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// Check execute.
|
||||
const AZStd::string serializedBeforeExecute = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeExecute = SerializePhysicsSetup(GetActor());
|
||||
EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(command, result));
|
||||
const AZStd::string serializedAfterExecute = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedAfterExecute = SerializePhysicsSetup(GetActor());
|
||||
|
||||
EXPECT_EQ(colliderConfig->m_isTrigger, param.m_isTrigger);
|
||||
EXPECT_EQ(colliderConfig->m_position, param.m_position);
|
||||
@@ -243,12 +254,12 @@ namespace EMotionFX
|
||||
|
||||
// Check undo.
|
||||
EXPECT_TRUE(CommandSystem::GetCommandManager()->Undo(result));
|
||||
const AZStd::string serializedAfterUndo = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedAfterUndo = SerializePhysicsSetup(GetActor());
|
||||
EXPECT_EQ(serializedAfterUndo, serializedBeforeExecute);
|
||||
|
||||
// Check redo.
|
||||
EXPECT_TRUE(CommandSystem::GetCommandManager()->Redo(result));
|
||||
const AZStd::string serializedAfterRedo = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedAfterRedo = SerializePhysicsSetup(GetActor());
|
||||
EXPECT_EQ(serializedAfterRedo, serializedAfterExecute);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
#include <Tests/TestAssetCode/JackActor.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
@@ -33,14 +35,12 @@ namespace EMotionFX
|
||||
ASSERT_EQ(GetActorManager().GetNumActors(), 0);
|
||||
|
||||
// Load an Actor
|
||||
const char* actorCmd{ "ImportActor -filename @engroot@/Gems/EMotionFX/Code/Tests/TestAssets/Rin/rin.actor" };
|
||||
{
|
||||
AZStd::string result;
|
||||
EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(actorCmd, result)) << result.c_str();
|
||||
}
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<JackNoMeshesActor>(actorAssetId, "Jack");
|
||||
|
||||
// Ensure the Actor is correct
|
||||
ASSERT_TRUE(GetActorManager().FindActorByName("rinActor"));
|
||||
ASSERT_TRUE(GetActorManager().FindActorByName("Jack"));
|
||||
EXPECT_EQ(GetActorManager().GetNumActors(), 1);
|
||||
}
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
#include <EMotionFX/Source/AnimGraphMotionNode.h>
|
||||
#include <EMotionFX/Source/MotionSet.h>
|
||||
#include <EMotionFX/Source/Motion.h>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/ActorInstance.h>
|
||||
#include <EMotionFX/Source/ActorUpdateScheduler.h>
|
||||
#include <EMotionFX/Source/EMotionFXManager.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
#include <EMotionFX/Source/MultiThreadScheduler.h>
|
||||
#include <Tests/SystemComponentFixture.h>
|
||||
#include <Tests/TestAssetCode/JackActor.h>
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
#include <EMotionFX/Source/AnimGraphEntryNode.h>
|
||||
#include <EMotionFX/Source/AnimGraphHubNode.h>
|
||||
#include <EMotionFX/Source/AnimGraphManager.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
|
||||
#include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h>
|
||||
#include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphViewWidget.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <EMotionFX/Source/MotionManager.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -78,7 +80,8 @@ namespace EMotionFX
|
||||
EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommandGroup(group, commandResult)) << commandResult.c_str();
|
||||
|
||||
// Create temp Actor
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(1, "tempActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 1, "tempActor");
|
||||
|
||||
// Cache some local poitners.
|
||||
m_animGraphPlugin = static_cast<EMStudio::AnimGraphPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMStudio::AnimGraphPlugin::CLASS_ID));
|
||||
@@ -90,6 +93,7 @@ namespace EMotionFX
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
GetEMotionFX().GetActorManager()->UnregisterAllActors();
|
||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
delete m_animGraph;
|
||||
UIFixture::TearDown();
|
||||
@@ -104,7 +108,7 @@ namespace EMotionFX
|
||||
AZStd::string m_entryNodeName = "testEntry";
|
||||
AnimGraph* m_animGraph = nullptr;
|
||||
EMStudio::AnimGraphPlugin* m_animGraphPlugin = nullptr;
|
||||
AutoRegisteredActor m_actor;
|
||||
AZ::Data::Asset<Integration::ActorAsset> m_actorAsset;
|
||||
};
|
||||
|
||||
TEST_F(PopulatedAnimGraphFixture, CanActivateValidGraph)
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <EMotionFX/Source/AnimGraphMotionNode.h>
|
||||
#include <EMotionFX/Source/AnimGraphReferenceNode.h>
|
||||
#include <EMotionFX/Source/AnimGraphStateMachine.h>
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
#include <EMotionFX/Source/EMotionFXManager.h>
|
||||
#include <EMotionFX/Source/Parameter/BoolParameter.h>
|
||||
#include <EMotionFX/Source/Parameter/FloatSliderParameter.h>
|
||||
@@ -43,6 +42,7 @@
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/ProvidesUI/AnimGraph/SimpleAnimGraphUIFixture.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/Mocks/EventHandler.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -423,7 +423,10 @@ namespace EMotionFX
|
||||
using testing::Eq;
|
||||
using testing::Not;
|
||||
|
||||
AutoRegisteredActor actor = EMotionFX::ActorFactory::CreateAndInit<EMotionFX::SimpleJointChainActor>(1);
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 1);
|
||||
|
||||
auto motionSet = AZStd::make_unique<EMotionFX::MotionSet>();
|
||||
|
||||
{
|
||||
@@ -432,7 +435,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
auto* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(0);
|
||||
auto* actorInstance = EMotionFX::ActorInstance::Create(actor.get());
|
||||
auto* actorInstance = EMotionFX::ActorInstance::Create(actorAsset->GetActor());
|
||||
auto* animGraphInstance = EMotionFX::AnimGraphInstance::Create(animGraph, actorInstance, motionSet.get());
|
||||
actorInstance->SetAnimGraphInstance(animGraphInstance);
|
||||
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
#include <EMotionStudio/EMStudioSDK/Source/SaveChangedFilesManager.h>
|
||||
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/UI/ModalPopupHandler.h>
|
||||
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
|
||||
@@ -58,8 +57,10 @@ namespace EMotionFX
|
||||
ASSERT_EQ(GetMotionManager().GetNumMotions(), 0) << "Expected exactly zero motions";
|
||||
|
||||
// Create Actor, AnimGraph, Motionset and Motion
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(2, "SampleActor");
|
||||
ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 2, "SampleActor");
|
||||
ActorInstance::Create(actorAsset->GetActor());
|
||||
{
|
||||
AZStd::string result;
|
||||
ASSERT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(createAnimGraphCmd, result)) << result.c_str();
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <Tests/Mocks/PhysicsSystem.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -79,7 +80,11 @@ namespace EMotionFX
|
||||
TEST_F(CopyPasteRagdollCollidersFixture, CanCopyCollider)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_EDITOR_TESTS
|
||||
{
|
||||
AutoRegisteredActor actor{ActorFactory::CreateAndInit<SimpleJointChainActor>(4)};
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 4);
|
||||
const Actor* actor = actorAsset->GetActor();
|
||||
|
||||
const Physics::RagdollConfiguration& ragdollConfig = actor->GetPhysicsSetup()->GetRagdollConfig();
|
||||
const Physics::CharacterColliderConfiguration& simulatedObjectConfig = actor->GetPhysicsSetup()->GetSimulatedObjectColliderConfig();
|
||||
|
||||
@@ -104,8 +109,7 @@ namespace EMotionFX
|
||||
|
||||
{
|
||||
AZStd::string result;
|
||||
EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(
|
||||
"Select -actorId " + AZStd::to_string(actor->GetID()),
|
||||
EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand("Select -actorId " + AZStd::to_string(actor->GetID()),
|
||||
result))
|
||||
<< result.c_str();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
|
||||
#include <EMotionFX/CommandSystem/Source/RagdollCommands.h>
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
|
||||
#include <Editor/Plugins/Ragdoll/RagdollJointLimitWidget.h>
|
||||
#include <Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.h>
|
||||
@@ -25,6 +24,7 @@
|
||||
#include <Tests/Mocks/PhysicsSystem.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -76,7 +76,9 @@ namespace EMotionFX
|
||||
return AZStd::make_unique<D6JointLimitConfiguration>();
|
||||
});
|
||||
|
||||
AutoRegisteredActor actor {ActorFactory::CreateAndInit<SimpleJointChainActor>(4)};
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 4);
|
||||
const Actor* actor = actorAsset->GetActor();
|
||||
|
||||
{
|
||||
AZStd::string result;
|
||||
|
||||
@@ -99,28 +99,28 @@ namespace EMotionFX
|
||||
"l_hand",
|
||||
};
|
||||
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(m_actor->GetID(), {"l_shldr"}, &commandGroup);
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(GetActor()->GetID(), {"l_shldr"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(
|
||||
StrEq(),
|
||||
jointsToLeftShoulder
|
||||
)
|
||||
);
|
||||
|
||||
const AZStd::string serializedBeforeHandAdded = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeHandAdded = SerializePhysicsSetup(GetActor());
|
||||
|
||||
// Adding l_hand should add l_upArm and l_loArm as well
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(m_actor->GetID(), {"l_hand"}, &commandGroup);
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(GetActor()->GetID(), {"l_hand"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
|
||||
const AZStd::string serializedAfterHandAdded = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedAfterHandAdded = SerializePhysicsSetup(GetActor());
|
||||
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(
|
||||
StrEq(),
|
||||
jointsToLeftHand
|
||||
@@ -129,23 +129,23 @@ namespace EMotionFX
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result)) << result.c_str();
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(
|
||||
StrEq(),
|
||||
jointsToLeftShoulder
|
||||
)
|
||||
);
|
||||
EXPECT_THAT(SerializePhysicsSetup(m_actor.get()), StrEq(serializedBeforeHandAdded));
|
||||
EXPECT_THAT(SerializePhysicsSetup(GetActor()), StrEq(serializedBeforeHandAdded));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result)) << result.c_str();
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(
|
||||
StrEq(),
|
||||
jointsToLeftHand
|
||||
)
|
||||
);
|
||||
EXPECT_THAT(SerializePhysicsSetup(m_actor.get()), StrEq(serializedAfterHandAdded));
|
||||
EXPECT_THAT(SerializePhysicsSetup(GetActor()), StrEq(serializedAfterHandAdded));
|
||||
}
|
||||
|
||||
TEST_F(RagdollCommandTests, AddJointHigherInHierarchy)
|
||||
@@ -166,10 +166,10 @@ namespace EMotionFX
|
||||
"l_hand",
|
||||
};
|
||||
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(m_actor->GetID(), {"l_hand"}, &commandGroup);
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(GetActor()->GetID(), {"l_hand"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(
|
||||
StrEq(),
|
||||
jointsToLeftHand
|
||||
@@ -178,10 +178,10 @@ namespace EMotionFX
|
||||
|
||||
// l_shldr should already be in the ragdoll, so adding it should do nothing
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(m_actor->GetID(), {"l_shldr"}, &commandGroup);
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(GetActor()->GetID(), {"l_shldr"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(
|
||||
StrEq(),
|
||||
jointsToLeftHand
|
||||
@@ -190,11 +190,11 @@ namespace EMotionFX
|
||||
|
||||
// Undo here undoes the addition of l_hand
|
||||
EXPECT_TRUE(commandManager.Undo(result)) << result.c_str();
|
||||
EXPECT_TRUE(GetRagdollJointNames(m_actor.get()).empty());
|
||||
EXPECT_TRUE(GetRagdollJointNames(GetActor()).empty());
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result)) << result.c_str();
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(
|
||||
StrEq(),
|
||||
jointsToLeftHand
|
||||
@@ -221,16 +221,16 @@ namespace EMotionFX
|
||||
};
|
||||
|
||||
// Add a joint to the ragdoll that does not make a chain all the way to the root
|
||||
EXPECT_TRUE(commandManager.ExecuteCommand(aznew CommandAddRagdollJoint(m_actor->GetID(), "l_shldr"), result)) << result.c_str();
|
||||
EXPECT_TRUE(commandManager.ExecuteCommand(aznew CommandAddRagdollJoint(GetActor()->GetID(), "l_shldr"), result)) << result.c_str();
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(StrEq(), AZStd::vector<AZStd::string>{"l_shldr"})
|
||||
);
|
||||
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(m_actor->GetID(), {"l_hand"}, &commandGroup);
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(GetActor()->GetID(), {"l_hand"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(StrEq(), jointsToLeftHand)
|
||||
);
|
||||
}
|
||||
@@ -250,17 +250,17 @@ namespace EMotionFX
|
||||
};
|
||||
|
||||
// Add joints from the root to the left hand
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(m_actor->GetID(), {"l_hand"}, &commandGroup);
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(GetActor()->GetID(), {"l_hand"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
|
||||
// Removing the left shoulder should remove the elbow, wrist, and hand
|
||||
// as well
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandRagdollHelpers::RemoveJointsFromRagdoll(m_actor->GetID(), {"l_shldr"}, &commandGroup);
|
||||
CommandRagdollHelpers::RemoveJointsFromRagdoll(GetActor()->GetID(), {"l_shldr"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
|
||||
EXPECT_THAT(
|
||||
GetRagdollJointNames(m_actor.get()),
|
||||
GetRagdollJointNames(GetActor()),
|
||||
testing::UnorderedPointwise(StrEq(), jointsToSpine3)
|
||||
);
|
||||
}
|
||||
@@ -271,24 +271,24 @@ namespace EMotionFX
|
||||
CommandSystem::CommandManager commandManager;
|
||||
MCore::CommandGroup commandGroup;
|
||||
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(m_actor->GetID(), {"l_hand"}, &commandGroup);
|
||||
CommandRagdollHelpers::AddJointsToRagdoll(GetActor()->GetID(), {"l_hand"}, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result)) << result.c_str();
|
||||
|
||||
const AZStd::string serializedBeforeSphereAdded = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeSphereAdded = SerializePhysicsSetup(GetActor());
|
||||
|
||||
CommandColliderHelpers::AddCollider(m_actor->GetID(), "l_hand",
|
||||
CommandColliderHelpers::AddCollider(GetActor()->GetID(), "l_hand",
|
||||
PhysicsSetup::Ragdoll, azrtti_typeid<Physics::SphereShapeConfiguration>());
|
||||
|
||||
const AZStd::string serializedAfterSphereAdded = SerializePhysicsSetup(m_actor.get());
|
||||
const AZStd::string serializedAfterSphereAdded = SerializePhysicsSetup(GetActor());
|
||||
|
||||
EXPECT_THAT(serializedAfterSphereAdded, ::testing::Not(StrEq(serializedBeforeSphereAdded)));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result)) << result.c_str();
|
||||
|
||||
EXPECT_THAT(SerializePhysicsSetup(m_actor.get()), StrEq(serializedBeforeSphereAdded));
|
||||
EXPECT_THAT(SerializePhysicsSetup(GetActor()), StrEq(serializedBeforeSphereAdded));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result)) << result.c_str();
|
||||
|
||||
EXPECT_THAT(SerializePhysicsSetup(m_actor.get()), StrEq(serializedAfterSphereAdded));
|
||||
EXPECT_THAT(SerializePhysicsSetup(GetActor()), StrEq(serializedAfterSphereAdded));
|
||||
}
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -55,25 +55,25 @@ namespace EMotionFX
|
||||
CommandSystem::CommandManager commandManager;
|
||||
MCore::CommandGroup commandGroup;
|
||||
|
||||
const uint32 actorId = m_actor->GetID();
|
||||
const uint32 actorId = GetActor()->GetID();
|
||||
const AZStd::vector<AZStd::string> jointNames = GetTestJointNames();
|
||||
|
||||
// 1. Add simulated object.
|
||||
const AZStd::string serializedBeforeAdd = SerializeSimulatedObjectSetup(m_actor.get());
|
||||
const AZStd::string serializedBeforeAdd = SerializeSimulatedObjectSetup(GetActor());
|
||||
CommandSimulatedObjectHelpers::AddSimulatedObject(actorId, AZStd::nullopt, &commandGroup);
|
||||
CommandSimulatedObjectHelpers::AddSimulatedObject(actorId, AZStd::nullopt, &commandGroup);
|
||||
CommandSimulatedObjectHelpers::AddSimulatedObject(actorId, AZStd::nullopt, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
const AZStd::string serializedAfterAdd = SerializeSimulatedObjectSetup(m_actor.get());
|
||||
EXPECT_EQ(3, CountSimulatedObjects(m_actor.get()));
|
||||
const AZStd::string serializedAfterAdd = SerializeSimulatedObjectSetup(GetActor());
|
||||
EXPECT_EQ(3, CountSimulatedObjects(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(0, CountSimulatedObjects(m_actor.get()));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, CountSimulatedObjects(GetActor()));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(3, CountSimulatedObjects(m_actor.get()));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(3, CountSimulatedObjects(GetActor()));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
// 2. Remove simulated object.
|
||||
commandGroup.RemoveAllCommands();
|
||||
@@ -81,22 +81,22 @@ namespace EMotionFX
|
||||
CommandSimulatedObjectHelpers::RemoveSimulatedObject(actorId, 0, &commandGroup);
|
||||
CommandSimulatedObjectHelpers::RemoveSimulatedObject(actorId, 0, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
EXPECT_EQ(0, CountSimulatedObjects(m_actor.get()));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, CountSimulatedObjects(GetActor()));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(3, CountSimulatedObjects(m_actor.get()));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(3, CountSimulatedObjects(GetActor()));
|
||||
EXPECT_EQ(serializedAfterAdd, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(0, CountSimulatedObjects(m_actor.get()));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, CountSimulatedObjects(GetActor()));
|
||||
EXPECT_EQ(serializedBeforeAdd, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
// 3. Add simulated joints.
|
||||
// 3.1 Add a simulated object first to put in the simulated joints.
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandSimulatedObjectHelpers::AddSimulatedObject(actorId);
|
||||
const AZStd::string serialized3_1 = SerializeSimulatedObjectSetup(m_actor.get());
|
||||
const AZStd::string serialized3_1 = SerializeSimulatedObjectSetup(GetActor());
|
||||
|
||||
// 3.2 Add simulated joints.
|
||||
// Joint hierarchy as follow:
|
||||
@@ -105,7 +105,7 @@ namespace EMotionFX
|
||||
// --l_loLeg
|
||||
// --l_ankle
|
||||
// --l_ball
|
||||
const Skeleton* skeleton = m_actor->GetSkeleton();
|
||||
const Skeleton* skeleton = GetActor()->GetSkeleton();
|
||||
const size_t l_upLegIdx = skeleton->FindNodeByName("l_upLeg")->GetNodeIndex();
|
||||
const size_t l_upLegRollIdx = skeleton->FindNodeByName("l_upLegRoll")->GetNodeIndex();
|
||||
const size_t l_loLegIdx = skeleton->FindNodeByName("l_loLeg")->GetNodeIndex();
|
||||
@@ -113,33 +113,33 @@ namespace EMotionFX
|
||||
const size_t l_ballIdx = skeleton->FindNodeByName("l_ball")->GetNodeIndex();
|
||||
CommandSimulatedObjectHelpers::AddSimulatedJoints(actorId, {l_upLegIdx, l_upLegRollIdx, l_loLegIdx, l_ankleIdx, l_ballIdx}, 0, false, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
const AZStd::string serialized3_2 = SerializeSimulatedObjectSetup(m_actor.get());
|
||||
EXPECT_EQ(5, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(2, CountChildJoints(m_actor.get(), 0, l_upLegIdx));
|
||||
EXPECT_EQ(0, CountChildJoints(m_actor.get(), 0, l_upLegRollIdx));
|
||||
EXPECT_EQ(1, CountChildJoints(m_actor.get(), 0, l_loLegIdx));
|
||||
const AZStd::string serialized3_2 = SerializeSimulatedObjectSetup(GetActor());
|
||||
EXPECT_EQ(5, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(2, CountChildJoints(GetActor(), 0, l_upLegIdx));
|
||||
EXPECT_EQ(0, CountChildJoints(GetActor(), 0, l_upLegRollIdx));
|
||||
EXPECT_EQ(1, CountChildJoints(GetActor(), 0, l_loLegIdx));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serialized3_1, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serialized3_1, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(5, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serialized3_2, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(5, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serialized3_2, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
// 4 Remove simulated joints.
|
||||
// 4.1 Test sparse chain.
|
||||
EXPECT_EQ(1, CountRootJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(1, CountRootJoints(GetActor(), 0));
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandSimulatedObjectHelpers::RemoveSimulatedJoints(actorId, {l_loLegIdx}, 0, false, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
EXPECT_EQ(2, CountRootJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(2, CountRootJoints(GetActor(), 0));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(1, CountRootJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(1, CountRootJoints(GetActor(), 0));
|
||||
|
||||
EXPECT_TRUE(commandManager.Redo(result));
|
||||
EXPECT_EQ(2, CountRootJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(2, CountRootJoints(GetActor(), 0));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
|
||||
@@ -147,23 +147,23 @@ namespace EMotionFX
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandSimulatedObjectHelpers::RemoveSimulatedJoints(actorId, { l_upLegIdx, l_upLegRollIdx, l_loLegIdx, l_ankleIdx, l_ballIdx }, 0, false, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serialized3_1, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serialized3_1, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(5, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serialized3_2, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(5, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serialized3_2, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
// 4.3 Test removing the root joint and children.
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandSimulatedObjectHelpers::RemoveSimulatedJoints(actorId, { l_upLegIdx }, 0, true, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serialized3_1, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serialized3_1, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(5, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serialized3_2, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(5, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serialized3_2, SerializeSimulatedObjectSetup(GetActor()));
|
||||
}
|
||||
|
||||
TEST_F(SimulatedObjectCommandTests, SimulatedObjectCommands_UndoRemoveJointTest)
|
||||
@@ -172,35 +172,35 @@ namespace EMotionFX
|
||||
CommandSystem::CommandManager commandManager;
|
||||
MCore::CommandGroup commandGroup;
|
||||
|
||||
const uint32 actorId = m_actor->GetID();
|
||||
const uint32 actorId = GetActor()->GetID();
|
||||
const AZStd::vector<AZStd::string> jointNames = GetTestJointNames();
|
||||
|
||||
// 1. Add simulated object
|
||||
CommandSimulatedObjectHelpers::AddSimulatedObject(actorId, AZStd::nullopt, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
const AZStd::string serializedBase = SerializeSimulatedObjectSetup(m_actor.get());
|
||||
const AZStd::string serializedBase = SerializeSimulatedObjectSetup(GetActor());
|
||||
const size_t simulatedObjectIndex = 0;
|
||||
|
||||
// 2. Add r_upLeg simulated joints
|
||||
const Skeleton* skeleton = m_actor->GetSkeleton();
|
||||
const Skeleton* skeleton = GetActor()->GetSkeleton();
|
||||
const size_t r_upLegIdx = skeleton->FindNodeByName("r_upLeg")->GetNodeIndex();
|
||||
const size_t r_loLegIdx = skeleton->FindNodeByName("r_loLeg")->GetNodeIndex();
|
||||
CommandSimulatedObjectHelpers::AddSimulatedJoints(actorId, { r_upLegIdx, r_loLegIdx }, 0, false);
|
||||
EXPECT_EQ(2, CountSimulatedJoints(m_actor.get(), 0));
|
||||
const AZStd::string serializedUpLeg = SerializeSimulatedObjectSetup(m_actor.get());
|
||||
EXPECT_EQ(2, CountSimulatedJoints(GetActor(), 0));
|
||||
const AZStd::string serializedUpLeg = SerializeSimulatedObjectSetup(GetActor());
|
||||
|
||||
// 3. Remove the r_loLeg simulated joint
|
||||
AZStd::vector<SimulatedJoint*> jointsToBeRemoved;
|
||||
commandGroup.RemoveAllCommands();
|
||||
CommandSimulatedObjectHelpers::RemoveSimulatedJoints(actorId, { r_upLegIdx }, simulatedObjectIndex, true, &commandGroup);
|
||||
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serializedBase, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(0, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serializedBase, SerializeSimulatedObjectSetup(GetActor()));
|
||||
|
||||
// 4. Undo
|
||||
// This recreates r_loLeg and r_loLeg but won't add all other children recursively as only these two joints got aded in step 3.
|
||||
EXPECT_TRUE(commandManager.Undo(result));
|
||||
EXPECT_EQ(2, CountSimulatedJoints(m_actor.get(), 0));
|
||||
EXPECT_EQ(serializedUpLeg, SerializeSimulatedObjectSetup(m_actor.get()));
|
||||
EXPECT_EQ(2, CountSimulatedJoints(GetActor(), 0));
|
||||
EXPECT_EQ(serializedUpLeg, SerializeSimulatedObjectSetup(GetActor()));
|
||||
}
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -22,17 +22,21 @@
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
using SimulatedObjectModelTestsFixture = UIFixture;
|
||||
TEST_F(SimulatedObjectModelTestsFixture, CanUndoAddSimulatedObjectAndSimulatedJointWithChildren)
|
||||
{
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(3, "simulatedObjectModelTestActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 3, "simulatedObjectModelTestActor");
|
||||
const Actor* actor = actorAsset->GetActor();
|
||||
|
||||
EMotionFX::SimulatedObjectWidget* simulatedObjectWidget = static_cast<EMotionFX::SimulatedObjectWidget*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SimulatedObjectWidget::CLASS_ID));
|
||||
ASSERT_TRUE(simulatedObjectWidget) << "Simulated Object plugin not loaded";
|
||||
simulatedObjectWidget->ActorSelectionChanged(actor.get());
|
||||
simulatedObjectWidget->ActorSelectionChanged(actorAsset->GetActor());
|
||||
|
||||
SimulatedObjectModel* model = simulatedObjectWidget->GetSimulatedObjectModel();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace EMotionFX
|
||||
|
||||
TEST_F(SimulatedObjectSerializeTests, SerializeTest)
|
||||
{
|
||||
SimulatedObjectSetup* setup = m_actor->GetSimulatedObjectSetup().get();
|
||||
SimulatedObjectSetup* setup = GetActor()->GetSimulatedObjectSetup().get();
|
||||
|
||||
// Build some setup.
|
||||
SimulatedObject* object = setup->AddSimulatedObject();
|
||||
@@ -29,7 +29,7 @@ namespace EMotionFX
|
||||
object->SetGravityFactor(3.0f);
|
||||
object->SetStiffnessFactor(4.0f);
|
||||
const AZStd::vector<AZStd::string> jointNames = { "l_upArm", "l_loArm", "l_hand" };
|
||||
Skeleton* skeleton = m_actor->GetSkeleton();
|
||||
Skeleton* skeleton = GetActor()->GetSkeleton();
|
||||
for (const AZStd::string& name : jointNames)
|
||||
{
|
||||
size_t skeletonJointIndex;
|
||||
@@ -50,7 +50,7 @@ namespace EMotionFX
|
||||
object->GetSimulatedJoint(0)->SetPinned(true);
|
||||
|
||||
// Serialize it and deserialize it.
|
||||
const AZStd::string serialized = SerializeSimulatedObjectSetup(m_actor.get());
|
||||
const AZStd::string serialized = SerializeSimulatedObjectSetup(GetActor());
|
||||
AZStd::unique_ptr<SimulatedObjectSetup> loadedSetup(DeserializeSimulatedObjectSetup(serialized));
|
||||
|
||||
// Verify some of the contents of the deserialized version.
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace EMotionFX
|
||||
void SetUp()
|
||||
{
|
||||
ActorFixture::SetUp();
|
||||
m_actor->AddLODLevel();
|
||||
GetActor()->AddLODLevel();
|
||||
DisableJointsForLOD(m_disabledJointNames, 1);
|
||||
}
|
||||
|
||||
void DisableJointsForLOD(const std::vector<std::string>& jointNames, size_t lodLevel)
|
||||
{
|
||||
const Skeleton* skeleton = m_actor->GetSkeleton();
|
||||
const Skeleton* skeleton = GetActor()->GetSkeleton();
|
||||
for (const std::string& jointName : jointNames)
|
||||
{
|
||||
Node* joint = skeleton->FindNodeByName(jointName.c_str());
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/EMotionFXManager.h>
|
||||
#include <EMotionFX/Source/Importer/Importer.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/JackActor.h>
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <Integration/Assets/ActorAsset.h>
|
||||
#include <EMotionFX/Source/EMotionFXManager.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
@@ -18,5 +21,14 @@ namespace EMotionFX
|
||||
public:
|
||||
static AZStd::string FileToBase64(const char* filePath);
|
||||
static AZ::Data::Asset<Integration::ActorAsset> GetAssetFromActor(const AZ::Data::AssetId& assetId, AZStd::unique_ptr<Actor>&& actor);
|
||||
|
||||
template<class ActorT, typename... Args>
|
||||
static AZ::Data::Asset<Integration::ActorAsset> CreateActorAssetAndRegister(const AZ::Data::AssetId& assetId, Args&&... args)
|
||||
{
|
||||
AZStd::unique_ptr<ActorT> actor = ActorFactory::CreateAndInit<ActorT>(AZStd::forward<Args>(args)...);
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset = TestActorAssets::GetAssetFromActor(assetId, AZStd::move(actor));
|
||||
GetEMotionFX().GetActorManager()->RegisterActor(actorAsset);
|
||||
return AZStd::move(actorAsset);
|
||||
}
|
||||
};
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#include <Tests/UI/ModalPopupHandler.h>
|
||||
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
|
||||
#include <Editor/Plugins/SimulatedObject/SimulatedObjectWidget.h>
|
||||
#include <Editor/Plugins/SkeletonOutliner/SkeletonOutlinerPlugin.h>
|
||||
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
@@ -37,8 +37,11 @@ namespace EMotionFX
|
||||
RecordProperty("test_case_id", "C13048819");
|
||||
|
||||
// Create an actor
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(5, "SimpleActor");
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "SimpleActor");
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actorAsset->GetActor());
|
||||
const Actor* actor = actorAsset->GetActor();
|
||||
|
||||
// Open simulated objects layout
|
||||
EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects");
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <Tests/UI/ModalPopupHandler.h>
|
||||
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
#include <Editor/ColliderContainerWidget.h>
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
|
||||
#include <Editor/Plugins/SimulatedObject/SimulatedObjectWidget.h>
|
||||
@@ -27,6 +26,7 @@
|
||||
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/PhysicsSetupUtils.h>
|
||||
#include <Editor/ReselectingTreeView.h>
|
||||
|
||||
@@ -81,9 +81,9 @@ namespace EMotionFX
|
||||
inputDialog->accept();
|
||||
|
||||
// There is one and only one simulated objects
|
||||
ASSERT_EQ(m_actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 1);
|
||||
ASSERT_EQ(m_actorAsset->GetActor()->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 1);
|
||||
// Check it has the correct name
|
||||
EXPECT_STREQ(m_actor->GetSimulatedObjectSetup()->GetSimulatedObject(0)->GetName().c_str(), objectName);
|
||||
EXPECT_STREQ(m_actorAsset->GetActor()->GetSimulatedObjectSetup()->GetSimulatedObject(0)->GetName().c_str(), objectName);
|
||||
|
||||
}
|
||||
|
||||
@@ -112,14 +112,16 @@ namespace EMotionFX
|
||||
});
|
||||
ASSERT_NE(addCapsuleColliderAction, addSelectedColliderMenuActions.end());
|
||||
|
||||
size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders(
|
||||
m_actorAsset->GetActor(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
|
||||
(*addCapsuleColliderAction)->trigger();
|
||||
|
||||
// Delete the context menu, otherwise there it will still be around during this frame as the Qt event loop has not been run.
|
||||
delete contextMenu;
|
||||
|
||||
const size_t numCapsuleCollidersAfterAdd = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
const size_t numCapsuleCollidersAfterAdd = PhysicsSetupUtils::CountColliders(
|
||||
m_actorAsset->GetActor(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
|
||||
ASSERT_EQ(numCapsuleCollidersAfterAdd, numCapsuleColliders + 1);
|
||||
|
||||
@@ -127,7 +129,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
protected:
|
||||
AutoRegisteredActor m_actor;
|
||||
AZ::Data::Asset<Integration::ActorAsset> m_actorAsset;
|
||||
EMotionFX::SimulatedObjectWidget* m_simulatedObjectWidget = nullptr;
|
||||
|
||||
EMotionFX::SkeletonOutlinerPlugin* m_skeletonOutliner = nullptr;
|
||||
@@ -144,7 +146,8 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C13048820");
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(1, "CanAddSimulatedObjectActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 1, "CanAddSimulatedObjectActor");
|
||||
|
||||
CreateSimulateObject("New simulated object");
|
||||
}
|
||||
@@ -153,9 +156,11 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C13048818");
|
||||
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(2, "CanAddSimulatedObjectWithJointsActor");
|
||||
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 2, "CanAddSimulatedObjectWithJointsActor");
|
||||
Actor* actor = actorAsset->GetActor();
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor);
|
||||
|
||||
EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects");
|
||||
|
||||
@@ -216,7 +221,9 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C13048820a");
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(5, "CanAddSimulatedObjectActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor");
|
||||
Actor* actor = m_actorAsset->GetActor();
|
||||
|
||||
CreateSimulateObject("sim1");
|
||||
|
||||
@@ -261,8 +268,8 @@ namespace EMotionFX
|
||||
inputDialog->SetText("sim2");
|
||||
inputDialog->accept();
|
||||
|
||||
ASSERT_EQ(m_actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 2);
|
||||
const auto simulatedObject = m_actor->GetSimulatedObjectSetup()->GetSimulatedObject(1);
|
||||
ASSERT_EQ(actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 2);
|
||||
const auto simulatedObject = actor->GetSimulatedObjectSetup()->GetSimulatedObject(1);
|
||||
EXPECT_STREQ(simulatedObject->GetName().c_str(), "sim2");
|
||||
}
|
||||
|
||||
@@ -270,7 +277,9 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C13048816");
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(5, "CanAddSimulatedObjectActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor");
|
||||
Actor* actor = m_actorAsset->GetActor();
|
||||
|
||||
CreateSimulateObject("sim1");
|
||||
|
||||
@@ -301,25 +310,25 @@ namespace EMotionFX
|
||||
QAction* addCapsuleColliderAction;
|
||||
ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addCapsuleColliderAction, addSelectedColliderMenu, "Capsule"));
|
||||
|
||||
size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
EXPECT_EQ(numCapsuleColliders, 0);
|
||||
|
||||
addCapsuleColliderAction->trigger();
|
||||
|
||||
// Check that a collider has been added.
|
||||
size_t numCollidersAfterAddCapsule = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
size_t numCollidersAfterAddCapsule = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
ASSERT_EQ(numCollidersAfterAddCapsule, numCapsuleColliders + 1) << "Capsule collider not added.";
|
||||
|
||||
QAction* addSphereColliderAction;
|
||||
ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addSphereColliderAction, addSelectedColliderMenu, "Sphere"));
|
||||
|
||||
const size_t numSphereColliders = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
const size_t numSphereColliders = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
EXPECT_EQ(numSphereColliders, 0);
|
||||
|
||||
addSphereColliderAction->trigger();
|
||||
|
||||
// Check that a second collider has been added.
|
||||
const size_t numCollidersAfterAddSphere = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
const size_t numCollidersAfterAddSphere = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
ASSERT_EQ(numCollidersAfterAddSphere, numSphereColliders + 1) << "Sphere collider not added.";
|
||||
}
|
||||
|
||||
@@ -327,7 +336,9 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C13048821");
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(1, "CanRemoveSimulatedObjectActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 1, "CanRemoveSimulatedObjectActor");
|
||||
Actor* actor = m_actorAsset->GetActor();
|
||||
|
||||
CreateSimulateObject("TestObject1");
|
||||
|
||||
@@ -350,14 +361,16 @@ namespace EMotionFX
|
||||
ASSERT_TRUE(UIFixture::GetActionFromContextMenu(removeObjectAction, contextMenu, "Remove object"));
|
||||
removeObjectAction->trigger();
|
||||
|
||||
ASSERT_EQ(m_actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 0);
|
||||
ASSERT_EQ(actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 0);
|
||||
}
|
||||
|
||||
TEST_F(CanAddSimulatedObjectFixture, CanAddColliderToSimulatedObjectFromInspector)
|
||||
{
|
||||
RecordProperty("test_case_id", "C20385259");
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(5, "CanAddSimulatedObjectActor");
|
||||
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor");
|
||||
Actor* actor = m_actorAsset->GetActor();
|
||||
|
||||
CreateSimulateObject("sim1");
|
||||
|
||||
@@ -380,10 +393,12 @@ namespace EMotionFX
|
||||
// Send the left button click directly to the button
|
||||
QTest::mouseClick(addColliderButton, Qt::LeftButton);
|
||||
|
||||
const size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
const size_t numCapsuleColliders =
|
||||
PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
EXPECT_EQ(numCapsuleColliders, 0);
|
||||
|
||||
const size_t numSphereColliders = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
const size_t numSphereColliders =
|
||||
PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
EXPECT_EQ(numSphereColliders, 0);
|
||||
|
||||
QMenu* contextMenu = addColliderButton->findChild<QMenu*>("EMFX.AddColliderButton.ContextMenu");
|
||||
@@ -392,13 +407,15 @@ namespace EMotionFX
|
||||
QAction* addCapsuleAction;
|
||||
ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addCapsuleAction, contextMenu, "Add capsule"));
|
||||
addCapsuleAction->trigger();
|
||||
const size_t numCollidersAfterAddCapsule = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
const size_t numCollidersAfterAddCapsule =
|
||||
PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule);
|
||||
ASSERT_EQ(numCollidersAfterAddCapsule, numCapsuleColliders + 1) << "Capsule collider not added.";
|
||||
|
||||
QAction* addSphereAction;
|
||||
ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addSphereAction, contextMenu, "Add sphere"));
|
||||
addSphereAction->trigger();
|
||||
const size_t numCollidersAfterAddSphere = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
const size_t numCollidersAfterAddSphere =
|
||||
PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere);
|
||||
ASSERT_EQ(numCollidersAfterAddSphere, numSphereColliders + 1) << "Sphere collider not added.";
|
||||
}
|
||||
|
||||
@@ -406,7 +423,9 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C13048818");
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(7, "CanAddSimulatedObjectActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 7, "CanAddSimulatedObjectActor");
|
||||
Actor* actor = m_actorAsset->GetActor();
|
||||
|
||||
CreateSimulateObject("ANY");
|
||||
|
||||
@@ -442,7 +461,7 @@ namespace EMotionFX
|
||||
messageBoxPopupHandler.WaitForPopupPressDialogButton<QMessageBox*>(QDialogButtonBox::No);
|
||||
newSimulatedObjectAction->trigger();
|
||||
|
||||
const EMotionFX::SimulatedObject* simulatedObject = m_actor->GetSimulatedObjectSetup()->GetSimulatedObject(0);
|
||||
const EMotionFX::SimulatedObject* simulatedObject = actor->GetSimulatedObjectSetup()->GetSimulatedObject(0);
|
||||
EXPECT_EQ(simulatedObject->GetNumSimulatedRootJoints(), 1);
|
||||
EXPECT_EQ(simulatedObject->GetNumSimulatedJoints(), 3);
|
||||
}
|
||||
@@ -450,7 +469,9 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C13048817");
|
||||
|
||||
m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(5, "CanAddSimulatedObjectActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor");
|
||||
Actor* actor = m_actorAsset->GetActor();
|
||||
|
||||
EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects");
|
||||
|
||||
@@ -470,7 +491,7 @@ namespace EMotionFX
|
||||
AddCapsuleColliderToJointIndex(3);
|
||||
AddCapsuleColliderToJointIndex(4);
|
||||
|
||||
const size_t numCollidersAfterAdd = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider);
|
||||
const size_t numCollidersAfterAdd = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider);
|
||||
EXPECT_EQ(numCollidersAfterAdd, 2);
|
||||
|
||||
m_indexList.clear();
|
||||
@@ -498,7 +519,7 @@ namespace EMotionFX
|
||||
removeAction->trigger();
|
||||
|
||||
// Check that one of the colliders is now gone.
|
||||
const size_t numCollidersAfterFirstRemove = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider);
|
||||
const size_t numCollidersAfterFirstRemove = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider);
|
||||
ASSERT_EQ(numCollidersAfterFirstRemove, numCollidersAfterAdd - 1) << "RemoveCollider action in Simulated Object Inspector failed.";
|
||||
|
||||
// Now do the same thing using the Simulated Object Inspector context menu.
|
||||
@@ -536,7 +557,7 @@ namespace EMotionFX
|
||||
delAction->trigger();
|
||||
|
||||
// Check that we have the number of colliders we started we expect.
|
||||
const size_t numCollidersAfterSecondRemove = PhysicsSetupUtils::CountColliders(m_actor.get(), PhysicsSetup::SimulatedObjectCollider);
|
||||
const size_t numCollidersAfterSecondRemove = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider);
|
||||
ASSERT_EQ(numCollidersAfterSecondRemove, numCollidersAfterAdd - 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <Editor/ReselectingTreeView.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/UI/ModalPopupHandler.h>
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
#include <Tests/D6JointLimitConfiguration.h>
|
||||
@@ -52,9 +53,11 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C14603914");
|
||||
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(7, "CanAddToSimulatedObjectActor");
|
||||
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 7, "CanAddToSimulatedObjectActor");
|
||||
Actor* actor = actorAsset->GetActor();
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor);
|
||||
|
||||
// Change the Editor mode to Simulated Objects
|
||||
EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects");
|
||||
@@ -165,9 +168,11 @@ namespace EMotionFX
|
||||
});
|
||||
|
||||
RecordProperty("test_case_id", "C13291807");
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(7, "CanAddToSimulatedObjectActor");
|
||||
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 7, "CanAddToSimulatedObjectActor");
|
||||
Actor* actor = actorAsset->GetActor();
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor);
|
||||
|
||||
// Change the Editor mode to Physics
|
||||
EMStudio::GetMainWindow()->ApplicationModeChanged("Physics");
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <Editor/Plugins/SimulatedObject/SimulatedObjectWidget.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/UI/ModalPopupHandler.h>
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
|
||||
@@ -37,9 +38,10 @@ namespace EMotionFX
|
||||
{
|
||||
RecordProperty("test_case_id", "C14519563");
|
||||
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(7, "CanAddToSimulatedObjectActor");
|
||||
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 7, "CanAddToSimulatedObjectActor");
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actorAsset->GetActor());
|
||||
|
||||
// Change the Editor mode to Simulated Objects
|
||||
EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects");
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Editor/Plugins/SimulatedObject/SimulatedObjectWidget.h>
|
||||
#include <Editor/Plugins/SkeletonOutliner/SkeletonOutlinerPlugin.h>
|
||||
#include <EMotionFX/Rendering/OpenGL2/Source/GraphicsManager.h>
|
||||
#include <EMotionFX/Source/AnimGraphReferenceNode.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
|
||||
#include <EMotionFX/CommandSystem/Source/AnimGraphNodeCommands.h>
|
||||
#include <EMotionFX/CommandSystem/Source/MotionCommands.h>
|
||||
@@ -141,8 +143,10 @@ namespace EMotionFX
|
||||
{
|
||||
if (EMotionFX::GetActorManager().GetNumActorInstances() == 0)
|
||||
{
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(2, "CanAddSimulatedObjectWithJointsActor");
|
||||
ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 2, "CanAddSimulatedObjectWithJointsActor");
|
||||
ActorInstance::Create(actorAsset->GetActor());
|
||||
|
||||
EXPECT_EQ(EMotionFX::GetActorManager().GetNumActorInstances(), 1) << "Failed to create actor set for reset test.";
|
||||
}
|
||||
@@ -152,15 +156,16 @@ namespace EMotionFX
|
||||
{
|
||||
if (EMotionFX::GetActorManager().GetNumActorInstances() == 0)
|
||||
{
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(2, "CanAddSimulatedObjectWithJointsActor");
|
||||
ActorInstance::Create(actor.get());
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(
|
||||
actorAssetId, 2, "CanAddSimulatedObjectWithJointsActor");
|
||||
ActorInstance::Create(actorAsset->GetActor());
|
||||
|
||||
EXPECT_EQ(EMotionFX::GetActorManager().GetNumActorInstances(), 1) << "Failed to create actor set for reset test.";
|
||||
|
||||
actor->SetFileName(filename);
|
||||
actorAsset->GetActor()->SetFileName(filename);
|
||||
|
||||
AZStd::string stringFilename = filename;
|
||||
ExporterLib::SaveActor(stringFilename, actor.get(), MCore::Endian::ENDIAN_LITTLE);
|
||||
ExporterLib::SaveActor(stringFilename, actorAsset->GetActor(), MCore::Endian::ENDIAN_LITTLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +244,6 @@ namespace EMotionFX
|
||||
|
||||
// Load the actor we just saved, with replaceScene set to true to represent a load.
|
||||
LoadActor(actorFilename.toUtf8().data(), true);
|
||||
|
||||
ASSERT_EQ(EMotionFX::GetActorManager().GetNumActorInstances(), 1) << "Failed to load Actor.";
|
||||
|
||||
// Do it again to verify that number of actors stays the same when replaceScene is true.
|
||||
@@ -696,7 +700,10 @@ namespace EMotionFX
|
||||
|
||||
TestResetMenuItem(fileMenu);
|
||||
|
||||
TestActorMenus(fileMenu);
|
||||
// Temporarily disable loading actor test.
|
||||
// This is because the importer command now load actor asset instead of reading from disk. We do not want to add dependency to the asset processor
|
||||
// in this test.
|
||||
// TestActorMenus(fileMenu);
|
||||
|
||||
TestSaveAllMenuItem(fileMenu);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <Editor/InputDialogValidatable.h>
|
||||
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
|
||||
#include <EMotionFX/Source/Actor.h>
|
||||
#include <EMotionFX/Source/AutoRegisteredActor.h>
|
||||
#include <EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/DockWidgetPlugin.h>
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioPlugin.h>
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -102,7 +103,9 @@ namespace EMotionFX
|
||||
const int lastIndex = 6;
|
||||
RecordProperty("test_case_id", "C18970351");
|
||||
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(numJoints, "RagdollEditTestsActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, numJoints, "RagdollEditTestsActor");
|
||||
|
||||
CreateSkeletonAndModelIndices();
|
||||
EXPECT_EQ(m_indexList.size(), numJoints);
|
||||
|
||||
@@ -80,11 +80,14 @@ namespace EMotionFX
|
||||
DataMembers m_data;
|
||||
};
|
||||
|
||||
AZStd::unique_ptr<Actor> CreateLODActor(int numLODs)
|
||||
AZ::Data::Asset<Integration::ActorAsset> CreateLODActor(int numLODs)
|
||||
{
|
||||
AZStd::unique_ptr<Actor> actor = ActorFactory::CreateAndInit<PlaneActor>("LODSkinnedMeshTestsActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<PlaneActor>(actorAssetId, "LODSkinnedMeshTestsActor");
|
||||
|
||||
// Modify the actor to have numLODs LOD levels.
|
||||
Actor* actor = actorAsset->GetActor();
|
||||
Mesh* lodMesh = actor->GetMesh(0, 0);
|
||||
StandardMaterial* dummyMat = StandardMaterial::Create("Dummy Material");
|
||||
actor->AddMaterial(0, dummyMat); // owns the material
|
||||
@@ -97,7 +100,7 @@ namespace EMotionFX
|
||||
actor->AddMaterial(i, dummyMat->Clone());
|
||||
}
|
||||
|
||||
return actor;
|
||||
return AZStd::move(actorAsset);
|
||||
}
|
||||
|
||||
class LODPropertyRowWidget
|
||||
@@ -112,9 +115,8 @@ namespace EMotionFX
|
||||
const int numLODs = GetParam();
|
||||
RecordProperty("test_case_id", "C29202698");
|
||||
|
||||
AutoRegisteredActor actor = CreateLODActor(numLODs);
|
||||
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actor.get());
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset = CreateLODActor(numLODs);
|
||||
ActorInstance* actorInstance = ActorInstance::Create(actorAsset->GetActor());
|
||||
|
||||
// Change the Editor mode to Character
|
||||
EMStudio::GetMainWindow()->ApplicationModeChanged("Character");
|
||||
@@ -166,8 +168,7 @@ namespace EMotionFX
|
||||
gameEntity->SetId(entityId);
|
||||
|
||||
AZ::Data::AssetId actorAssetId("{85D3EF54-7400-43F8-8A40-F6BCBF534E54}");
|
||||
AZStd::unique_ptr<Actor> actor = CreateLODActor(numLODs);
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset = TestActorAssets::GetAssetFromActor(actorAssetId, AZStd::move(actor));
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset = CreateLODActor(numLODs);
|
||||
|
||||
gameEntity->CreateComponent<AzFramework::TransformComponent>();
|
||||
Integration::ActorComponent::Configuration actorConf;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
|
||||
#include <Tests/TestAssetCode/ActorFactory.h>
|
||||
#include <Tests/TestAssetCode/SimpleActors.h>
|
||||
#include <Tests/TestAssetCode/TestActorAssets.h>
|
||||
#include <Tests/UI/UIFixture.h>
|
||||
|
||||
#include <Editor/ReselectingTreeView.h>
|
||||
@@ -110,7 +111,9 @@ namespace EMotionFX
|
||||
const int numJoints = 6;
|
||||
RecordProperty("test_case_id", "C3122249");
|
||||
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(numJoints, "RagdollEditTestsActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, numJoints, "RagdollEditTestsActor");
|
||||
|
||||
CreateSkeletonAndModelIndices();
|
||||
|
||||
@@ -138,7 +141,9 @@ namespace EMotionFX
|
||||
const int numJoints = 8;
|
||||
RecordProperty("test_case_id", "C3122248");
|
||||
|
||||
AutoRegisteredActor actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(numJoints, "RagdollEditTestsActor");
|
||||
AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}");
|
||||
AZ::Data::Asset<Integration::ActorAsset> actorAsset =
|
||||
TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, numJoints, "RagdollEditTestsActor");
|
||||
|
||||
CreateSkeletonAndModelIndices();
|
||||
EXPECT_EQ(m_indexList.size(), numJoints);
|
||||
|
||||
Reference in New Issue
Block a user