From 09f9e5c6c35a04327e35a663282df16f3082906e Mon Sep 17 00:00:00 2001 From: rhhong Date: Tue, 28 Sep 2021 22:48:14 -0700 Subject: [PATCH] CR feedback Signed-off-by: rhhong --- .../Code/Tools/EMStudio/AnimViewportRenderer.cpp | 5 ++--- .../Code/Tools/EMStudio/AnimViewportRenderer.h | 6 +++--- .../Code/Tools/EMStudio/AnimViewportWidget.h | 2 +- .../Code/Tools/EMStudio/AtomRenderPlugin.cpp | 13 +++++++++++++ .../Code/Tools/EMStudio/AtomRenderPlugin.h | 2 ++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp index f3294ddc09..c98a244d8f 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp @@ -40,7 +40,6 @@ namespace EMStudio { static constexpr float DepthNear = 0.01f; - static constexpr const char* const s_actorComponentTypeId = "{BDC97E7F-A054-448B-A26F-EA2B5D78E377}"; AnimViewportRenderer::AnimViewportRenderer(AZStd::shared_ptr windowContext) : m_windowContext(windowContext) @@ -229,7 +228,7 @@ namespace EMStudio void AnimViewportRenderer::ReinitActorEntities() { - // 1. Destroy all the entities that does not point to any actorAsset anymore. + // 1. Destroy all the entities that do not point to any actorAsset anymore. AZStd::set assetLookup; AzFramework::EntityContext* entityContext = m_entityContext.get(); const size_t numActors = EMotionFX::GetActorManager().GetNumActors(); @@ -285,7 +284,7 @@ namespace EMStudio AZ::Entity* AnimViewportRenderer::CreateActorEntity(AZ::Data::Asset actorAsset) { AZ::Entity* actorEntity = m_entityContext->CreateEntity(actorAsset->GetActor()->GetName()); - actorEntity->CreateComponent(s_actorComponentTypeId); + actorEntity->CreateComponent(azrtti_typeid()); actorEntity->CreateComponent(AZ::Render::MaterialComponentTypeId); actorEntity->CreateComponent(azrtti_typeid()); actorEntity->Activate(); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h index c131605caa..8671068199 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h @@ -51,11 +51,11 @@ namespace EMStudio private: - // This function reset the light, camera and other environment settings. + // This function resets the light, camera and other environment settings. void ResetEnvironment(); - // This function create in-editor entities for all the actor asset stored in the actor manager, - // and delete all the actor entities that no longer has an actor asset in the actor manager. + // This function creates in-editor entities for all actor assets stored in the actor manager, + // and deletes all the actor entities that no longer has an actor asset in the actor manager. // Those entities are used in atom render viewport to visualize actors in animation editor. void ReinitActorEntities(); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportWidget.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportWidget.h index 9e074c1d2c..6d1d91ac0d 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportWidget.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportWidget.h @@ -19,7 +19,7 @@ namespace EMStudio { public: AnimViewportWidget(QWidget* parent = nullptr); - AnimViewportRenderer* GetAnimViewportRenderer() { return m_renderer.get();} + AnimViewportRenderer* GetAnimViewportRenderer() { return m_renderer.get(); } private: AZStd::unique_ptr m_renderer; diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp index 735c90d762..1f35212b8b 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp @@ -89,7 +89,9 @@ namespace EMStudio // 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); return true; } @@ -121,4 +123,15 @@ namespace EMStudio return ReinitAtomRenderPlugin(); } + bool AtomRenderPlugin::RemoveActorInstanceCallback::Execute( + [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) + { + return ReinitAtomRenderPlugin(); + } + bool AtomRenderPlugin::RemoveActorInstanceCallback::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 9e5b3b6937..475fd34180 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h @@ -50,7 +50,9 @@ namespace EMStudio private: MCORE_DEFINECOMMANDCALLBACK(CreateActorInstanceCallback); + MCORE_DEFINECOMMANDCALLBACK(RemoveActorInstanceCallback); CreateActorInstanceCallback* m_createActorInstanceCallback; + RemoveActorInstanceCallback* m_removeActorInstanceCallback; QWidget* m_innerWidget; AnimViewportWidget* m_animViewportWidget;