Merge pull request #6175 from aws-lumberyard-dev/cgalvan/ReadOnlyViewportChanges

Updated viewport to hide the transform manipulators for entities marked as read only.
This commit is contained in:
Chris Galvan
2021-12-06 15:20:59 -06:00
committed by GitHub
2 changed files with 28 additions and 0 deletions
@@ -21,6 +21,7 @@
#include <AzToolsFramework/Commands/EntityManipulatorCommand.h>
#include <AzToolsFramework/Commands/SelectionCommand.h>
#include <AzToolsFramework/Entity/EditorEntityTransformBus.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
#include <AzToolsFramework/Manipulators/ManipulatorSnapping.h>
#include <AzToolsFramework/Manipulators/RotationManipulators.h>
@@ -1019,6 +1020,7 @@ namespace AzToolsFramework
EditorManipulatorCommandUndoRedoRequestBus::Handler::BusConnect(entityContextId);
EditorContextMenuBus::Handler::BusConnect();
ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusConnect(ViewportUi::DefaultViewportId);
ReadOnlyEntityPublicNotificationBus::Handler::BusConnect(entityContextId);
CreateTransformModeSelectionCluster();
CreateSpaceSelectionCluster();
@@ -1054,6 +1056,7 @@ namespace AzToolsFramework
m_pivotOverrideFrame.Reset();
ReadOnlyEntityPublicNotificationBus::Handler::BusDisconnect();
ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusDisconnect();
EditorContextMenuBus::Handler::BusConnect();
EditorManipulatorCommandUndoRedoRequestBus::Handler::BusDisconnect();
@@ -3623,6 +3626,18 @@ namespace AzToolsFramework
m_selectedEntityIds.erase(focusRoot);
}
}
// Do not create manipulators for any entities marked as read only
if (auto readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get())
{
AZStd::erase_if(
m_selectedEntityIds,
[readOnlyEntityPublicInterface](auto entityId)
{
return readOnlyEntityPublicInterface->IsReadOnly(entityId);
}
);
}
}
void EditorTransformComponentSelection::OnTransformChanged(
@@ -3830,6 +3845,14 @@ namespace AzToolsFramework
m_snappingCluster.TrySetVisible(m_viewportUiVisible && !m_selectedEntityIds.empty());
}
void EditorTransformComponentSelection::OnReadOnlyEntityStatusChanged(const AZ::EntityId& entityId, [[maybe_unused]] bool readOnly)
{
if (IsEntitySelected(entityId))
{
RefreshSelectedEntityIdsAndRegenerateManipulators();
}
}
namespace ETCS
{
// little raii wrapper to switch a value from true to false and back
@@ -20,6 +20,7 @@
#include <AzToolsFramework/Commands/EntityManipulatorCommand.h>
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityBus.h>
#include <AzToolsFramework/Manipulators/BaseManipulator.h>
#include <AzToolsFramework/ToolsComponents/EditorLockComponentBus.h>
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
@@ -160,6 +161,7 @@ namespace AzToolsFramework
, private EditorManipulatorCommandUndoRedoRequestBus::Handler
, private AZ::TransformNotificationBus::MultiHandler
, private ViewportInteraction::ViewportSettingsNotificationBus::Handler
, private ReadOnlyEntityPublicNotificationBus::Handler
{
public:
AZ_CLASS_ALLOCATOR_DECL
@@ -297,6 +299,9 @@ namespace AzToolsFramework
// ViewportSettingsNotificationBus overrides ...
void OnGridSnappingChanged(bool enabled) override;
// ReadOnlyEntityPublicNotificationBus overrides ...
void OnReadOnlyEntityStatusChanged(const AZ::EntityId& entityId, bool readOnly) override;
// Helpers to safely interact with the TransformBus (requests).
void SetEntityWorldTranslation(AZ::EntityId entityId, const AZ::Vector3& worldTranslation);
void SetEntityLocalTranslation(AZ::EntityId entityId, const AZ::Vector3& localTranslation);