diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp index c39012d303..131cbd7053 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp @@ -51,7 +51,7 @@ namespace EMStudio const char* AtomRenderPlugin::GetName() const { - return "Atom Render Window (Preview)"; + return "Atom Render Window"; } uint32 AtomRenderPlugin::GetClassID() const diff --git a/Gems/EMotionFX/Assets/Editor/Layouts/AnimGraph.layout b/Gems/EMotionFX/Assets/Editor/Layouts/AnimGraph.layout index e85d6054a3..62c9e1bb4e 100644 Binary files a/Gems/EMotionFX/Assets/Editor/Layouts/AnimGraph.layout and b/Gems/EMotionFX/Assets/Editor/Layouts/AnimGraph.layout differ diff --git a/Gems/EMotionFX/Assets/Editor/Layouts/Animation.layout b/Gems/EMotionFX/Assets/Editor/Layouts/Animation.layout index ec5a4d1da3..e4c2333f7f 100644 Binary files a/Gems/EMotionFX/Assets/Editor/Layouts/Animation.layout and b/Gems/EMotionFX/Assets/Editor/Layouts/Animation.layout differ diff --git a/Gems/EMotionFX/Assets/Editor/Layouts/Character.layout b/Gems/EMotionFX/Assets/Editor/Layouts/Character.layout index 5d42b49035..cfaf839c85 100644 Binary files a/Gems/EMotionFX/Assets/Editor/Layouts/Character.layout and b/Gems/EMotionFX/Assets/Editor/Layouts/Character.layout differ diff --git a/Gems/EMotionFX/Assets/Editor/Layouts/Physics.layout b/Gems/EMotionFX/Assets/Editor/Layouts/Physics.layout index 2e59ab6b0e..ffde15b367 100644 Binary files a/Gems/EMotionFX/Assets/Editor/Layouts/Physics.layout and b/Gems/EMotionFX/Assets/Editor/Layouts/Physics.layout differ diff --git a/Gems/EMotionFX/Assets/Editor/Layouts/SimulatedObjects.layout b/Gems/EMotionFX/Assets/Editor/Layouts/SimulatedObjects.layout index f52df642e8..e1db7060ac 100644 Binary files a/Gems/EMotionFX/Assets/Editor/Layouts/SimulatedObjects.layout and b/Gems/EMotionFX/Assets/Editor/Layouts/SimulatedObjects.layout differ diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/OpenGLRenderPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/OpenGLRenderPlugin.h index a0e7d1e3b4..aba1023d24 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/OpenGLRenderPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/OpenGLRenderPlugin.h @@ -35,7 +35,7 @@ namespace EMStudio // plugin information const char* GetCompileDate() const override { return MCORE_DATE; } - const char* GetName() const override { return "OpenGL Render Window"; } + const char* GetName() const override { return "OpenGL Render Window (Deprecated)"; } uint32 GetClassID() const override { return static_cast(RenderPlugin::CLASS_ID); } const char* GetCreatorName() const override { return "O3DE"; } float GetVersion() const override { return 1.0f; } diff --git a/Gems/EMotionFX/Code/Tests/Mocks/AtomRenderPlugin.h b/Gems/EMotionFX/Code/Tests/Mocks/AtomRenderPlugin.h new file mode 100644 index 0000000000..5be74a5d41 --- /dev/null +++ b/Gems/EMotionFX/Code/Tests/Mocks/AtomRenderPlugin.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace EMStudio +{ + // The Mock version of AtomRenderPlugin. It have the same name, class_id and type of the actual version. + // The actual implementation of the AtomRenderPlugin is defined outside of EMotionFX gem. This Mock version + // exists so we could load the default layouts without errors. + class MockAtomRenderPlugin + : public DockWidgetPlugin + { + enum + { + CLASS_ID = 0x32b0c04d + }; + + // Plugin information + const char* GetName() const override + { + return "Atom Render Window"; + }; + uint32 GetClassID() const override + { + return CLASS_ID; + }; + + bool Init() override + { + return true; + }; + + EMStudioPlugin* Clone() + { + return new MockAtomRenderPlugin(); + }; + + EMStudioPlugin::EPluginType GetPluginType() const override + { + return EMStudioPlugin::PLUGINTYPE_RENDERING; + }; + }; + +} diff --git a/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteColliders.cpp b/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteColliders.cpp index 17f07b2180..5e3eff1453 100644 --- a/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteColliders.cpp +++ b/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteColliders.cpp @@ -40,11 +40,6 @@ namespace EMotionFX UIFixture::SetUp(); - AZ::SerializeContext* serializeContext = GetSerializeContext(); - - Physics::MockPhysicsSystem::Reflect(serializeContext); // Required by Ragdoll plugin to fake PhysX Gem is available - D6JointLimitConfiguration::Reflect(serializeContext); - EXPECT_CALL(m_jointHelpers, GetSupportedJointTypeIds) .WillRepeatedly(testing::Return(AZStd::vector{ azrtti_typeid() })); @@ -68,7 +63,9 @@ namespace EMotionFX { return AZStd::make_unique(); }); } - private: + protected: + virtual bool ShouldReflectPhysicSystem() override { return true; } + Physics::MockPhysicsSystem m_physicsSystem; Physics::MockPhysicsInterface m_physicsInterface; Physics::MockJointHelpersInterface m_jointHelpers; @@ -116,7 +113,6 @@ namespace EMotionFX auto* ragdollPlugin = EMStudio::GetPluginManager()->FindActivePlugin(); ASSERT_TRUE(ragdollPlugin) << "Ragdoll plugin not found."; - ragdollPlugin->Init(); auto* skeletonOutlinerPlugin = EMStudio::GetPluginManager()->FindActivePlugin(); ASSERT_TRUE(skeletonOutlinerPlugin) << "Skeleton outliner plugin not found."; diff --git a/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteJointLimits.cpp b/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteJointLimits.cpp index 3f475c7916..6ff00e4e1b 100644 --- a/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteJointLimits.cpp +++ b/Gems/EMotionFX/Code/Tests/ProvidesUI/Ragdoll/CanCopyPasteJointLimits.cpp @@ -31,6 +31,8 @@ namespace EMotionFX { class CopyPasteRagdollJointLimitsFixture : public UIFixture { + protected: + virtual bool ShouldReflectPhysicSystem() override { return true; } }; #if AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_EDITOR_TESTS @@ -41,16 +43,10 @@ namespace EMotionFX { using testing::_; - AZ::SerializeContext* serializeContext = GetSerializeContext(); - - Physics::MockPhysicsSystem::Reflect(serializeContext); // Required by Ragdoll plugin to fake PhysX Gem is available - D6JointLimitConfiguration::Reflect(serializeContext); - EMStudio::GetMainWindow()->ApplicationModeChanged("Physics"); auto ragdollPlugin = static_cast(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::RagdollNodeInspectorPlugin::CLASS_ID)); ASSERT_TRUE(ragdollPlugin) << "Ragdoll plugin not found."; - ragdollPlugin->Init(); Physics::MockPhysicsSystem physicsSystem; Physics::MockPhysicsInterface physicsInterface; diff --git a/Gems/EMotionFX/Code/Tests/UI/CanAddToSimulatedObject.cpp b/Gems/EMotionFX/Code/Tests/UI/CanAddToSimulatedObject.cpp index a10ba352d2..de4eb001c3 100644 --- a/Gems/EMotionFX/Code/Tests/UI/CanAddToSimulatedObject.cpp +++ b/Gems/EMotionFX/Code/Tests/UI/CanAddToSimulatedObject.cpp @@ -34,19 +34,8 @@ namespace EMotionFX class CanAddToSimulatedObjectFixture : public UIFixture { - public: - void SetUp() override - { - SetupQtAndFixtureBase(); - - AZ::SerializeContext* serializeContext = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext); - - Physics::MockPhysicsSystem::Reflect(serializeContext); // Required by Ragdoll plugin to fake PhysX Gem is available - D6JointLimitConfiguration::Reflect(serializeContext); - - SetupPluginWindows(); - } + protected: + virtual bool ShouldReflectPhysicSystem() override { return true; } }; TEST_F(CanAddToSimulatedObjectFixture, CanAddExistingJointsAndUnaddedChildren) diff --git a/Gems/EMotionFX/Code/Tests/UI/ClothColliderTests.cpp b/Gems/EMotionFX/Code/Tests/UI/ClothColliderTests.cpp index d87c35a4fa..59066ca1b8 100644 --- a/Gems/EMotionFX/Code/Tests/UI/ClothColliderTests.cpp +++ b/Gems/EMotionFX/Code/Tests/UI/ClothColliderTests.cpp @@ -49,18 +49,6 @@ namespace EMotionFX class ClothColliderTestsFixture : public UIFixture { public: - void SetUp() override - { - SetupQtAndFixtureBase(); - - AZ::SerializeContext* serializeContext = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext); - - SystemComponent::Reflect(serializeContext); - - SetupPluginWindows(); - } - void TearDown() override { QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); @@ -86,6 +74,19 @@ namespace EMotionFX } protected: + bool ShouldReflectPhysicSystem() override { return true; } + + void ReflectMockedSystems() override + { + UIFixture::ReflectMockedSystems(); + + // Reflect the mocked version of the cloth system. + AZ::SerializeContext* serializeContext = nullptr; + AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext); + + SystemComponent::Reflect(serializeContext); + } + QModelIndexList m_indexList; ReselectingTreeView* m_treeView; EMotionFX::SkeletonOutlinerPlugin* m_skeletonOutliner; diff --git a/Gems/EMotionFX/Code/Tests/UI/RagdollEditTests.cpp b/Gems/EMotionFX/Code/Tests/UI/RagdollEditTests.cpp index d097e67d15..94b659ab91 100644 --- a/Gems/EMotionFX/Code/Tests/UI/RagdollEditTests.cpp +++ b/Gems/EMotionFX/Code/Tests/UI/RagdollEditTests.cpp @@ -31,18 +31,12 @@ namespace EMotionFX { class RagdollEditTestsFixture : public UIFixture { - public: + public: void SetUp() override { - using ::testing::_; - - SetupQtAndFixtureBase(); - - AZ::SerializeContext* serializeContext = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext); + UIFixture::SetUp(); - Physics::MockPhysicsSystem::Reflect(serializeContext); // Required by Ragdoll plugin to fake PhysX Gem is available - D6JointLimitConfiguration::Reflect(serializeContext); + using ::testing::_; EXPECT_CALL(m_jointHelpers, GetSupportedJointTypeIds) .WillRepeatedly(testing::Return(AZStd::vector{ azrtti_typeid() })); @@ -67,7 +61,6 @@ namespace EMotionFX return AZStd::make_unique(); }); - SetupPluginWindows(); } void TearDown() override @@ -95,6 +88,8 @@ namespace EMotionFX } protected: + virtual bool ShouldReflectPhysicSystem() override { return true; } + QModelIndexList m_indexList; ReselectingTreeView* m_treeView; EMotionFX::SkeletonOutlinerPlugin* m_skeletonOutliner; diff --git a/Gems/EMotionFX/Code/Tests/UI/UIFixture.cpp b/Gems/EMotionFX/Code/Tests/UI/UIFixture.cpp index ea1f1c9148..2a1c7b190d 100644 --- a/Gems/EMotionFX/Code/Tests/UI/UIFixture.cpp +++ b/Gems/EMotionFX/Code/Tests/UI/UIFixture.cpp @@ -8,6 +8,9 @@ #include #include +#include +#include +#include #include #include @@ -69,6 +72,7 @@ namespace EMotionFX // Set ignore visibilty so that the visibility check can be ignored in plugins EMStudio::GetManager()->SetIgnoreVisibility(true); } + void UIFixture::SetupPluginWindows() { // Plugins have to be created after both the QApplication object and @@ -81,11 +85,30 @@ namespace EMotionFX } } + void UIFixture::ReflectMockedSystems() + { + if (ShouldReflectPhysicSystem()) + { + AZ::SerializeContext* serializeContext = GetSerializeContext(); + + Physics::MockPhysicsSystem::Reflect(serializeContext); // Required by Ragdoll plugin to fake PhysX Gem is available + D6JointLimitConfiguration::Reflect(serializeContext); + } + } + + void UIFixture::OnRegisterPlugin() + { + EMStudio::PluginManager* pluginManager = EMStudio::EMStudioManager::GetInstance()->GetPluginManager(); + pluginManager->RegisterPlugin(new EMStudio::MockAtomRenderPlugin()); + } void UIFixture::SetUp() { + Integration::SystemNotificationBus::Handler::BusConnect(); + using namespace testing; SetupQtAndFixtureBase(); + ReflectMockedSystems(); SetupPluginWindows(); m_animGraphPlugin = static_cast(EMStudio::GetPluginManager()->FindActivePlugin(EMStudio::AnimGraphPlugin::CLASS_ID)); @@ -97,6 +120,7 @@ namespace EMotionFX void UIFixture::TearDown() { m_assetSystemRequestMock.BusDisconnect(); + Integration::SystemNotificationBus::Handler::BusDisconnect(); CloseAllNotificationWindows(); DeselectAllAnimGraphNodes(); diff --git a/Gems/EMotionFX/Code/Tests/UI/UIFixture.h b/Gems/EMotionFX/Code/Tests/UI/UIFixture.h index 7d22f0ce58..59b517ee33 100644 --- a/Gems/EMotionFX/Code/Tests/UI/UIFixture.h +++ b/Gems/EMotionFX/Code/Tests/UI/UIFixture.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -68,6 +69,7 @@ namespace EMotionFX class UIFixture : public MakeQtApplicationBase , public UIFixtureBase + , private Integration::SystemNotificationBus::Handler { public: void SetUp() override; @@ -108,6 +110,10 @@ namespace EMotionFX SimulatedObjectColliderWidget* GetSimulatedObjectColliderWidget() const; protected: + virtual bool ShouldReflectPhysicSystem() { return false; } + virtual void ReflectMockedSystems(); + + void OnRegisterPlugin(); void SetupQtAndFixtureBase(); void SetupPluginWindows(); diff --git a/Gems/EMotionFX/Code/emotionfx_editor_tests_files.cmake b/Gems/EMotionFX/Code/emotionfx_editor_tests_files.cmake index c7e0e57256..ee71677f9a 100644 --- a/Gems/EMotionFX/Code/emotionfx_editor_tests_files.cmake +++ b/Gems/EMotionFX/Code/emotionfx_editor_tests_files.cmake @@ -99,5 +99,6 @@ set(FILES Tests/EMotionFXBuilderFixture.cpp Tests/TestAssetCode/TestActorAssets.h Tests/TestAssetCode/TestActorAssets.cpp + Tests/Mocks/AtomRenderPlugin.h Tests/Mocks/PhysicsSystem.h )