Merge branch 'development' into optimization/unused_files
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> # Conflicts: # Code/Editor/IEditorImpl.cpp # Code/Editor/IEditorImpl.h # Gems/LmbrCentral/Code/Tests/lmbrcentral_editor_tests_files.cmake
This commit is contained in:
+47
-36
@@ -8,13 +8,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzFramework/Render/GeometryIntersectionStructures.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorSelectionAccentSystemComponent.h>
|
||||
|
||||
class CEntityObject;
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
struct ViewportInfo;
|
||||
@@ -22,56 +20,68 @@ namespace AzFramework
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/// Bus for customizing Entity selection logic from within the EditorComponents.
|
||||
/// Used to provide with custom implementation for Ray intersection tests, specifying AABB, etc.
|
||||
class EditorComponentSelectionRequests
|
||||
: public AZ::ComponentBus
|
||||
//! Bus for customizing Entity selection logic from within the EditorComponents.
|
||||
//! Used to provide with custom implementation for Ray intersection tests, specifying AABB, etc.
|
||||
class EditorComponentSelectionRequests : public AZ::ComponentBus
|
||||
{
|
||||
public:
|
||||
/// @brief Returns an AABB that encompasses the object.
|
||||
/// @return AABB that encompasses the object.
|
||||
/// @note ViewportInfo may be necessary if the all or part of the object
|
||||
/// stays at a constant size regardless of camera position.
|
||||
virtual AZ::Aabb GetEditorSelectionBoundsViewport(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/)
|
||||
//! @brief Returns an AABB that encompasses the object.
|
||||
//! @return AABB that encompasses the object.
|
||||
//! @note ViewportInfo may be necessary if the all or part of the object
|
||||
//! stays at a constant size regardless of camera position.
|
||||
virtual AZ::Aabb GetEditorSelectionBoundsViewport([[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo)
|
||||
{
|
||||
AZ_Assert(!SupportsEditorRayIntersect(),
|
||||
AZ_Assert(
|
||||
!SupportsEditorRayIntersect(),
|
||||
"Component claims to support ray intersection but GetEditorSelectionBoundsViewport "
|
||||
"has not been implemented in the derived class");
|
||||
|
||||
return AZ::Aabb::CreateNull();
|
||||
}
|
||||
|
||||
/// @brief Returns true if editor selection ray intersects with the handler.
|
||||
/// @return True if the editor selection ray intersects the handler.
|
||||
/// @note ViewportInfo may be necessary if the all or part of the object
|
||||
/// stays at a constant size regardless of camera position.
|
||||
//! @brief Returns true if editor selection ray intersects with the handler.
|
||||
//! @return True if the editor selection ray intersects the handler.
|
||||
//! @note ViewportInfo may be necessary if the all or part of the object
|
||||
//! stays at a constant size regardless of camera position.
|
||||
virtual bool EditorSelectionIntersectRayViewport(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/,
|
||||
const AZ::Vector3& /*src*/, const AZ::Vector3& /*dir*/, float& /*distance*/)
|
||||
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo,
|
||||
[[maybe_unused]] const AZ::Vector3& src,
|
||||
[[maybe_unused]] const AZ::Vector3& dir,
|
||||
[[maybe_unused]] float& distance)
|
||||
{
|
||||
AZ_Assert(!SupportsEditorRayIntersect(),
|
||||
AZ_Assert(
|
||||
!SupportsEditorRayIntersect(),
|
||||
"Component claims to support ray intersection but EditorSelectionIntersectRayViewport "
|
||||
"has not been implemented in the derived class");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Returns true if the component overrides EditorSelectionIntersectRay method,
|
||||
/// otherwise selection will be based only on AABB test.
|
||||
/// @return True if EditorSelectionIntersectRay method is implemented.
|
||||
virtual bool SupportsEditorRayIntersect() { return false; }
|
||||
//! @brief Returns if the component overrides EditorSelectionIntersectRay(Viewport) interface,
|
||||
//! otherwise selection will be based only on an AABB test.
|
||||
virtual bool SupportsEditorRayIntersect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! @brief Returns if the component overrides EditorSelectionIntersectRay(Viewport) interface,
|
||||
//! otherwise selection will be based only on an AABB test.
|
||||
//! @note Overload of SupportsEditorRayIntersect which accepts a ViewportInfo containing the ViewportId, this can be used to
|
||||
//! lookup the intersection setting per viewport.
|
||||
virtual bool SupportsEditorRayIntersectViewport([[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo)
|
||||
{
|
||||
return SupportsEditorRayIntersect();
|
||||
}
|
||||
|
||||
protected:
|
||||
~EditorComponentSelectionRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorComponentSelectionRequests.
|
||||
//! Type to inherit to implement EditorComponentSelectionRequests.
|
||||
using EditorComponentSelectionRequestsBus = AZ::EBus<EditorComponentSelectionRequests>;
|
||||
|
||||
/// Bus that provides notifications about selection events of the parent Entity.
|
||||
class EditorComponentSelectionNotifications
|
||||
: public AZ::EBusTraits
|
||||
//! Bus that provides notifications about selection events of the parent Entity.
|
||||
class EditorComponentSelectionNotifications : public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
// EBusTraits overrides
|
||||
@@ -79,20 +89,21 @@ namespace AzToolsFramework
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
typedef AZ::EntityId BusIdType;
|
||||
|
||||
/// @brief Notifies listeners about in-editor selection events (mouse hover, selected, etc.)
|
||||
virtual void OnAccentTypeChanged(EntityAccentType /*accent*/) {}
|
||||
//! @brief Notifies listeners about in-editor selection events (mouse hover, selected, etc.)
|
||||
virtual void OnAccentTypeChanged([[maybe_unused]] EntityAccentType accent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
~EditorComponentSelectionNotifications() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorComponentSelectionNotifications.
|
||||
//! Type to inherit to implement EditorComponentSelectionNotifications.
|
||||
using EditorComponentSelectionNotificationsBus = AZ::EBus<EditorComponentSelectionNotifications>;
|
||||
|
||||
/// Returns the union of all editor selection bounds on a given Entity.
|
||||
/// @note The returned Aabb is in world space.
|
||||
inline AZ::Aabb CalculateEditorEntitySelectionBounds(
|
||||
const AZ::EntityId entityId, const AzFramework::ViewportInfo& viewportInfo)
|
||||
//! Returns the union of all editor selection bounds on a given Entity.
|
||||
//! @note The returned Aabb is in world space.
|
||||
inline AZ::Aabb CalculateEditorEntitySelectionBounds(const AZ::EntityId entityId, const AzFramework::ViewportInfo& viewportInfo)
|
||||
{
|
||||
AZ::EBusReduceResult<AZ::Aabb, AzFramework::AabbUnionAggregator> aabbResult(AZ::Aabb::CreateNull());
|
||||
EditorComponentSelectionRequestsBus::EventResult(
|
||||
|
||||
+2
-4
@@ -177,7 +177,6 @@ namespace AzToolsFramework
|
||||
auto data = index.data(AssetBrowserModel::Roles::EntryRole);
|
||||
if (data.canConvert<const AssetBrowserEntry*>())
|
||||
{
|
||||
bool isEnabled = (option.state & QStyle::State_Enabled) != 0;
|
||||
|
||||
QStyle* style = option.widget ? option.widget->style() : QApplication::style();
|
||||
|
||||
@@ -223,7 +222,6 @@ namespace AzToolsFramework
|
||||
// sources with no children should be greyed out.
|
||||
if (sourceEntry->GetChildCount() == 0)
|
||||
{
|
||||
isEnabled = false; // draw in disabled style.
|
||||
actualPalette.setCurrentColorGroup(QPalette::Disabled);
|
||||
}
|
||||
}
|
||||
@@ -285,7 +283,7 @@ namespace AzToolsFramework
|
||||
initStyleOption(&optionV4, index);
|
||||
optionV4.state &= ~(QStyle::State_HasFocus | QStyle::State_Selected);
|
||||
|
||||
if (m_assetBrowserFilerModel && m_assetBrowserFilerModel->GetStringFilter()
|
||||
if (m_assetBrowserFilerModel && m_assetBrowserFilerModel->GetStringFilter()
|
||||
&& !m_assetBrowserFilerModel->GetStringFilter()->GetFilterString().isEmpty())
|
||||
{
|
||||
displayString = RichTextHighlighter::HighlightText(displayString, m_assetBrowserFilerModel->GetStringFilter()->GetFilterString());
|
||||
@@ -316,7 +314,7 @@ namespace AzToolsFramework
|
||||
absoluteIconPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / TreeIconPathOneChild;
|
||||
break;
|
||||
}
|
||||
[[maybe_unused]] bool pixmapLoadedSuccess = pixmap.load(absoluteIconPath.c_str());
|
||||
[[maybe_unused]] bool pixmapLoadedSuccess = pixmap.load(absoluteIconPath.c_str());
|
||||
AZ_Assert(pixmapLoadedSuccess, "Error loading Branch Icons in SearchEntryDelegate");
|
||||
|
||||
m_branchIcons[static_cast<EntryBranchType>(branchType)] = pixmap;
|
||||
|
||||
@@ -63,9 +63,12 @@ namespace AzToolsFramework
|
||||
/// Registers an existing set of entities with the editor context.
|
||||
virtual void AddEditorEntities(const EntityList& entities) = 0;
|
||||
|
||||
/// Registers an existing set of entities with the editor context.
|
||||
/// Triggers registered callbacks for an existing set of entities with the editor context.
|
||||
virtual void HandleEntitiesAdded(const EntityList& entities) = 0;
|
||||
|
||||
/// Creates an editor ready entity, and sends out notification for the creation.
|
||||
virtual void FinalizeEditorEntity(AZ::Entity* entity) = 0;
|
||||
|
||||
/// Destroys an entity in the editor context.
|
||||
/// \return whether or not the entity was destroyed. A false return value signifies the entity did not belong to the game context.
|
||||
virtual bool DestroyEditorEntity(AZ::EntityId entityId) = 0;
|
||||
|
||||
+7
-18
@@ -227,14 +227,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
AZ::Entity* entity = CreateEntity(name);
|
||||
AZ_Assert(entity != nullptr, "Entity with name %s couldn't be created.", name);
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
FinalizeEditorEntity(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
|
||||
}
|
||||
FinalizeEditorEntity(entity);
|
||||
|
||||
return entity->GetId();
|
||||
}
|
||||
|
||||
@@ -263,14 +257,7 @@ namespace AzToolsFramework
|
||||
entity = aznew AZ::Entity(entityId, name);
|
||||
AZ_Assert(entity != nullptr, "Entity with name %s couldn't be created.", name);
|
||||
AddEntity(entity);
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
FinalizeEditorEntity(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
|
||||
}
|
||||
FinalizeEditorEntity(entity);
|
||||
|
||||
return entity->GetId();
|
||||
}
|
||||
@@ -284,10 +271,12 @@ namespace AzToolsFramework
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetupEditorEntity(entity);
|
||||
|
||||
// Store creation undo command.
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
SetupEditorEntity(entity);
|
||||
|
||||
ScopedUndoBatch undoBatch("Create Entity");
|
||||
|
||||
EntityCreateCommand* command = aznew EntityCreateCommand(static_cast<AZ::u64>(entity->GetId()));
|
||||
@@ -458,7 +447,7 @@ namespace AzToolsFramework
|
||||
else
|
||||
{
|
||||
loadedSuccessfully = static_cast<PrefabEditorEntityOwnershipService*>(m_entityOwnershipService.get())->LoadFromStream(
|
||||
stream, AZStd::string_view(levelPakFile.toUtf8(), levelPakFile.size()) );
|
||||
stream, AZStd::string_view(levelPakFile.toUtf8().constData(), levelPakFile.size()) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -81,6 +81,7 @@ namespace AzToolsFramework
|
||||
void AddEditorEntity(AZ::Entity* entity) override;
|
||||
void AddEditorEntities(const EntityList& entities) override;
|
||||
void HandleEntitiesAdded(const EntityList& entities) override;
|
||||
void FinalizeEditorEntity(AZ::Entity* entity) override;
|
||||
bool CloneEditorEntities(const EntityIdList& sourceEntities,
|
||||
EntityList& resultEntities,
|
||||
AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap) override;
|
||||
@@ -142,13 +143,9 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnContextEntitiesAdded(const EntityList& entities) override;
|
||||
void OnContextEntityRemoved(const AZ::EntityId& id) override;
|
||||
|
||||
// Helper function for creating editor ready entities.
|
||||
void FinalizeEditorEntity(AZ::Entity* entity);
|
||||
|
||||
void SetupEditorEntity(AZ::Entity* entity);
|
||||
void SetupEditorEntities(const EntityList& entities);
|
||||
|
||||
|
||||
+6
-1
@@ -693,7 +693,12 @@ namespace AzToolsFramework
|
||||
SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
|
||||
&SliceEditorEntityOwnershipServiceNotifications::OnSaveStreamForGameBegin, stream, streamType, tempEntities);
|
||||
|
||||
sourceEntities.insert(sourceEntities.end(), tempEntities.begin(), tempEntities.end());
|
||||
sourceEntities.reserve(sourceEntities.size() + tempEntities.size());
|
||||
for (AZStd::unique_ptr<AZ::Entity>& tempEntity : tempEntities)
|
||||
{
|
||||
sourceEntities.emplace_back(tempEntity.release());
|
||||
}
|
||||
tempEntities = {};
|
||||
// Add the root slice metadata entity so that we export any level components
|
||||
sourceEntities.push_back(GetRootSlice()->GetMetadataEntity());
|
||||
|
||||
|
||||
@@ -241,25 +241,34 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void QtEventToAzInputMapper::SetCursorCaptureEnabled(bool enabled)
|
||||
void QtEventToAzInputMapper::SetCursorMode(AzToolsFramework::CursorInputMode mode)
|
||||
{
|
||||
if (m_capturingCursor != enabled)
|
||||
if (mode != m_cursorMode)
|
||||
{
|
||||
m_capturingCursor = enabled;
|
||||
|
||||
if (m_capturingCursor)
|
||||
m_cursorMode = mode;
|
||||
switch (m_cursorMode)
|
||||
{
|
||||
m_mouseDevice->SetSystemCursorState(AzFramework::SystemCursorState::ConstrainedAndHidden);
|
||||
case CursorInputMode::CursorModeCaptured:
|
||||
qApp->setOverrideCursor(Qt::BlankCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mouseDevice->SetSystemCursorState(AzFramework::SystemCursorState::UnconstrainedAndVisible);
|
||||
m_mouseDevice->SetSystemCursorState(AzFramework::SystemCursorState::ConstrainedAndHidden);
|
||||
break;
|
||||
case CursorInputMode::CursorModeWrapped:
|
||||
qApp->restoreOverrideCursor();
|
||||
m_mouseDevice->SetSystemCursorState(AzFramework::SystemCursorState::UnconstrainedAndVisible);
|
||||
break;
|
||||
case CursorInputMode::CursorModeNone:
|
||||
qApp->restoreOverrideCursor();
|
||||
m_mouseDevice->SetSystemCursorState(AzFramework::SystemCursorState::UnconstrainedAndVisible);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtEventToAzInputMapper::SetCursorCaptureEnabled(bool enabled)
|
||||
{
|
||||
SetCursorMode(enabled ? CursorInputMode::CursorModeCaptured : CursorInputMode::CursorModeNone);
|
||||
}
|
||||
|
||||
bool QtEventToAzInputMapper::eventFilter(QObject* object, QEvent* event)
|
||||
{
|
||||
// Abort if processing isn't enabled.
|
||||
@@ -436,25 +445,80 @@ namespace AzToolsFramework
|
||||
return QPoint{ denormalizedX, denormalizedY };
|
||||
}
|
||||
|
||||
void WrapCursorX(const QRect& rect, QPoint& point)
|
||||
{
|
||||
if (point.x() < rect.left())
|
||||
{
|
||||
point.setX(rect.right() - 1);
|
||||
}
|
||||
else if (point.x() > rect.right())
|
||||
{
|
||||
point.setX(rect.left() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void WrapCursorY(const QRect& rect, QPoint& point)
|
||||
{
|
||||
if (point.y() < rect.top())
|
||||
{
|
||||
point.setY(rect.bottom() - 1);
|
||||
}
|
||||
else if (point.y() > rect.bottom())
|
||||
{
|
||||
point.setY(rect.top() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void QtEventToAzInputMapper::HandleMouseMoveEvent(const QPoint& globalCursorPosition)
|
||||
{
|
||||
const QPoint cursorDelta = globalCursorPosition - m_previousGlobalCursorPosition;
|
||||
QScreen* screen = m_sourceWidget->screen();
|
||||
const QRect widgetRect(m_sourceWidget->mapToGlobal(QPoint(0, 0)), m_sourceWidget->size());
|
||||
|
||||
m_mouseDevice->m_cursorPositionData2D->m_normalizedPosition =
|
||||
WidgetPositionToNormalizedPosition(m_sourceWidget->mapFromGlobal(globalCursorPosition));
|
||||
m_mouseDevice->m_cursorPositionData2D->m_normalizedPositionDelta = WidgetPositionToNormalizedPosition(cursorDelta);
|
||||
|
||||
ProcessPendingMouseEvents(cursorDelta);
|
||||
|
||||
if (m_capturingCursor)
|
||||
switch (m_cursorMode)
|
||||
{
|
||||
// Reset our cursor position to the previous point
|
||||
case CursorInputMode::CursorModeCaptured:
|
||||
AzQtComponents::SetCursorPos(m_previousGlobalCursorPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
case CursorInputMode::CursorModeWrappedX:
|
||||
case CursorInputMode::CursorModeWrappedY:
|
||||
case CursorInputMode::CursorModeWrapped:
|
||||
{
|
||||
QPoint screenPos(globalCursorPosition);
|
||||
switch (m_cursorMode)
|
||||
{
|
||||
case CursorInputMode::CursorModeWrappedX:
|
||||
WrapCursorX(widgetRect, screenPos);
|
||||
break;
|
||||
case CursorInputMode::CursorModeWrappedY:
|
||||
WrapCursorY(widgetRect, screenPos);
|
||||
break;
|
||||
case CursorInputMode::CursorModeWrapped:
|
||||
WrapCursorX(widgetRect, screenPos);
|
||||
WrapCursorY(widgetRect, screenPos);
|
||||
break;
|
||||
default:
|
||||
// this should never happen
|
||||
AZ_Assert(false, "Invalid Curosr Mode: %i.", m_cursorMode);
|
||||
break;
|
||||
}
|
||||
QCursor::setPos(screen, screenPos);
|
||||
const QPoint screenDelta = globalCursorPosition - screenPos;
|
||||
m_previousGlobalCursorPosition = globalCursorPosition - screenDelta;
|
||||
}
|
||||
break;
|
||||
case CursorInputMode::CursorModeNone:
|
||||
m_previousGlobalCursorPosition = globalCursorPosition;
|
||||
break;
|
||||
default:
|
||||
AZ_Assert(false, "Invalid Curosr Mode: %i.", m_cursorMode);
|
||||
break;
|
||||
}
|
||||
ProcessPendingMouseEvents(cursorDelta);
|
||||
}
|
||||
|
||||
void QtEventToAzInputMapper::HandleKeyEvent(QKeyEvent* keyEvent)
|
||||
|
||||
@@ -32,6 +32,17 @@ class QWheelEvent;
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
enum class CursorInputMode {
|
||||
CursorModeNone,
|
||||
CursorModeCaptured, //!< Sets whether or not the cursor should be constrained to the source widget and invisible.
|
||||
//!< Internally, this will reset the cursor position after each move event to ensure movement
|
||||
//!< events don't allow the cursor to escape. This can be used for typical camera controls
|
||||
//!< like a dolly or rotation, where mouse movement is important but cursor location is not.
|
||||
CursorModeWrapped, //!< Flags whether the curser is going to wrap around the soruce widget.
|
||||
CursorModeWrappedX, //!< Flags whether the curser is going to wrap around the soruce widget only on the left and right side.
|
||||
CursorModeWrappedY //!< Flags whether the curser is going to wrap around the soruce widget only on the top and bottom side.
|
||||
};
|
||||
|
||||
//! Maps events from the Qt input system to synthetic InputChannels in AzFramework
|
||||
//! that can be used by AzFramework::ViewportControllers.
|
||||
class QtEventToAzInputMapper final
|
||||
@@ -56,8 +67,12 @@ namespace AzToolsFramework
|
||||
//! Internally, this will reset the cursor position after each move event to ensure movement
|
||||
//! events don't allow the cursor to escape. This can be used for typical camera controls
|
||||
//! like a dolly or rotation, where mouse movement is important but cursor location is not.
|
||||
//! @deprecated Use #SetCursorMode()
|
||||
void SetCursorCaptureEnabled(bool enabled);
|
||||
|
||||
//! Set the cursor mode.
|
||||
void SetCursorMode(AzToolsFramework::CursorInputMode mode);
|
||||
|
||||
void SetOverrideCursor(ViewportInteraction::CursorStyleOverride cursorStyleOverride);
|
||||
void ClearOverrideCursor();
|
||||
|
||||
@@ -176,8 +191,8 @@ namespace AzToolsFramework
|
||||
QWidget* m_sourceWidget;
|
||||
// Flags whether or not Qt events should currently be processed.
|
||||
bool m_enabled = true;
|
||||
// Flags whether or not the cursor is being constrained to the source widget (for invisible mouse movement).
|
||||
bool m_capturingCursor = false;
|
||||
// Controls the cursor behavior.
|
||||
AzToolsFramework::CursorInputMode m_cursorMode = AzToolsFramework::CursorInputMode::CursorModeNone;
|
||||
// Flags whether the cursor has been overridden.
|
||||
bool m_overrideCursor = false;
|
||||
|
||||
|
||||
@@ -661,6 +661,7 @@ namespace AzToolsFramework
|
||||
entityOwningInstance.AddEntity(*entity, entityAlias);
|
||||
|
||||
EditorEntityContextRequestBus::Broadcast(&EditorEntityContextRequestBus::Events::HandleEntitiesAdded, EntityList{entity});
|
||||
EditorEntityContextRequestBus::Broadcast(&EditorEntityContextRequestBus::Events::FinalizeEditorEntity, entity);
|
||||
|
||||
AZ::Transform transform = AZ::Transform::CreateIdentity();
|
||||
transform.SetTranslation(position);
|
||||
@@ -1063,7 +1064,7 @@ namespace AzToolsFramework
|
||||
return AZ::Failure(AZStd::string("No entities to duplicate."));
|
||||
}
|
||||
|
||||
const EntityIdList entityIdsNoFocusContainer = GenerateEntityIdListWithoutFocusedInstanceContainer(entityIds);
|
||||
const EntityIdList entityIdsNoFocusContainer = SanitizeEntityIdList(entityIds);
|
||||
if (entityIdsNoFocusContainer.empty())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("No entities to duplicate because only instance selected is the container entity of the focused instance."));
|
||||
@@ -1202,7 +1203,7 @@ namespace AzToolsFramework
|
||||
PrefabOperationResult PrefabPublicHandler::DeleteFromInstance(const EntityIdList& entityIds, bool deleteDescendants)
|
||||
{
|
||||
// Remove the container entity of the focused prefab from the list, if it is included.
|
||||
const EntityIdList entityIdsNoFocusContainer = GenerateEntityIdListWithoutFocusedInstanceContainer(entityIds);
|
||||
const EntityIdList entityIdsNoFocusContainer = SanitizeEntityIdList(entityIds);
|
||||
|
||||
if (entityIdsNoFocusContainer.empty())
|
||||
{
|
||||
@@ -1236,27 +1237,6 @@ namespace AzToolsFramework
|
||||
return AZ::Failure(AZStd::string("Cannot delete entities belonging to an instance that is not being edited."));
|
||||
}
|
||||
|
||||
// None of the specified entities can be marked as read only, otherwise this operation is invalid.
|
||||
if (auto readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get())
|
||||
{
|
||||
AZ::EntityId readOnlyEntityId;
|
||||
for (const auto& entityId : entityIdsNoFocusContainer)
|
||||
{
|
||||
if (readOnlyEntityPublicInterface->IsReadOnly(entityId))
|
||||
{
|
||||
readOnlyEntityId = entityId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (readOnlyEntityId.IsValid())
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format(
|
||||
"Cannot delete entities because entity (id '%llu') is marked as read only.",
|
||||
static_cast<AZ::u64>(readOnlyEntityId)));
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve entityList from entityIds
|
||||
EntityList inputEntityList = EntityIdListToEntityList(entityIdsNoFocusContainer);
|
||||
|
||||
@@ -1680,10 +1660,24 @@ namespace AzToolsFramework
|
||||
return AZ::Success();
|
||||
}
|
||||
|
||||
EntityIdList PrefabPublicHandler::GenerateEntityIdListWithoutFocusedInstanceContainer(
|
||||
const EntityIdList& entityIds) const
|
||||
EntityIdList PrefabPublicHandler::SanitizeEntityIdList(const EntityIdList& entityIds) const
|
||||
{
|
||||
EntityIdList outEntityIds(entityIds);
|
||||
EntityIdList outEntityIds;
|
||||
|
||||
if (auto readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get())
|
||||
{
|
||||
std::copy_if(
|
||||
entityIds.begin(), entityIds.end(), AZStd::back_inserter(outEntityIds),
|
||||
[readOnlyEntityPublicInterface](const AZ::EntityId& entityId)
|
||||
{
|
||||
return !readOnlyEntityPublicInterface->IsReadOnly(entityId);
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
outEntityIds = entityIds;
|
||||
}
|
||||
|
||||
AzFramework::EntityContextId editorEntityContextId = AzToolsFramework::GetEntityContextId();
|
||||
AZ::EntityId focusedInstanceContainerEntityId = m_prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(editorEntityContextId);
|
||||
|
||||
@@ -75,7 +75,10 @@ namespace AzToolsFramework
|
||||
Instance& commonRootEntityOwningInstance,
|
||||
EntityList& outEntities,
|
||||
AZStd::vector<Instance*>& outInstances) const;
|
||||
EntityIdList GenerateEntityIdListWithoutFocusedInstanceContainer(const EntityIdList& entityIds) const;
|
||||
|
||||
//! Sanitizes an EntityIdList to remove entities that should not be affected by prefab operations.
|
||||
//! It will identify and exclude the container entity of the root prefab instance, and all read-only entities.
|
||||
EntityIdList SanitizeEntityIdList(const EntityIdList& entityIds) const;
|
||||
|
||||
InstanceOptionalReference GetOwnerInstanceByEntityId(AZ::EntityId entityId) const;
|
||||
bool EntitiesBelongToSameInstance(const EntityIdList& entityIds) const;
|
||||
|
||||
@@ -506,7 +506,7 @@ namespace AzToolsFramework
|
||||
//Remove all Links owned by the Template from TemplateToLinkIdsMap.
|
||||
Template& templateToDelete = findTemplateResult->get();
|
||||
const Template::Links& linkIdsToDelete = templateToDelete.GetLinks();
|
||||
bool result;
|
||||
[[maybe_unused]] bool result;
|
||||
for (auto linkId : linkIdsToDelete)
|
||||
{
|
||||
result = RemoveLinkIdFromTemplateToLinkIdsMap(linkId);
|
||||
@@ -774,7 +774,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
Link& link = findLinkResult->get();
|
||||
bool result;
|
||||
[[maybe_unused]] bool result;
|
||||
result = RemoveLinkIdFromTemplateToLinkIdsMap(linkId, link);
|
||||
AZ_Assert(result,
|
||||
"Prefab - PrefabSystemComponent::RemoveLink - "
|
||||
|
||||
@@ -65,6 +65,9 @@ namespace AzToolsFramework
|
||||
|
||||
bool Connection::Open(const AZStd::string& filename, bool readOnly)
|
||||
{
|
||||
AZ_Assert(sqlite3_libversion_number() == SQLITE_VERSION_NUMBER, "Sqlite header version number does not match library");
|
||||
AZ_Assert(strncmp(sqlite3_sourceid(), SQLITE_SOURCE_ID, 80) == 0, "Sqlite header source id does not match library");
|
||||
AZ_Assert(strcmp(sqlite3_libversion(), SQLITE_VERSION) == 0, "Sqlite header version does not match library");
|
||||
AZ_Assert(m_db == NULL, "You have to close the database prior to opening a new one.");
|
||||
if (m_db)
|
||||
{
|
||||
|
||||
@@ -926,7 +926,7 @@ namespace AzToolsFramework
|
||||
const bool entityIsFromIgnoredSliceInstance = ignoreSliceInstance && ignoreSliceInstance->IsValid() && ignoreSliceInstance->GetReference()->GetSliceAsset().GetId() == instanceAddr.GetReference()->GetSliceAsset().GetId();
|
||||
if (!entityIsFromIgnoredSliceInstance)
|
||||
{
|
||||
bool foundTargetAncestor = false;
|
||||
[[maybe_unused]] bool foundTargetAncestor = false;
|
||||
|
||||
const AZ::SliceComponent::EntityList& entitiesInInstance = instanceAddr.GetInstance()->GetInstantiated()->m_entities;
|
||||
|
||||
|
||||
+1
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
|
||||
@@ -890,6 +890,7 @@ namespace AzToolsFramework
|
||||
|
||||
m_actionGoToEntitiesInViewport = new QAction(tr("Find in viewport"), this);
|
||||
m_actionGoToEntitiesInViewport->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
m_actionGoToEntitiesInViewport->setShortcut(tr("Z"));
|
||||
connect(m_actionGoToEntitiesInViewport, &QAction::triggered, this, &EntityOutlinerWidget::GoToEntitiesInViewport);
|
||||
addAction(m_actionGoToEntitiesInViewport);
|
||||
}
|
||||
|
||||
+4
-3
@@ -217,7 +217,7 @@ namespace AzToolsFramework
|
||||
});
|
||||
|
||||
EditorActionRequestBus::Broadcast(
|
||||
&EditorActionRequests::AddActionViaBusCrc, AZ_CRC_CE("com.o3de.action.editortransform.prefabopen"),
|
||||
&EditorActionRequests::AddActionViaBusCrc, AZ_CRC_CE("org.o3de.action.editortransform.prefabopen"),
|
||||
m_actions.back().get());
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace AzToolsFramework
|
||||
});
|
||||
|
||||
EditorActionRequestBus::Broadcast(
|
||||
&EditorActionRequests::AddActionViaBusCrc, AZ_CRC_CE("com.o3de.action.editortransform.prefabclose"),
|
||||
&EditorActionRequests::AddActionViaBusCrc, AZ_CRC_CE("org.o3de.action.editortransform.prefabclose"),
|
||||
m_actions.back().get());
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Instantiate Prefab
|
||||
if (selectedEntities.size() == 1 && !readOnlyEntityInSelection && !onlySelectedEntityIsClosedPrefabContainer)
|
||||
if (selectedEntities.size() == 0 ||
|
||||
selectedEntities.size() == 1 && !readOnlyEntityInSelection && !onlySelectedEntityIsClosedPrefabContainer)
|
||||
{
|
||||
QAction* instantiateAction = menu->addAction(QObject::tr("Instantiate Prefab..."));
|
||||
instantiateAction->setToolTip(QObject::tr("Instantiates a prefab file in the scene."));
|
||||
|
||||
+9
@@ -44,6 +44,9 @@ namespace AzToolsFramework::Prefab
|
||||
m_breadcrumbsWidget = breadcrumbsWidget;
|
||||
m_backButton = backButton;
|
||||
|
||||
// Add icons to the widget
|
||||
m_breadcrumbsWidget->setDefaultIcon(QString(":/Entity/prefab_edit.svg"));
|
||||
|
||||
// If a part of the path is clicked, focus on that instance
|
||||
connect(m_breadcrumbsWidget, &AzQtComponents::BreadCrumbs::linkClicked, this,
|
||||
[&](const QString&, int linkIndex)
|
||||
@@ -73,6 +76,12 @@ namespace AzToolsFramework::Prefab
|
||||
{
|
||||
// Push new Path
|
||||
m_breadcrumbsWidget->pushPath(m_prefabFocusPublicInterface->GetPrefabFocusPath(m_editorEntityContextId).c_str());
|
||||
|
||||
// Set root icon
|
||||
m_breadcrumbsWidget->setIconAt(0, QString(":/Level/level.svg"));
|
||||
|
||||
// If root instance is focused, disable the back button; else enable it.
|
||||
m_backButton->setEnabled(m_prefabFocusPublicInterface->GetPrefabFocusPathLength(m_editorEntityContextId) > 1);
|
||||
}
|
||||
|
||||
} // namespace AzToolsFramework::Prefab
|
||||
|
||||
+3
-2
@@ -10,12 +10,13 @@
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
|
||||
//! Model storing all the files that can be suggested in the Asset Autocompleter for PropertyAssetCtrl
|
||||
class AssetCompleterModel
|
||||
: public QAbstractTableModel
|
||||
@@ -45,7 +46,7 @@ namespace AzToolsFramework
|
||||
void SetFetchEntryType(AssetBrowserEntry::AssetEntryType entryType);
|
||||
|
||||
private:
|
||||
struct AssetItem
|
||||
struct AssetItem
|
||||
{
|
||||
AZStd::string m_displayName;
|
||||
AZStd::string m_path;
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ namespace AzToolsFramework
|
||||
void PropertyEnumComboBoxCtrl::setValue(AZ::s64 value)
|
||||
{
|
||||
m_pComboBox->blockSignals(true);
|
||||
bool indexWasFound = false;
|
||||
[[maybe_unused]] bool indexWasFound = false;
|
||||
for (size_t enumValIndex = 0; enumValIndex < m_enumValues.size(); enumValIndex++)
|
||||
{
|
||||
if (m_enumValues[enumValIndex].first == value)
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace AzToolsFramework
|
||||
/// @name Reverse URLs.
|
||||
/// Used to identify common actions and override them when necessary.
|
||||
//@{
|
||||
static const AZ::Crc32 s_backAction = AZ_CRC("com.o3de.action.common.back", 0x80c3030f);
|
||||
static const AZ::Crc32 s_deleteAction = AZ_CRC("com.o3de.action.common.delete", 0x58e78eed);
|
||||
static const AZ::Crc32 s_duplicateAction = AZ_CRC("com.o3de.action.common.duplicate", 0xbc5a4a23);
|
||||
static const AZ::Crc32 s_nextComponentMode = AZ_CRC("com.o3de.action.common.nextComponentMode", 0xf9aca3a8);
|
||||
static const AZ::Crc32 s_previousComponentMode = AZ_CRC("com.o3de.action.common.previousComponentMode", 0x0580eaec);
|
||||
static const AZ::Crc32 s_backAction = AZ_CRC_CE("org.o3de.action.common.back");
|
||||
static const AZ::Crc32 s_deleteAction = AZ_CRC_CE("org.o3de.action.common.delete");
|
||||
static const AZ::Crc32 s_duplicateAction = AZ_CRC_CE("org.o3de.action.common.duplicate");
|
||||
static const AZ::Crc32 s_nextComponentMode = AZ_CRC_CE("org.o3de.action.common.nextComponentMode");
|
||||
static const AZ::Crc32 s_previousComponentMode = AZ_CRC_CE("org.o3de.action.common.previousComponentMode");
|
||||
//@}
|
||||
|
||||
/// Specific Action properties to be sent to a type implementing
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportInteractionHelpers.h>
|
||||
|
||||
|
||||
namespace AzToolsFramework::ViewportInteraction
|
||||
{
|
||||
MouseButton Helpers::GetMouseButton(const AzFramework::InputChannel& inputChannel)
|
||||
{
|
||||
using AzToolsFramework::ViewportInteraction::MouseButton;
|
||||
using InputButton = AzFramework::InputDeviceMouse::Button;
|
||||
const AzFramework::InputChannelId& id = inputChannel.GetInputChannelId();
|
||||
if (id == InputButton::Left)
|
||||
{
|
||||
return MouseButton::Left;
|
||||
}
|
||||
if (id == InputButton::Middle)
|
||||
{
|
||||
return MouseButton::Middle;
|
||||
}
|
||||
if (id == InputButton::Right)
|
||||
{
|
||||
return MouseButton::Right;
|
||||
}
|
||||
return MouseButton::None;
|
||||
}
|
||||
|
||||
bool Helpers::IsMouseMove(const AzFramework::InputChannel& inputChannel)
|
||||
{
|
||||
return inputChannel.GetInputChannelId() == AzFramework::InputDeviceMouse::SystemCursorPosition;
|
||||
}
|
||||
|
||||
KeyboardModifier Helpers::GetKeyboardModifier(const AzFramework::InputChannel& inputChannel)
|
||||
{
|
||||
using AzToolsFramework::ViewportInteraction::KeyboardModifier;
|
||||
using Key = AzFramework::InputDeviceKeyboard::Key;
|
||||
const auto& id = inputChannel.GetInputChannelId();
|
||||
if (id == Key::ModifierAltL || id == Key::ModifierAltR)
|
||||
{
|
||||
return KeyboardModifier::Alt;
|
||||
}
|
||||
if (id == Key::ModifierCtrlL || id == Key::ModifierCtrlR)
|
||||
{
|
||||
return KeyboardModifier::Ctrl;
|
||||
}
|
||||
if (id == Key::ModifierShiftL || id == Key::ModifierShiftR)
|
||||
{
|
||||
return KeyboardModifier::Shift;
|
||||
}
|
||||
return KeyboardModifier::None;
|
||||
}
|
||||
} // namespace AzToolsFramework::ViewportInteraction
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzFramework/Input/Channels/InputChannel.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportTypes.h>
|
||||
|
||||
|
||||
namespace AzToolsFramework::ViewportInteraction
|
||||
{
|
||||
class Helpers
|
||||
{
|
||||
public:
|
||||
static MouseButton GetMouseButton(const AzFramework::InputChannel& inputChannel);
|
||||
static bool IsMouseMove(const AzFramework::InputChannel& inputChannel);
|
||||
static KeyboardModifier GetKeyboardModifier(const AzFramework::InputChannel& inputChannel);
|
||||
};
|
||||
} // namespace AzToolsFramework::ViewportInteraction
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <AzFramework/Render/IntersectorInterface.h>
|
||||
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
@@ -66,15 +67,19 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::Vector3 FindClosestPickIntersection(const AzFramework::RenderGeometry::RayRequest& rayRequest, const float defaultDistance)
|
||||
{
|
||||
AzFramework::RenderGeometry::RayResult renderGeometryIntersectionResult;
|
||||
// attempt a ray intersection with any visible mesh or terrain and return the intersection position if successful
|
||||
AZ::EBusReduceResult<AzFramework::RenderGeometry::RayResult, AzFramework::RenderGeometry::RayResultClosestAggregator> renderGeometryIntersectionResult;
|
||||
AzFramework::RenderGeometry::IntersectorBus::EventResult(
|
||||
renderGeometryIntersectionResult, AzToolsFramework::GetEntityContextId(),
|
||||
&AzFramework::RenderGeometry::IntersectorBus::Events::RayIntersect, rayRequest);
|
||||
AzFramework::Terrain::TerrainDataRequestBus::BroadcastResult(
|
||||
renderGeometryIntersectionResult,
|
||||
&AzFramework::Terrain::TerrainDataRequests::GetClosestIntersection,
|
||||
rayRequest);
|
||||
|
||||
// attempt a ray intersection with any visible mesh and return the intersection position if successful
|
||||
if (renderGeometryIntersectionResult)
|
||||
if (renderGeometryIntersectionResult.value)
|
||||
{
|
||||
return renderGeometryIntersectionResult.m_worldPosition;
|
||||
return renderGeometryIntersectionResult.value.m_worldPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -150,6 +150,9 @@ namespace AzToolsFramework
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
};
|
||||
|
||||
//! A bus to listen to just the MouseViewportRequests.
|
||||
using ViewportMouseRequestBus = AZ::EBus<MouseViewportRequests, ViewportEBusTraits>;
|
||||
|
||||
//! Requests that can be made to the viewport to query and modify its state.
|
||||
class ViewportInteractionRequests
|
||||
{
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
}
|
||||
|
||||
AZ::Crc32 m_uri; //!< Unique identifier for the Action. (In the form 'com.o3de.action.---").
|
||||
AZ::Crc32 m_uri; //!< Unique identifier for the Action. (In the form 'org.o3de.action.---").
|
||||
AZStd::vector<AZStd::function<void()>> m_callbacks; //!< Callbacks associated with this Action (note: with multi-selections
|
||||
//!< there will be a callback per Entity/Component).
|
||||
AZStd::unique_ptr<QAction> m_action; //!< The QAction associated with the overrideWidget for all ComponentMode actions.
|
||||
|
||||
+3
-2
@@ -95,11 +95,12 @@ namespace AzToolsFramework
|
||||
entityId,
|
||||
[mouseInteraction, &entityPicked, &closestDistance, viewportId](EditorComponentSelectionRequests* handler) -> bool
|
||||
{
|
||||
if (handler->SupportsEditorRayIntersect())
|
||||
const auto viewportInfo = AzFramework::ViewportInfo{ viewportId };
|
||||
if (handler->SupportsEditorRayIntersectViewport(viewportInfo))
|
||||
{
|
||||
float distance = std::numeric_limits<float>::max();
|
||||
const bool intersection = handler->EditorSelectionIntersectRayViewport(
|
||||
{ viewportId }, mouseInteraction.m_mousePick.m_rayOrigin, mouseInteraction.m_mousePick.m_rayDirection, distance);
|
||||
viewportInfo, mouseInteraction.m_mousePick.m_rayOrigin, mouseInteraction.m_mousePick.m_rayDirection, distance);
|
||||
|
||||
if (intersection && distance < closestDistance)
|
||||
{
|
||||
|
||||
+17
-17
@@ -17,23 +17,23 @@ namespace AzToolsFramework
|
||||
//! @name Reverse URLs.
|
||||
//! Used to identify common actions and override them when necessary.
|
||||
//@{
|
||||
constexpr inline AZ::Crc32 LockSelection = AZ_CRC_CE("com.o3de.action.editortransform.lockselect");
|
||||
constexpr inline AZ::Crc32 UnlockSelection = AZ_CRC_CE("com.o3de.action.editortransform.unlockselect");
|
||||
constexpr inline AZ::Crc32 HideSelection = AZ_CRC_CE("com.o3de.action.editortransform.hideselect");
|
||||
constexpr inline AZ::Crc32 ShowSelection = AZ_CRC_CE("com.o3de.action.editortransform.showselect");
|
||||
constexpr inline AZ::Crc32 UnlockAll = AZ_CRC_CE("com.o3de.action.editortransform.unlockall");
|
||||
constexpr inline AZ::Crc32 ShowAll = AZ_CRC_CE("com.o3de.action.editortransform.unhideall");
|
||||
constexpr inline AZ::Crc32 SelectAll = AZ_CRC_CE("com.o3de.action.editortransform.selectall");
|
||||
constexpr inline AZ::Crc32 InvertSelect = AZ_CRC_CE("com.o3de.action.editortransform.invertselect");
|
||||
constexpr inline AZ::Crc32 DuplicateSelect = AZ_CRC_CE("com.o3de.action.editortransform.duplicateselect");
|
||||
constexpr inline AZ::Crc32 DeleteSelect = AZ_CRC_CE("com.o3de.action.editortransform.deleteselect");
|
||||
constexpr inline AZ::Crc32 EditEscaspe = AZ_CRC_CE("com.o3de.action.editortransform.editescape");
|
||||
constexpr inline AZ::Crc32 EditPivot = AZ_CRC_CE("com.o3de.action.editortransform.editpivot");
|
||||
constexpr inline AZ::Crc32 EditReset = AZ_CRC_CE("com.o3de.action.editortransform.editreset");
|
||||
constexpr inline AZ::Crc32 EditResetManipulator = AZ_CRC_CE("com.o3de.action.editortransform.editresetmanipulator");
|
||||
constexpr inline AZ::Crc32 ViewportUiVisible = AZ_CRC_CE("com.o3de.action.editortransform.viewportuivisible");
|
||||
constexpr inline AZ::Crc32 Helpers = AZ_CRC_CE("com.o3de.action.editor.helpers");
|
||||
constexpr inline AZ::Crc32 Icons = AZ_CRC_CE("com.o3de.action.editor.icons");
|
||||
constexpr inline AZ::Crc32 LockSelection = AZ_CRC_CE("org.o3de.action.editortransform.lockselect");
|
||||
constexpr inline AZ::Crc32 UnlockSelection = AZ_CRC_CE("org.o3de.action.editortransform.unlockselect");
|
||||
constexpr inline AZ::Crc32 HideSelection = AZ_CRC_CE("org.o3de.action.editortransform.hideselect");
|
||||
constexpr inline AZ::Crc32 ShowSelection = AZ_CRC_CE("org.o3de.action.editortransform.showselect");
|
||||
constexpr inline AZ::Crc32 UnlockAll = AZ_CRC_CE("org.o3de.action.editortransform.unlockall");
|
||||
constexpr inline AZ::Crc32 ShowAll = AZ_CRC_CE("org.o3de.action.editortransform.unhideall");
|
||||
constexpr inline AZ::Crc32 SelectAll = AZ_CRC_CE("org.o3de.action.editortransform.selectall");
|
||||
constexpr inline AZ::Crc32 InvertSelect = AZ_CRC_CE("org.o3de.action.editortransform.invertselect");
|
||||
constexpr inline AZ::Crc32 DuplicateSelect = AZ_CRC_CE("org.o3de.action.editortransform.duplicateselect");
|
||||
constexpr inline AZ::Crc32 DeleteSelect = AZ_CRC_CE("org.o3de.action.editortransform.deleteselect");
|
||||
constexpr inline AZ::Crc32 EditEscaspe = AZ_CRC_CE("org.o3de.action.editortransform.editescape");
|
||||
constexpr inline AZ::Crc32 EditPivot = AZ_CRC_CE("org.o3de.action.editortransform.editpivot");
|
||||
constexpr inline AZ::Crc32 EditReset = AZ_CRC_CE("org.o3de.action.editortransform.editreset");
|
||||
constexpr inline AZ::Crc32 EditResetManipulator = AZ_CRC_CE("org.o3de.action.editortransform.editresetmanipulator");
|
||||
constexpr inline AZ::Crc32 ViewportUiVisible = AZ_CRC_CE("org.o3de.action.editortransform.viewportuivisible");
|
||||
constexpr inline AZ::Crc32 Helpers = AZ_CRC_CE("org.o3de.action.editor.helpers");
|
||||
constexpr inline AZ::Crc32 Icons = AZ_CRC_CE("org.o3de.action.editor.icons");
|
||||
//@}
|
||||
|
||||
//! Provide interface for EditorTransformComponentSelection requests.
|
||||
|
||||
@@ -488,6 +488,8 @@ set(FILES
|
||||
Viewport/EditorContextMenu.cpp
|
||||
Viewport/VertexContainerDisplay.h
|
||||
Viewport/VertexContainerDisplay.cpp
|
||||
Viewport/ViewportInteractionHelpers.h
|
||||
Viewport/ViewportInteractionHelpers.cpp
|
||||
Viewport/ViewportMessages.h
|
||||
Viewport/ViewportMessages.cpp
|
||||
Viewport/ViewportTypes.h
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace //anonymous
|
||||
"project_id": "{91FB81A1-072C-4A80-8FCC-7E2C4C767B4D}",
|
||||
|
||||
"android_settings" : {
|
||||
"package_name" : "com.lumberyard.yourgame",
|
||||
"package_name" : "org.o3de.yourgame",
|
||||
"version_number" : 1,
|
||||
"version_name" : "1.0.0.0",
|
||||
"orientation" : "landscape"
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZStd::vector<AzToolsFramework::ActionOverride> PlaceHolderComponentMode::PopulateActionsImpl()
|
||||
{
|
||||
const AZ::Crc32 placeHolderComponentModeAction = AZ_CRC_CE("com.o3de.action.placeholder.test");
|
||||
const AZ::Crc32 placeHolderComponentModeAction = AZ_CRC_CE("org.o3de.action.placeholder.test");
|
||||
|
||||
return AZStd::vector<AzToolsFramework::ActionOverride>
|
||||
{
|
||||
|
||||
@@ -44,6 +44,10 @@ namespace UnitTest
|
||||
QObject::connect(m_inputChannelMapper.get(), &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, m_rootWidget.get(),
|
||||
[this]([[maybe_unused]] const AzFramework::InputChannel* inputChannel, QEvent* event)
|
||||
{
|
||||
if(event == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QEvent::Type eventType = event->type();
|
||||
|
||||
if (eventType == QEvent::Type::MouseButtonPress ||
|
||||
@@ -96,6 +100,11 @@ namespace UnitTest
|
||||
m_azChannelEvents.push_back(AzEventInfo(inputChannel));
|
||||
hasBeenConsumed = m_captureAzEvents;
|
||||
}
|
||||
else if (inputChannelId == AzFramework::InputDeviceMouse::SystemCursorPosition)
|
||||
{
|
||||
m_azCursorPositions.push_back(*inputChannel.GetCustomData<AzFramework::InputChannel::PositionData2D>());
|
||||
hasBeenConsumed = m_captureAzEvents;
|
||||
}
|
||||
}
|
||||
else if (AzFramework::InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId))
|
||||
{
|
||||
@@ -161,6 +170,7 @@ namespace UnitTest
|
||||
AZStd::vector<QtEventInfo> m_signalEvents;
|
||||
AZStd::vector<AzEventInfo> m_azChannelEvents;
|
||||
AZStd::vector<AZStd::string> m_azTextEvents;
|
||||
AZStd::vector<AzFramework::InputChannel::PositionData2D> m_azCursorPositions;
|
||||
|
||||
bool m_captureAzEvents{ false };
|
||||
bool m_captureTextEvents{ false };
|
||||
@@ -512,4 +522,175 @@ namespace UnitTest
|
||||
return info.param.m_az.GetName();
|
||||
}
|
||||
);
|
||||
|
||||
struct MouseMoveParam
|
||||
{
|
||||
AzToolsFramework::CursorInputMode mode;
|
||||
int iterations;
|
||||
QPoint startPos;
|
||||
QPoint deltaPos;
|
||||
QPoint expectedPos;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
class MoveMoveWrapParamQtEventToAzInputMapperFixture
|
||||
: public QtEventToAzInputMapperFixture
|
||||
, public ::testing::WithParamInterface<MouseMoveParam>
|
||||
{
|
||||
};
|
||||
|
||||
TEST_P(MoveMoveWrapParamQtEventToAzInputMapperFixture, DISABLED_MouseMove_NoAzHandlers_VerifyMouseMovementViewport)
|
||||
{
|
||||
|
||||
// setup
|
||||
const MouseMoveParam mouseMoveParam = GetParam();
|
||||
|
||||
AzFramework::InputChannelNotificationBus::Handler::BusConnect();
|
||||
m_captureAzEvents = true;
|
||||
|
||||
m_rootWidget->move(100, 100);
|
||||
QScreen* screen = m_rootWidget->screen();
|
||||
MouseMove(m_rootWidget.get(), mouseMoveParam.startPos, QPoint(0, 0));
|
||||
|
||||
// given
|
||||
m_inputChannelMapper->SetCursorMode(mouseMoveParam.mode);
|
||||
m_azCursorPositions.clear();
|
||||
for (float i = 0; i < mouseMoveParam.iterations; i++)
|
||||
{
|
||||
MouseMove(m_rootWidget.get(), m_rootWidget->mapFromGlobal(QCursor::pos(screen)), (mouseMoveParam.deltaPos / mouseMoveParam.iterations));
|
||||
}
|
||||
|
||||
AZ::Vector2 accumulatedPosition(0.0f,0.0f);
|
||||
for(const auto& pos: m_azCursorPositions) {
|
||||
accumulatedPosition += (pos.m_normalizedPositionDelta * AZ::Vector2(aznumeric_cast<float>(WidgetSize.width()), aznumeric_cast<float>(WidgetSize.height())));
|
||||
}
|
||||
|
||||
// validate
|
||||
const QPoint endPosition = m_rootWidget->mapFromGlobal(QCursor::pos(screen));
|
||||
EXPECT_NEAR(endPosition.x(), mouseMoveParam.expectedPos.x(), 1.0f);
|
||||
EXPECT_NEAR(endPosition.y(), mouseMoveParam.expectedPos.y(), 1.0f);
|
||||
|
||||
EXPECT_NEAR(accumulatedPosition.GetX(), mouseMoveParam.deltaPos.x(), 1.0f);
|
||||
EXPECT_NEAR(accumulatedPosition.GetY(), mouseMoveParam.deltaPos.y(), 1.0f);
|
||||
|
||||
// cleanup
|
||||
m_rootWidget->move(0, 0);
|
||||
m_inputChannelMapper->SetCursorMode(AzToolsFramework::CursorInputMode::CursorModeNone);
|
||||
AzFramework::InputChannelNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(All, MoveMoveWrapParamQtEventToAzInputMapperFixture,
|
||||
testing::Values(
|
||||
// verify CursorModeWrappedX wrapping
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedX,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() - 20, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
QPoint(40, 0),
|
||||
QPoint(20, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
"CursorModeWrappedX_Test_Right"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedX,
|
||||
40,
|
||||
QPoint(20, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
QPoint(-40, 0),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() - 20, QtEventToAzInputMapperFixture::WidgetSize.height()/2),
|
||||
"CursorModeWrappedX_Test_Left"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedX,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, 20),
|
||||
QPoint(0, -40),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, -20),
|
||||
"CursorModeWrappedX_Test_Top"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedX,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() - 20),
|
||||
QPoint(0, 40),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() + 20),
|
||||
"CursorModeWrappedX_Test_Bottom"
|
||||
},
|
||||
|
||||
// verify CursorModeWrappedY wrapping
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedY,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() - 20, QtEventToAzInputMapperFixture::WidgetSize.height()/2),
|
||||
QPoint(40, 0),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() + 20, QtEventToAzInputMapperFixture::WidgetSize.height()/2),
|
||||
"CursorModeWrappedY_Test_Right"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedY,
|
||||
40,
|
||||
QPoint(20, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
QPoint(-40, 0),
|
||||
QPoint(-20, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
"CursorModeWrappedY_Test_Left"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedY,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, 20),
|
||||
QPoint(0, -40),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() - 20),
|
||||
"CursorModeWrappedY_Test_Top"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrappedY,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() - 20),
|
||||
QPoint(0, 40),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, 20),
|
||||
"CursorModeWrappedY_Test_Bottom"
|
||||
},
|
||||
|
||||
// verify CursorModeWrapped wrapping
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrapped,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() - 20, QtEventToAzInputMapperFixture::WidgetSize.height()/2),
|
||||
QPoint(40, 0),
|
||||
QPoint(20, QtEventToAzInputMapperFixture::WidgetSize.height()/2),
|
||||
"CursorModeWrapped_Test_Right"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrapped,
|
||||
40,
|
||||
QPoint(20, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
QPoint(-40, 0),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() - 20, QtEventToAzInputMapperFixture::WidgetSize.height()/2),
|
||||
"CursorModeWrapped_Test_Left"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrapped,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, 20),
|
||||
QPoint(0, -40),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() - 20),
|
||||
"CursorModeWrapped_Test_Top"
|
||||
},
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeWrapped,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() - 20),
|
||||
QPoint(0, 40),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, 20),
|
||||
"CursorModeWrapped_Test_Bottom"
|
||||
},
|
||||
// verify CursorModeCaptured
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeCaptured,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
QPoint(0, 40),
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
"CursorModeCaptured"
|
||||
},
|
||||
// verify CursorModeNone
|
||||
MouseMoveParam {AzToolsFramework::CursorInputMode::CursorModeNone,
|
||||
40,
|
||||
QPoint(QtEventToAzInputMapperFixture::WidgetSize.width() / 2, QtEventToAzInputMapperFixture::WidgetSize.height() / 2),
|
||||
QPoint(40, 0),
|
||||
QPoint((QtEventToAzInputMapperFixture::WidgetSize.width() / 2) + 40, (QtEventToAzInputMapperFixture::WidgetSize.height() / 2)),
|
||||
"CursorModeNone"
|
||||
}
|
||||
),
|
||||
[](const ::testing::TestParamInfo<MouseMoveParam>& info)
|
||||
{
|
||||
return info.param.name;
|
||||
}
|
||||
);
|
||||
|
||||
} // namespace UnitTest
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace UnitTest
|
||||
size_t nextIndex = 1;
|
||||
size_t slices = 0;
|
||||
size_t liveAllocs = 0;
|
||||
size_t totalAllocs = 0;
|
||||
[[maybe_unused]] size_t totalAllocs = 0;
|
||||
|
||||
auto cb = [&liveAllocs](void*, const AZ::Debug::AllocationInfo&, unsigned char)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user