diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.cpp index 64f7f2dd97..edd2f074fe 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.cpp @@ -34,6 +34,6 @@ namespace AZ::EMotionFXAtom void EditorSystemComponent::OnRegisterPlugin() { EMStudio::PluginManager* pluginManager = EMStudio::EMStudioManager::GetInstance()->GetPluginManager(); - pluginManager->RegisterPlugin(new EMStudio::AtomRenderPlugin()); + pluginManager->RegisterPlugin(aznew EMStudio::AtomRenderPlugin()); } } // namespace AZ::EMotionFXAtom diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.h index 9da98bcf42..80ff7b0b8d 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/Editor/EditorSystemComponent.h @@ -22,7 +22,7 @@ namespace AZ::EMotionFXAtom static void Reflect(ReflectContext* context); protected: - // AZ::Component + // AZ::Component overrides void Activate() override; void Deactivate() override; diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp index a75095568f..08f85ab1be 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp @@ -59,7 +59,6 @@ namespace EMStudio m_frameworkScene->SetSubsystem(m_entityContext.get()); // Create and register a scene with all available feature processors - // TODO: We don't need every procesors, only register the processor we are going to use. AZ::RPI::SceneDescriptor sceneDesc; m_scene = AZ::RPI::Scene::CreateScene(sceneDesc); m_scene->EnableAllFeatureProcessors(); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp index 948006e2b5..90f6d54466 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp @@ -11,11 +11,14 @@ #include #include +#include #include #include namespace EMStudio { + AZ_CLASS_ALLOCATOR_IMPL(AtomRenderPlugin, EMotionFX::EditorAllocator, 0); + AtomRenderPlugin::AtomRenderPlugin() : DockWidgetPlugin() { @@ -74,6 +77,7 @@ namespace EMStudio void AtomRenderPlugin::ReinitRenderer() { m_animViewportWidget->GetAnimViewportRenderer()->Reinit(); + m_animViewportWidget->ResetCameraPosition(); } bool AtomRenderPlugin::Init() @@ -89,10 +93,10 @@ namespace EMStudio verticalLayout->addWidget(m_animViewportWidget); // Register command callbacks. - m_createActorInstanceCallback = new CreateActorInstanceCallback(false); - m_removeActorInstanceCallback = new RemoveActorInstanceCallback(false); - EMStudioManager::GetInstance()->GetCommandManager()->RegisterCommandCallback("CreateActorInstance", m_createActorInstanceCallback); - EMStudioManager::GetInstance()->GetCommandManager()->RegisterCommandCallback("RemoveActorInstance", m_removeActorInstanceCallback); + m_importActorCallback = new ImportActorCallback(false); + m_removeActorCallback = new RemoveActorCallback(false); + EMStudioManager::GetInstance()->GetCommandManager()->RegisterCommandCallback("ImportActor", m_importActorCallback); + EMStudioManager::GetInstance()->GetCommandManager()->RegisterCommandCallback("RemoveActor", m_removeActorCallback); return true; } @@ -113,23 +117,23 @@ namespace EMStudio return true; } - bool AtomRenderPlugin::CreateActorInstanceCallback::Execute( + bool AtomRenderPlugin::ImportActorCallback::Execute( [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) { return ReinitAtomRenderPlugin(); } - bool AtomRenderPlugin::CreateActorInstanceCallback::Undo( + bool AtomRenderPlugin::ImportActorCallback::Undo( [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) { return ReinitAtomRenderPlugin(); } - bool AtomRenderPlugin::RemoveActorInstanceCallback::Execute( + bool AtomRenderPlugin::RemoveActorCallback::Execute( [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) { return ReinitAtomRenderPlugin(); } - bool AtomRenderPlugin::RemoveActorInstanceCallback::Undo( + bool AtomRenderPlugin::RemoveActorCallback::Undo( [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) { return ReinitAtomRenderPlugin(); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h index 475fd34180..e890f9aa4b 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h @@ -27,6 +27,8 @@ namespace EMStudio : public DockWidgetPlugin { public: + AZ_CLASS_ALLOCATOR_DECL + enum { CLASS_ID = 0x32b0c04d @@ -49,10 +51,10 @@ namespace EMStudio void ReinitRenderer(); private: - MCORE_DEFINECOMMANDCALLBACK(CreateActorInstanceCallback); - MCORE_DEFINECOMMANDCALLBACK(RemoveActorInstanceCallback); - CreateActorInstanceCallback* m_createActorInstanceCallback; - RemoveActorInstanceCallback* m_removeActorInstanceCallback; + MCORE_DEFINECOMMANDCALLBACK(ImportActorCallback); + MCORE_DEFINECOMMANDCALLBACK(RemoveActorCallback); + ImportActorCallback* m_importActorCallback; + RemoveActorCallback* m_removeActorCallback; QWidget* m_innerWidget; AnimViewportWidget* m_animViewportWidget; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.cpp index 0593575623..be3ac10d45 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.cpp @@ -31,7 +31,6 @@ namespace EMotionFX SetScheduler(MultiThreadScheduler::Create()); // reserve memory - m_actorAssets.reserve(32); m_actorInstances.reserve(1024); m_rootActorInstances.reserve(1024); } @@ -429,7 +428,7 @@ namespace EMotionFX } - ActorManager::ActorAssetData ActorManager::GetActorAsset(size_t nr) const + ActorAssetData ActorManager::GetActorAsset(size_t nr) const { return m_actorAssets[nr]; } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.h b/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.h index e8bbf40661..003153b36c 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/ActorManager.h @@ -42,7 +42,6 @@ namespace EMotionFX friend class EMotionFXManager; public: - using ActorAssetData = AZ::Data::Asset; static ActorManager* Create(); /** diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeWindow/NodeWindowPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeWindow/NodeWindowPlugin.h index 4c530fffdc..59c9f78719 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeWindow/NodeWindowPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeWindow/NodeWindowPlugin.h @@ -90,6 +90,7 @@ namespace EMStudio AZStd::unique_ptr m_actorInfo; AZStd::unique_ptr m_nodeInfo; + // Use this flag to defer the reinit function to main thread. bool m_reinitRequested = false; }; } // namespace EMStudio diff --git a/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h b/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h index 325191af81..4161b3c77d 100644 --- a/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h +++ b/Gems/EMotionFX/Code/Include/Integration/ActorComponentBus.h @@ -98,7 +98,6 @@ namespace EMotionFX // Use this to alter the actor asset. virtual void SetActorAsset(AZ::Data::Asset actorAsset) = 0; - // virtual AZ::Data::Asset GetAsset() const = 0; static const size_t s_invalidJointIndex = std::numeric_limits::max(); }; diff --git a/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.h b/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.h index c256fa5283..4b13603ed5 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.h +++ b/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.h @@ -80,6 +80,8 @@ namespace EMotionFX const char* GetBrowserIcon() const override; }; } // namespace Integration + + using ActorAssetData = AZ::Data::Asset; } // namespace EMotionFX namespace AZ