From 65f3f26339149e37e15aa3d6b4d469dc886db947 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 13 Oct 2021 18:19:06 +0100 Subject: [PATCH 1/6] Fix issue with activating/deactivating FocusMode. Signed-off-by: John --- .../AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp index af518afd66..19bde5f3a8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp @@ -71,9 +71,6 @@ namespace AzToolsFramework return; } - m_focusRoot = entityId; - FocusModeNotificationBus::Broadcast(&FocusModeNotifications::OnEditorFocusChanged, m_focusRoot); - if (auto tracker = AZ::Interface::Get(); tracker != nullptr) { @@ -86,6 +83,9 @@ namespace AzToolsFramework tracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Focus); } } + + m_focusRoot = entityId; + FocusModeNotificationBus::Broadcast(&FocusModeNotifications::OnEditorFocusChanged, m_focusRoot); } void FocusModeSystemComponent::ClearFocusRoot([[maybe_unused]] AzFramework::EntityContextId entityContextId) From 2e7c8a0fd2093eab3b6de9f607e0d6a175a56e47 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 13 Oct 2021 18:49:49 +0100 Subject: [PATCH 2/6] Double click entity in prefab to enter FocusMode. Signed-off-by: John --- .../ViewportSelection/EditorHelpers.cpp | 37 +++++++++++++++++-- .../ViewportSelection/EditorHelpers.h | 20 +++++++++- .../EditorPickEntitySelection.cpp | 2 +- .../EditorTransformComponentSelection.cpp | 33 ++++++++++++----- 4 files changed, 76 insertions(+), 16 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp index 3ce350287f..0311cdbd54 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp @@ -114,6 +114,34 @@ namespace AzToolsFramework } } + EntityIdUnderCursor::EntityIdUnderCursor(AZ::EntityId entityId) + : m_entityId(entityId) + , m_rootEntityId(entityId) + { + } + + EntityIdUnderCursor::EntityIdUnderCursor(AZ::EntityId entityId, AZ::EntityId rootEntityId) + : m_entityId(entityId) + , m_rootEntityId(rootEntityId) + { + } + + AZ::EntityId EntityIdUnderCursor::GetEntityId() const + { + return m_entityId; + } + + AZ::EntityId EntityIdUnderCursor::GetRootEntityId() const + { + return m_rootEntityId; + } + + bool EntityIdUnderCursor::IsChildEntity() const + { + return m_entityId != m_rootEntityId; + } + + EditorHelpers::EditorHelpers(const EditorVisibleEntityDataCache* entityDataCache) : m_entityDataCache(entityDataCache) { @@ -125,7 +153,7 @@ namespace AzToolsFramework "Check that it is being correctly initialized."); } - AZ::EntityId EditorHelpers::HandleMouseInteraction( + EntityIdUnderCursor EditorHelpers::GetEntityIdUnderCursor( const AzFramework::CameraState& cameraState, const ViewportInteraction::MouseInteractionEvent& mouseInteraction) { AZ_PROFILE_FUNCTION(AzToolsFramework); @@ -189,7 +217,7 @@ namespace AzToolsFramework // Verify if the entity Id corresponds to an entity that is focused; if not, halt selection. if (!m_focusModeInterface->IsInFocusSubTree(entityIdUnderCursor)) { - return AZ::EntityId(); + return EntityIdUnderCursor(AZ::EntityId()); } // Container Entity support - if the entity that is being selected is part of a closed container, @@ -197,10 +225,11 @@ namespace AzToolsFramework ContainerEntityInterface* containerEntityInterface = AZ::Interface::Get(); if (containerEntityInterface) { - return containerEntityInterface->FindHighestSelectableEntity(entityIdUnderCursor); + const auto highestSelectableEntity = containerEntityInterface->FindHighestSelectableEntity(entityIdUnderCursor); + return EntityIdUnderCursor(entityIdUnderCursor, highestSelectableEntity); } - return entityIdUnderCursor; + return EntityIdUnderCursor(entityIdUnderCursor); } void EditorHelpers::DisplayHelpers( diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h index a6a78a4e61..b9fc27971b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h @@ -29,6 +29,22 @@ namespace AzToolsFramework struct MouseInteractionEvent; } + //!< Represents the result of a query to find the id of the entity under the cursor (if any). + class EntityIdUnderCursor + { + public: + EntityIdUnderCursor(AZ::EntityId entityId); + EntityIdUnderCursor(AZ::EntityId entityId, AZ::EntityId rootEntityId); + + AZ::EntityId GetEntityId() const; + AZ::EntityId GetRootEntityId() const; + bool IsChildEntity() const; + + private: + AZ::EntityId m_entityId; //HandleMouseInteraction(cameraState, mouseInteraction); + m_cachedEntityIdUnderCursor = m_editorHelpers->GetEntityIdUnderCursor(cameraState, mouseInteraction).GetRootEntityId(); // when left clicking, if we successfully clicked an entity, assign that // to the entity field selected in the entity inspector (RPE) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index 7015a25ce1..a9e0d70a5b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -1799,7 +1800,8 @@ namespace AzToolsFramework const AzFramework::ViewportId viewportId = mouseInteraction.m_mouseInteraction.m_interactionId.m_viewportId; const AzFramework::CameraState cameraState = GetCameraState(viewportId); - m_cachedEntityIdUnderCursor = m_editorHelpers->HandleMouseInteraction(cameraState, mouseInteraction); + const auto entityIdsUnderCursor = m_editorHelpers->GetEntityIdUnderCursor(cameraState, mouseInteraction); + m_cachedEntityIdUnderCursor = entityIdsUnderCursor.GetRootEntityId(); const auto selectClickEvent = ClickDetectorEventFromViewportInteraction(mouseInteraction); m_cursorState.SetCurrentPosition(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates); @@ -1825,8 +1827,6 @@ namespace AzToolsFramework } } - const AZ::EntityId entityIdUnderCursor = m_cachedEntityIdUnderCursor; - EditorContextMenuUpdate(m_contextMenu, mouseInteraction); m_boxSelect.HandleMouseInteraction(mouseInteraction); @@ -1842,6 +1842,21 @@ namespace AzToolsFramework return true; } + if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::DoubleClick && + mouseInteraction.m_mouseInteraction.m_mouseButtons.Left()) + { + if (entityIdsUnderCursor.IsChildEntity()) + { + auto prefabFocusInterface = AZ::Interface::Get(); + if (prefabFocusInterface) + { + // Focus on this prefab + prefabFocusInterface->FocusOnOwningPrefab(entityIdsUnderCursor.GetRootEntityId()); + return false; + } + } + } + bool stickySelect = false; ViewportInteraction::ViewportSettingsRequestBus::EventResult( stickySelect, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::StickySelectEnabled); @@ -1863,7 +1878,7 @@ namespace AzToolsFramework // select/deselect (add/remove) entities with ctrl held if (Input::AdditiveIndividualSelect(clickOutcome, mouseInteraction)) { - if (SelectDeselect(entityIdUnderCursor)) + if (SelectDeselect(m_cachedEntityIdUnderCursor)) { if (m_selectedEntityIds.empty()) { @@ -1877,13 +1892,13 @@ namespace AzToolsFramework if (!m_selectedEntityIds.empty()) { // group copying/alignment to specific entity - 'ditto' position/orientation for group - if (Input::GroupDitto(mouseInteraction) && PerformGroupDitto(entityIdUnderCursor)) + if (Input::GroupDitto(mouseInteraction) && PerformGroupDitto(m_cachedEntityIdUnderCursor)) { return false; } // individual copying/alignment to specific entity - 'ditto' position/orientation for individual - if (Input::IndividualDitto(mouseInteraction) && PerformIndividualDitto(entityIdUnderCursor)) + if (Input::IndividualDitto(mouseInteraction) && PerformIndividualDitto(m_cachedEntityIdUnderCursor)) { return false; } @@ -1898,7 +1913,7 @@ namespace AzToolsFramework // set manipulator pivot override translation or orientation (update manipulators) if (Input::ManipulatorDitto(clickOutcome, mouseInteraction)) { - PerformManipulatorDitto(entityIdUnderCursor); + PerformManipulatorDitto(m_cachedEntityIdUnderCursor); return false; } @@ -1913,11 +1928,11 @@ namespace AzToolsFramework { if (!stickySelect) { - ChangeSelectedEntity(entityIdUnderCursor); + ChangeSelectedEntity(m_cachedEntityIdUnderCursor); } else { - SelectDeselect(entityIdUnderCursor); + SelectDeselect(m_cachedEntityIdUnderCursor); } } From 06910a7c82ad6440458eed024fcfb6fe8fd5e0fa Mon Sep 17 00:00:00 2001 From: John Date: Wed, 13 Oct 2021 18:58:43 +0100 Subject: [PATCH 3/6] Add API comments. Signed-off-by: John --- .../ViewportSelection/EditorHelpers.cpp | 2 +- .../AzToolsFramework/ViewportSelection/EditorHelpers.h | 10 +++++++++- .../EditorTransformComponentSelection.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp index 933a8c9ee4..7cdd87d0ae 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp @@ -136,7 +136,7 @@ namespace AzToolsFramework return m_rootEntityId; } - bool EntityIdUnderCursor::IsChildEntity() const + bool EntityIdUnderCursor::IsPrefabEntity() const { return m_entityId != m_rootEntityId; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h index 0a108c709a..cd99087852 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h @@ -36,9 +36,17 @@ namespace AzToolsFramework EntityIdUnderCursor(AZ::EntityId entityId); EntityIdUnderCursor(AZ::EntityId entityId, AZ::EntityId rootEntityId); + //! Returns the entity id under the cursor (if any). + //! @note In the case of no entity id under the cursor, an invalid entity id is returned. AZ::EntityId GetEntityId() const; + + //! Returns the root entity id if the entity id under the cursor is part of a prefab, otherwise returns the entity id. + //! @note In the case of no entity id under the cursor, an invalid entity id is returned. AZ::EntityId GetRootEntityId() const; - bool IsChildEntity() const; + + //! Returns true if the entity id under the cursor is part of a prefab, otherwise false. + //! @note In the case of no entity id under the cursor, true is returned (although consider this behavior undefined). + bool IsPrefabEntity() const; private: AZ::EntityId m_entityId; //::Get(); if (prefabFocusInterface) From f9740ae25ccefc2de0782c886578aa5988159682 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 13 Oct 2021 19:00:40 +0100 Subject: [PATCH 4/6] Remove undefined behavior. Signed-off-by: John --- .../AzToolsFramework/ViewportSelection/EditorHelpers.cpp | 5 +++++ .../AzToolsFramework/ViewportSelection/EditorHelpers.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp index 7cdd87d0ae..c67352d02f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp @@ -138,6 +138,11 @@ namespace AzToolsFramework bool EntityIdUnderCursor::IsPrefabEntity() const { + if (m_entityId == AZ::EntityId()) + { + return false; + } + return m_entityId != m_rootEntityId; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h index cd99087852..43282180db 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h @@ -45,7 +45,7 @@ namespace AzToolsFramework AZ::EntityId GetRootEntityId() const; //! Returns true if the entity id under the cursor is part of a prefab, otherwise false. - //! @note In the case of no entity id under the cursor, true is returned (although consider this behavior undefined). + //! @note In the case of no entity id under the cursor, false is returned. bool IsPrefabEntity() const; private: From 396530b2741b5bbc872d7d13c4b877f74b160eea Mon Sep 17 00:00:00 2001 From: John Date: Fri, 15 Oct 2021 11:18:17 +0100 Subject: [PATCH 5/6] Address PR feedback. Signed-off-by: John --- .../FocusMode/FocusModeSystemComponent.cpp | 3 +- .../ViewportSelection/EditorHelpers.cpp | 32 ++++++++----------- .../ViewportSelection/EditorHelpers.h | 22 ++++++------- .../EditorPickEntitySelection.cpp | 2 +- .../EditorTransformComponentSelection.cpp | 26 +++++++-------- 5 files changed, 38 insertions(+), 47 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp index 19bde5f3a8..e45b817bd5 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp @@ -71,8 +71,7 @@ namespace AzToolsFramework return; } - if (auto tracker = AZ::Interface::Get(); - tracker != nullptr) + if (auto tracker = AZ::Interface::Get()) { if (!m_focusRoot.IsValid() && entityId.IsValid()) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp index c67352d02f..f193aa669c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp @@ -114,36 +114,30 @@ namespace AzToolsFramework } } - EntityIdUnderCursor::EntityIdUnderCursor(AZ::EntityId entityId) + CursorEntityIdQuery::CursorEntityIdQuery(AZ::EntityId entityId, AZ::EntityId rootEntityId) : m_entityId(entityId) - , m_rootEntityId(entityId) + , m_containerAncestorEntityId(rootEntityId) { } - EntityIdUnderCursor::EntityIdUnderCursor(AZ::EntityId entityId, AZ::EntityId rootEntityId) - : m_entityId(entityId) - , m_rootEntityId(rootEntityId) - { - } - - AZ::EntityId EntityIdUnderCursor::GetEntityId() const + AZ::EntityId CursorEntityIdQuery::EntityIdUnderCursor() const { return m_entityId; } - AZ::EntityId EntityIdUnderCursor::GetRootEntityId() const + AZ::EntityId CursorEntityIdQuery::ContainerAncestorEntityId() const { - return m_rootEntityId; + return m_containerAncestorEntityId; } - bool EntityIdUnderCursor::IsPrefabEntity() const + bool CursorEntityIdQuery::HasContainerAncestorEntityId() const { - if (m_entityId == AZ::EntityId()) + if (m_entityId.IsValid()) { - return false; + return m_entityId != m_containerAncestorEntityId; } - return m_entityId != m_rootEntityId; + return false; } @@ -158,7 +152,7 @@ namespace AzToolsFramework "Check that it is being correctly initialized."); } - EntityIdUnderCursor EditorHelpers::GetEntityIdUnderCursor( + CursorEntityIdQuery EditorHelpers::FindEntityIdUnderCursor( const AzFramework::CameraState& cameraState, const ViewportInteraction::MouseInteractionEvent& mouseInteraction) { AZ_PROFILE_FUNCTION(AzToolsFramework); @@ -222,7 +216,7 @@ namespace AzToolsFramework // Verify if the entity Id corresponds to an entity that is focused; if not, halt selection. if (!IsSelectableAccordingToFocusMode(entityIdUnderCursor)) { - return EntityIdUnderCursor(AZ::EntityId()); + return CursorEntityIdQuery(AZ::EntityId(), AZ::EntityId()); } // Container Entity support - if the entity that is being selected is part of a closed container, @@ -230,10 +224,10 @@ namespace AzToolsFramework if (ContainerEntityInterface* containerEntityInterface = AZ::Interface::Get()) { const auto highestSelectableEntity = containerEntityInterface->FindHighestSelectableEntity(entityIdUnderCursor); - return EntityIdUnderCursor(entityIdUnderCursor, highestSelectableEntity); + return CursorEntityIdQuery(entityIdUnderCursor, highestSelectableEntity); } - return EntityIdUnderCursor(entityIdUnderCursor); + return CursorEntityIdQuery(entityIdUnderCursor, AZ::EntityId()); } void EditorHelpers::DisplayHelpers( diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h index 43282180db..c399847c0b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h @@ -30,27 +30,25 @@ namespace AzToolsFramework } //!< Represents the result of a query to find the id of the entity under the cursor (if any). - class EntityIdUnderCursor + class CursorEntityIdQuery { public: - EntityIdUnderCursor(AZ::EntityId entityId); - EntityIdUnderCursor(AZ::EntityId entityId, AZ::EntityId rootEntityId); + CursorEntityIdQuery(AZ::EntityId entityId, AZ::EntityId rootEntityId); //! Returns the entity id under the cursor (if any). //! @note In the case of no entity id under the cursor, an invalid entity id is returned. - AZ::EntityId GetEntityId() const; + AZ::EntityId EntityIdUnderCursor() const; - //! Returns the root entity id if the entity id under the cursor is part of a prefab, otherwise returns the entity id. + //! Returns the topmost container entity id in the hierarchy if the entity id under the cursor is inside a container entity, otherwise returns the entity id. //! @note In the case of no entity id under the cursor, an invalid entity id is returned. - AZ::EntityId GetRootEntityId() const; + AZ::EntityId ContainerAncestorEntityId() const; - //! Returns true if the entity id under the cursor is part of a prefab, otherwise false. - //! @note In the case of no entity id under the cursor, false is returned. - bool IsPrefabEntity() const; + //! Returns true if the query has a container ancestor entity id, otherwise false. + bool HasContainerAncestorEntityId() const; private: AZ::EntityId m_entityId; //GetEntityIdUnderCursor(cameraState, mouseInteraction).GetRootEntityId(); + m_cachedEntityIdUnderCursor = m_editorHelpers->FindEntityIdUnderCursor(cameraState, mouseInteraction).ContainerAncestorEntityId(); // when left clicking, if we successfully clicked an entity, assign that // to the entity field selected in the entity inspector (RPE) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index b2b8d9733e..e970745d0c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -1800,8 +1800,8 @@ namespace AzToolsFramework const AzFramework::ViewportId viewportId = mouseInteraction.m_mouseInteraction.m_interactionId.m_viewportId; const AzFramework::CameraState cameraState = GetCameraState(viewportId); - const auto entityIdsUnderCursor = m_editorHelpers->GetEntityIdUnderCursor(cameraState, mouseInteraction); - m_cachedEntityIdUnderCursor = entityIdsUnderCursor.GetRootEntityId(); + const auto cursorEntityIdQuery = m_editorHelpers->FindEntityIdUnderCursor(cameraState, mouseInteraction); + m_cachedEntityIdUnderCursor = cursorEntityIdQuery.ContainerAncestorEntityId(); const auto selectClickEvent = ClickDetectorEventFromViewportInteraction(mouseInteraction); m_cursorState.SetCurrentPosition(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates); @@ -1842,16 +1842,16 @@ namespace AzToolsFramework return true; } + const AZ::EntityId entityIdUnderCursor = m_cachedEntityIdUnderCursor; + if (mouseInteraction.m_mouseEvent == ViewportInteraction::MouseEvent::DoubleClick && mouseInteraction.m_mouseInteraction.m_mouseButtons.Left()) { - if (entityIdsUnderCursor.IsPrefabEntity()) + if (cursorEntityIdQuery.HasContainerAncestorEntityId()) { - auto prefabFocusInterface = AZ::Interface::Get(); - if (prefabFocusInterface) + if (auto prefabFocusInterface = AZ::Interface::Get()) { - // Focus on this prefab - prefabFocusInterface->FocusOnOwningPrefab(entityIdsUnderCursor.GetRootEntityId()); + prefabFocusInterface->FocusOnOwningPrefab(cursorEntityIdQuery.ContainerAncestorEntityId()); return false; } } @@ -1878,7 +1878,7 @@ namespace AzToolsFramework // select/deselect (add/remove) entities with ctrl held if (Input::AdditiveIndividualSelect(clickOutcome, mouseInteraction)) { - if (SelectDeselect(m_cachedEntityIdUnderCursor)) + if (SelectDeselect(entityIdUnderCursor)) { if (m_selectedEntityIds.empty()) { @@ -1892,13 +1892,13 @@ namespace AzToolsFramework if (!m_selectedEntityIds.empty()) { // group copying/alignment to specific entity - 'ditto' position/orientation for group - if (Input::GroupDitto(mouseInteraction) && PerformGroupDitto(m_cachedEntityIdUnderCursor)) + if (Input::GroupDitto(mouseInteraction) && PerformGroupDitto(entityIdUnderCursor)) { return false; } // individual copying/alignment to specific entity - 'ditto' position/orientation for individual - if (Input::IndividualDitto(mouseInteraction) && PerformIndividualDitto(m_cachedEntityIdUnderCursor)) + if (Input::IndividualDitto(mouseInteraction) && PerformIndividualDitto(entityIdUnderCursor)) { return false; } @@ -1913,7 +1913,7 @@ namespace AzToolsFramework // set manipulator pivot override translation or orientation (update manipulators) if (Input::ManipulatorDitto(clickOutcome, mouseInteraction)) { - PerformManipulatorDitto(m_cachedEntityIdUnderCursor); + PerformManipulatorDitto(entityIdUnderCursor); return false; } @@ -1928,11 +1928,11 @@ namespace AzToolsFramework { if (!stickySelect) { - ChangeSelectedEntity(m_cachedEntityIdUnderCursor); + ChangeSelectedEntity(entityIdUnderCursor); } else { - SelectDeselect(m_cachedEntityIdUnderCursor); + SelectDeselect(entityIdUnderCursor); } } From 363bc33fedfb0e43e266681de3c8a9582dae4a71 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 18 Oct 2021 09:25:33 +0100 Subject: [PATCH 6/6] Fix broken function name. Signed-off-by: John --- .../ViewportSelection/EditorTransformComponentSelection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index 602780391d..39c882b766 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -1851,7 +1851,7 @@ namespace AzToolsFramework { if (auto prefabFocusInterface = AZ::Interface::Get()) { - prefabFocusInterface->FocusOnOwningPrefab(cursorEntityIdQuery.ContainerAncestorEntityId()); + prefabFocusInterface->FocusOnPrefabInstanceOwningEntityId(cursorEntityIdQuery.ContainerAncestorEntityId()); return false; } }