Double click entity in prefab to enter FocusMode.
Signed-off-by: John <jonawals@amazon.com>
This commit is contained in:
+33
-4
@@ -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<ContainerEntityInterface>::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(
|
||||
|
||||
@@ -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; //<! The entity id under the cursor.
|
||||
AZ::EntityId m_rootEntityId; //<! For prefabs, the root entity id, otherwise the entity id under the cursor.
|
||||
};
|
||||
|
||||
//! EditorHelpers are the visualizations that appear for entities
|
||||
//! when 'Display Helpers' is toggled on inside the editor.
|
||||
//! These include but are not limited to entity icons and shape visualizations.
|
||||
@@ -44,9 +60,9 @@ namespace AzToolsFramework
|
||||
EditorHelpers& operator=(const EditorHelpers&) = delete;
|
||||
~EditorHelpers() = default;
|
||||
|
||||
//! Handle any mouse interaction with the EditorHelpers.
|
||||
//! Determines the id of the entity under the cursor (if any). For prefabs, also determines the root entity id.
|
||||
//! Used to check if a particular entity was selected.
|
||||
AZ::EntityId HandleMouseInteraction(
|
||||
EntityIdUnderCursor GetEntityIdUnderCursor(
|
||||
const AzFramework::CameraState& cameraState, const ViewportInteraction::MouseInteractionEvent& mouseInteraction);
|
||||
|
||||
//! Do the drawing responsible for the EditorHelpers.
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ namespace AzToolsFramework
|
||||
|
||||
const AzFramework::CameraState cameraState = GetCameraState(viewportId);
|
||||
|
||||
m_cachedEntityIdUnderCursor = m_editorHelpers->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)
|
||||
|
||||
+24
-9
@@ -27,6 +27,7 @@
|
||||
#include <AzToolsFramework/Manipulators/ScaleManipulators.h>
|
||||
#include <AzToolsFramework/Manipulators/TranslationManipulators.h>
|
||||
#include <AzToolsFramework/Maths/TransformUtils.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabFocusInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorLockComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
|
||||
@@ -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<Prefab::PrefabFocusInterface>::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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user