From 5508bf7e1d4472efc1af7086f99bf8e2bc4d249d Mon Sep 17 00:00:00 2001 From: greerdv Date: Fri, 14 May 2021 12:06:44 +0100 Subject: [PATCH] remove unnecessary non-uniform scale manipulator bus --- .../EditorNonUniformScaleComponent.cpp | 52 +++++++++---------- .../EditorNonUniformScaleComponent.h | 1 - .../EditorNonUniformScaleComponentMode.cpp | 14 ++--- .../EditorNonUniformScaleComponentMode.h | 42 ++++----------- 4 files changed, 44 insertions(+), 65 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp index 276fe0b3ab..03ad5cb3c7 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp @@ -1,20 +1,20 @@ /* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ -#include +#include +#include #include #include -#include -#include +#include #include @@ -34,13 +34,13 @@ namespace AzToolsFramework serializeContext->Class() ->Version(1) ->Field("NonUniformScale", &EditorNonUniformScaleComponent::m_scale) - ->Field("ComponentMode", &EditorNonUniformScaleComponent::m_componentModeDelegate) - ; + ->Field("ComponentMode", &EditorNonUniformScaleComponent::m_componentModeDelegate); if (AZ::EditContext* editContext = serializeContext->GetEditContext()) { - editContext->Class("Non-uniform Scale", - "Non-uniform scale for this entity only (does not propagate through hierarchy)") + editContext + ->Class( + "Non-uniform Scale", "Non-uniform scale for this entity only (does not propagate through hierarchy)") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::FixedComponentListIndex, 1) ->Attribute(AZ::Edit::Attributes::RemoveableByUser, true) @@ -53,10 +53,10 @@ namespace AzToolsFramework ->Attribute(AZ::Edit::Attributes::Max, AZ::MaxTransformScale) ->Attribute(AZ::Edit::Attributes::Step, 0.1f) ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorNonUniformScaleComponent::OnScaleChanged) - ->DataElement(AZ::Edit::UIHandlers::Default, &EditorNonUniformScaleComponent::m_componentModeDelegate, - "Component Mode", "Non-uniform Scale Component Mode") - ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly) - ; + ->DataElement( + AZ::Edit::UIHandlers::Default, &EditorNonUniformScaleComponent::m_componentModeDelegate, "Component Mode", + "Non-uniform Scale Component Mode") + ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly); } } } @@ -82,16 +82,13 @@ namespace AzToolsFramework AZ::NonUniformScaleRequestBus::Handler::BusConnect(GetEntityId()); // ComponentMode - AZ::EntityComponentIdPair entityComponentIdPair(GetEntityId(), GetId()); - NonUniformScaleManipulatorRequestBus::Handler::BusConnect(entityComponentIdPair); - m_componentModeDelegate.ConnectWithSingleComponentMode< - EditorNonUniformScaleComponent, NonUniformScaleComponentMode>(entityComponentIdPair, this); + m_componentModeDelegate.ConnectWithSingleComponentMode( + AZ::EntityComponentIdPair(GetEntityId(), GetId()), this); } void EditorNonUniformScaleComponent::Deactivate() { m_componentModeDelegate.Disconnect(); - NonUniformScaleManipulatorRequestBus::Handler::BusDisconnect(); AZ::NonUniformScaleRequestBus::Handler::BusDisconnect(); } @@ -111,7 +108,8 @@ namespace AzToolsFramework else { AZ::Vector3 clampedScale = scale.GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale)); - AZ_Warning("Editor Non-uniform Scale Component", false, "SetScale value was clamped from %s to %s for entity %s", + AZ_Warning( + "Editor Non-uniform Scale Component", false, "SetScale value was clamped from %s to %s for entity %s", AZ::ToString(scale).c_str(), AZ::ToString(clampedScale).c_str(), GetEntity()->GetName().c_str()); m_scale = clampedScale; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h index d7ce953b22..32f0b2918f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h @@ -28,7 +28,6 @@ namespace AzToolsFramework , public AZ::NonUniformScaleRequestBus::Handler , public AzToolsFramework::EditorComponentSelectionRequestsBus::Handler , public AzToolsFramework::EditorComponentSelectionNotificationsBus::Handler - , private NonUniformScaleManipulatorRequestBus::Handler { public: AZ_EDITOR_COMPONENT(EditorNonUniformScaleComponent, "{2933FB4F-B3DA-4CD1-8106-F37300730777}", EditorComponentBase); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.cpp index 0521a1f2d6..87f71f2912 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.cpp @@ -10,6 +10,7 @@ * */ +#include #include #include #include @@ -42,13 +43,14 @@ namespace AzToolsFramework m_manipulators->InstallAxisLeftMouseDownCallback([this](const LinearManipulator::Action& action) { AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne(); - NonUniformScaleManipulatorRequestBus::EventResult( - nonUniformScale, m_entityComponentIdPair, &NonUniformScaleManipulatorRequests::GetScale); + + AZ::NonUniformScaleRequestBus::EventResult( + nonUniformScale, m_entityComponentIdPair.GetEntityId(), &AZ::NonUniformScaleRequests::GetScale); m_initialScale = nonUniformScale + action.m_start.m_scaleSnapOffset; - NonUniformScaleManipulatorRequestBus::Event( - m_entityComponentIdPair, &NonUniformScaleManipulatorRequests::SetScale, m_initialScale); + AZ::NonUniformScaleRequestBus::Event( + m_entityComponentIdPair.GetEntityId(), &AZ::NonUniformScaleRequests::SetScale, m_initialScale); }); m_manipulators->InstallAxisMouseMoveCallback([this](const LinearManipulator::Action& action) { @@ -56,8 +58,8 @@ namespace AzToolsFramework (AZ::Vector3::CreateOne() + ((action.LocalScaleOffset() * action.m_start.m_sign) / m_initialScale)) .GetMax(AZ::Vector3(AZ::MinTransformScale)); - NonUniformScaleManipulatorRequestBus::Event( - m_entityComponentIdPair, &NonUniformScaleManipulatorRequests::SetScale, scale * m_initialScale); + AZ::NonUniformScaleRequestBus::Event( + m_entityComponentIdPair.GetEntityId(), &AZ::NonUniformScaleRequests::SetScale, scale * m_initialScale); }); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.h index 8b40438d38..9b38067fdf 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.h @@ -1,14 +1,14 @@ /* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ #pragma once @@ -19,27 +19,7 @@ namespace AzToolsFramework { namespace Components { - //! Interface for handling non-uniform scale manipulator requests. - //! Used by NonUniformScaleComponentMode. - class NonUniformScaleManipulatorRequests - : public AZ::EntityComponentBus - { - public: - //! Gets the non-uniform scale. - virtual AZ::Vector3 GetScale() const = 0; - - //! Sets the non-uniform scale. - virtual void SetScale(const AZ::Vector3& scale) = 0; - - protected: - ~NonUniformScaleManipulatorRequests() = default; - }; - - //! Type to inherit to implement NonUniformScaleManipulatorRequests. - using NonUniformScaleManipulatorRequestBus = AZ::EBus; - - class NonUniformScaleComponentMode - : public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode + class NonUniformScaleComponentMode : public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode { public: AZ_CLASS_ALLOCATOR(NonUniformScaleComponentMode, AZ::SystemAllocator, 0)