Updated viewport to hide the transform maniuplators for entities marked as read only.

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
Chris Galvan
2021-12-06 12:19:02 -06:00
parent 3c3529c8cd
commit 1f279ca713
2 changed files with 32 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,22 @@ namespace AzToolsFramework
m_selectedEntityIds.erase(focusRoot);
}
}
// Do not create maniuplators for any entities marked as read only
if (auto readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get())
{
for (auto it = m_selectedEntityIds.begin(); it != m_selectedEntityIds.end();)
{
if (readOnlyEntityPublicInterface->IsReadOnly(*it))
{
it = m_selectedEntityIds.erase(it);
}
else
{
++it;
}
}
}
}
void EditorTransformComponentSelection::OnTransformChanged(
@@ -3830,6 +3849,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);