+1
-2
@@ -71,8 +71,7 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto tracker = AZ::Interface<ViewportEditorModeTrackerInterface>::Get();
|
||||
tracker != nullptr)
|
||||
if (auto tracker = AZ::Interface<ViewportEditorModeTrackerInterface>::Get())
|
||||
{
|
||||
if (!m_focusRoot.IsValid() && entityId.IsValid())
|
||||
{
|
||||
|
||||
+13
-19
@@ -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<ContainerEntityInterface>::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(
|
||||
|
||||
+10
-12
@@ -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; //<! The entity id under the cursor.
|
||||
AZ::EntityId m_rootEntityId; //<! For prefabs, the root entity id, otherwise the entity id under the cursor.
|
||||
AZ::EntityId m_containerAncestorEntityId; //<! For entities in container entities, the topmost container entity id in the hierarchy, otherwise the entity id under the cursor.
|
||||
};
|
||||
|
||||
//! EditorHelpers are the visualizations that appear for entities
|
||||
@@ -68,9 +66,9 @@ namespace AzToolsFramework
|
||||
EditorHelpers& operator=(const EditorHelpers&) = delete;
|
||||
~EditorHelpers() = default;
|
||||
|
||||
//! Determines the id of the entity under the cursor (if any). For prefabs, also determines the root entity id.
|
||||
//! Finds the id of the entity under the cursor (if any). For entities in container entities, also finds the topmost container entity id in the hierarchy.
|
||||
//! Used to check if a particular entity was selected.
|
||||
EntityIdUnderCursor GetEntityIdUnderCursor(
|
||||
CursorEntityIdQuery FindEntityIdUnderCursor(
|
||||
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->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)
|
||||
|
||||
+13
-13
@@ -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<Prefab::PrefabFocusInterface>::Get();
|
||||
if (prefabFocusInterface)
|
||||
if (auto prefabFocusInterface = AZ::Interface<Prefab::PrefabFocusInterface>::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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user