From 5a4476a0e426fbb45260cf0fab8c90f497642929 Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Tue, 21 Sep 2021 10:26:41 -0700 Subject: [PATCH] Minor fixes to variable names and comments. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../FocusMode/FocusModeInterface.h | 14 +++---- .../FocusMode/FocusModeSystemComponent.cpp | 40 +++++++++---------- .../FocusMode/FocusModeSystemComponent.h | 9 +++-- .../Prefab/PrefabFocusHandler.cpp | 33 +++++---------- .../Prefab/PrefabFocusHandler.h | 9 +++-- .../Prefab/PrefabFocusInterface.h | 8 ++-- 6 files changed, 51 insertions(+), 62 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h index 70bb320a96..b2d008ca36 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h @@ -13,26 +13,26 @@ namespace AzToolsFramework { - /*! - * FocusModeInterface - * Interface to handle the Editor Focus Mode. - */ + //! FocusModeInterface + //! Interface to handle the Editor Focus Mode. class FocusModeInterface { public: AZ_RTTI(FocusModeInterface, "{437243B0-F86B-422F-B7B8-4A21CC000702}"); //! Sets the root entity the Editor should focus on. - //! The Editor will only allow the user to select entities belonging to the sub-tree that has root in the entityId provided. + //! The Editor will only allow the user to select entities that are descendants of the EntityId provided. //! @param entityId The entityId that will become the new focus root. virtual void SetFocusRoot(AZ::EntityId entityId) = 0; + //! Clears the Editor focus, allowing the user to select the whole level again. + virtual void ClearFocusRoot() = 0; + //! Returns the entity id of the root of the current Editor focus. - //! @return The id of the entity that is the root of the Editor focus. + //! @return The entity id of the root of the Editor focus, or an invalid entity id if no focus is set. virtual AZ::EntityId GetFocusRoot() = 0; //! Returns whether the entity id provided is part of the focused sub-tree. - //! @return True if entityId belongs to the focused sub-tree, false otherwise. virtual bool IsInFocusSubTree(AZ::EntityId entityId) = 0; }; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp index fcca452bf5..e609aa2f48 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp @@ -15,6 +15,24 @@ namespace AzToolsFramework { + bool IsInFocusSubTree(AZ::EntityId entityId, AZ::EntityId focusRootId) + { + if (entityId == AZ::EntityId()) + { + return false; + } + + if (entityId == focusRootId) + { + return true; + } + + AZ::EntityId parentId; + AZ::TransformBus::EventResult(parentId, entityId, &AZ::TransformInterface::GetParentId); + + return IsInFocusSubTree(parentId, focusRootId); + } + FocusModeSystemComponent::~FocusModeSystemComponent() { AZ::Interface::Unregister(this); @@ -33,7 +51,7 @@ namespace AzToolsFramework { } - void FocusModeSystemComponent::Reflect(AZ::ReflectContext* /*context*/) + void FocusModeSystemComponent::Reflect([[maybe_unused]] AZ::ReflectContext* context) { } @@ -69,25 +87,7 @@ namespace AzToolsFramework return true; } - return IsInFocusSubTree_helper(entityId, m_focusRoot); - } - - bool FocusModeSystemComponent::IsInFocusSubTree_helper(AZ::EntityId entityId, AZ::EntityId focusRootId) - { - if (entityId == AZ::EntityId()) - { - return false; - } - - if (entityId == focusRootId) - { - return true; - } - - AZ::EntityId parentId; - AZ::TransformBus::EventResult(parentId, entityId, &AZ::TransformInterface::GetParentId); - - return IsInFocusSubTree_helper(parentId, focusRootId); + return AzToolsFramework::IsInFocusSubTree(entityId, m_focusRoot); } } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.h b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.h index 284515eeb7..2a2b1500ac 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.h @@ -15,6 +15,9 @@ namespace AzToolsFramework { + bool IsInFocusSubTree(AZ::EntityId entityId, AZ::EntityId focusRootId); + + //! System Component to handle the Editor Focus Mode system class FocusModeSystemComponent final : public AZ::Component , private FocusModeInterface @@ -25,7 +28,7 @@ namespace AzToolsFramework FocusModeSystemComponent() = default; virtual ~FocusModeSystemComponent(); - // AZ::Component... + // AZ::Component overrides ... void Init() override; void Activate() override; void Deactivate() override; @@ -35,14 +38,12 @@ namespace AzToolsFramework static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); - // FocusModeInterface... + // FocusModeInterface overrides ... void SetFocusRoot(AZ::EntityId entityId) override; AZ::EntityId GetFocusRoot() override; bool IsInFocusSubTree(AZ::EntityId entityId) override; private: - static bool IsInFocusSubTree_helper(AZ::EntityId entityId, AZ::EntityId focusRootId); - AZ::EntityId m_focusRoot; }; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp index 63921cff21..bdd1b63afd 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp @@ -14,10 +14,6 @@ namespace AzToolsFramework::Prefab { - FocusModeInterface* PrefabFocusHandler::s_focusModeInterface = nullptr; - InstanceEntityMapperInterface* PrefabFocusHandler::s_instanceEntityMapperInterface = nullptr; - PrefabEditorEntityOwnershipInterface* PrefabFocusHandler::s_prefabEditorEntityOwnershipInterface = nullptr; - PrefabFocusHandler::~PrefabFocusHandler() { AZ::Interface::Unregister(this); @@ -25,23 +21,23 @@ namespace AzToolsFramework::Prefab void PrefabFocusHandler::Initialize() { - s_focusModeInterface = AZ::Interface::Get(); + m_focusModeInterface = AZ::Interface::Get(); AZ_Assert( - s_focusModeInterface, + m_focusModeInterface, "Prefab - PrefabFocusHandler - " "Focus Mode Interface could not be found. " "Check that it is being correctly initialized."); - s_instanceEntityMapperInterface = AZ::Interface::Get(); + m_instanceEntityMapperInterface = AZ::Interface::Get(); AZ_Assert( - s_instanceEntityMapperInterface, + m_instanceEntityMapperInterface, "Prefab - PrefabFocusHandler - " "Instance Entity Mapper Interface could not be found. " "Check that it is being correctly initialized."); - s_prefabEditorEntityOwnershipInterface = AZ::Interface::Get(); + m_prefabEditorEntityOwnershipInterface = AZ::Interface::Get(); AZ_Assert( - s_prefabEditorEntityOwnershipInterface, + m_prefabEditorEntityOwnershipInterface, "Prefab - PrefabFocusHandler - " "Prefab Editor Entity Ownership Interface could not be found. " "Check that it is being correctly initialized."); @@ -51,16 +47,9 @@ namespace AzToolsFramework::Prefab PrefabFocusOperationResult PrefabFocusHandler::FocusOnOwningPrefab(AZ::EntityId entityId) { - InstanceOptionalReference focusedInstance; - - if (entityId == AZ::EntityId()) - { - focusedInstance = s_prefabEditorEntityOwnershipInterface->GetRootPrefabInstance(); - } - else - { - focusedInstance = s_instanceEntityMapperInterface->FindOwningInstance(entityId); - } + InstanceOptionalReference focusedInstance = (entityId == AZ::EntityId()) + ? m_prefabEditorEntityOwnershipInterface->GetRootPrefabInstance() + : m_instanceEntityMapperInterface->FindOwningInstance(entityId); if (!focusedInstance.has_value()) { @@ -70,7 +59,7 @@ namespace AzToolsFramework::Prefab m_focusedInstance = focusedInstance; m_focusedTemplateId = focusedInstance->get().GetTemplateId(); - s_focusModeInterface->SetFocusRoot(focusedInstance->get().GetContainerEntityId()); + m_focusModeInterface->SetFocusRoot(focusedInstance->get().GetContainerEntityId()); return AZ::Success(); } @@ -92,7 +81,7 @@ namespace AzToolsFramework::Prefab return false; } - InstanceOptionalReference instance = s_instanceEntityMapperInterface->FindOwningInstance(entityId); + InstanceOptionalReference instance = m_instanceEntityMapperInterface->FindOwningInstance(entityId); return instance.has_value() && (&instance->get() == &m_focusedInstance->get()); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h index 6a2ff2f62e..60038d9bb8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h @@ -24,6 +24,7 @@ namespace AzToolsFramework::Prefab { class InstanceEntityMapperInterface; + //! Handles Prefab Focus mode, determining which prefab file entity changes will target. class PrefabFocusHandler final : private PrefabFocusInterface { @@ -34,7 +35,7 @@ namespace AzToolsFramework::Prefab void Initialize(); - // PrefabFocusInterface... + // PrefabFocusInterface override ... PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) override; TemplateId GetFocusedPrefabTemplateId() override; InstanceOptionalReference GetFocusedPrefabInstance() override; @@ -44,9 +45,9 @@ namespace AzToolsFramework::Prefab InstanceOptionalReference m_focusedInstance; TemplateId m_focusedTemplateId; - static FocusModeInterface* s_focusModeInterface; - static InstanceEntityMapperInterface* s_instanceEntityMapperInterface; - static PrefabEditorEntityOwnershipInterface* s_prefabEditorEntityOwnershipInterface; + FocusModeInterface* m_focusModeInterface; + InstanceEntityMapperInterface* m_instanceEntityMapperInterface; + PrefabEditorEntityOwnershipInterface* m_prefabEditorEntityOwnershipInterface; }; } // namespace AzToolsFramework::Prefab diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h index 7b867ab8d2..c7f58f5de2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h @@ -16,17 +16,15 @@ namespace AzToolsFramework::Prefab { - typedef AZ::Outcome PrefabFocusOperationResult; + using PrefabFocusOperationResult = AZ::Outcome; - /*! - * PrefabFocusInterface - */ + //! Interface to handle operations related to the Prefab Focus system. class PrefabFocusInterface { public: AZ_RTTI(PrefabFocusInterface, "{F3CFA37B-5FD8-436A-9C30-60EB54E350E1}"); - //! Set the focused prefab instance to the owning instance of the entityId provided + //! Set the focused prefab instance to the owning instance of the entityId provided. //! @param entityId The entityId of the entity whose owning instance we want the prefab system to focus on. virtual PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) = 0;