From 92311ddf0dd091f665209d9f49b349bdc68477ca Mon Sep 17 00:00:00 2001 From: greerdv Date: Tue, 25 May 2021 15:43:04 +0100 Subject: [PATCH] more tidying up --- .../AzCore/AzCore/Math/Transform.cpp | 2 +- Code/Framework/AzCore/AzCore/Math/Transform.h | 4 ++-- .../AzCore/AzCore/Math/Transform.inl | 2 +- .../Json/TransformSerializerTests.cpp | 4 ++-- .../ToolsComponents/TransformComponent.cpp | 19 +++++++++---------- .../ToolsComponents/TransformComponentBus.h | 4 ++-- .../CoreLights/PolygonLightDelegate.cpp | 1 + 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Math/Transform.cpp b/Code/Framework/AzCore/AzCore/Math/Transform.cpp index 0bdfb3b318..9090a9e94e 100644 --- a/Code/Framework/AzCore/AzCore/Math/Transform.cpp +++ b/Code/Framework/AzCore/AzCore/Math/Transform.cpp @@ -250,7 +250,7 @@ namespace AZ Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)-> Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::Value)-> Attribute(Script::Attributes::GenericConstructorOverride, &Internal::TransformDefaultConstructor)-> - Constructor()-> + Constructor()-> Method("GetBasis", &Transform::GetBasis)-> Method("GetBasisX", &Transform::GetBasisX)-> Method("GetBasisY", &Transform::GetBasisY)-> diff --git a/Code/Framework/AzCore/AzCore/Math/Transform.h b/Code/Framework/AzCore/AzCore/Math/Transform.h index 6139c11ba5..7ae86edd89 100644 --- a/Code/Framework/AzCore/AzCore/Math/Transform.h +++ b/Code/Framework/AzCore/AzCore/Math/Transform.h @@ -63,7 +63,7 @@ namespace AZ Transform() = default; //! Construct a transform from components. - Transform(const Vector3& translation, const Quaternion& rotation, const float scale); + Transform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale); //! Creates an identity transform. static Transform CreateIdentity(); @@ -89,7 +89,7 @@ namespace AZ static Transform CreateFromMatrix3x4(const Matrix3x4& value); - //! Sets the transform to apply (uniform) scale only, no rotation or translation. + //! Sets the transform to apply scale only, no rotation or translation. static Transform CreateScale(const AZ::Vector3& scale); //! Sets the transform to apply (uniform) scale only, no rotation or translation. diff --git a/Code/Framework/AzCore/AzCore/Math/Transform.inl b/Code/Framework/AzCore/AzCore/Math/Transform.inl index 1da103c45b..4c2a7798b5 100644 --- a/Code/Framework/AzCore/AzCore/Math/Transform.inl +++ b/Code/Framework/AzCore/AzCore/Math/Transform.inl @@ -12,7 +12,7 @@ namespace AZ { - AZ_MATH_INLINE Transform::Transform(const Vector3& translation, const Quaternion& rotation, const float scale) + AZ_MATH_INLINE Transform::Transform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale) : m_translation(translation) , m_rotation(rotation) , m_scale(scale) diff --git a/Code/Framework/AzCore/Tests/Serialization/Json/TransformSerializerTests.cpp b/Code/Framework/AzCore/Tests/Serialization/Json/TransformSerializerTests.cpp index 7febbbb5d9..e1e9bd237d 100644 --- a/Code/Framework/AzCore/Tests/Serialization/Json/TransformSerializerTests.cpp +++ b/Code/Framework/AzCore/Tests/Serialization/Json/TransformSerializerTests.cpp @@ -44,7 +44,7 @@ namespace JsonSerializationTests AZStd::shared_ptr CreateFullySetInstance() override { return AZStd::make_shared( - AZ::Vector3(1.0f, 2.0f, 3.0f), AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f), 9.0f); + AZ::Vector3(1.0f, 2.0f, 3.0f), AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f), AZ::Vector3(9.0f)); } AZStd::string_view GetJsonForFullySetInstance() override @@ -95,7 +95,7 @@ namespace JsonSerializationTests AZ::Transform expectedTransform( AZ::Vector3(2.25f, 3.5f, 4.75f), AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f), - 5.5f); + AZ::Vector3(5.5f)); rapidjson::Document json; json.Parse(R"({ "Translation": [ 2.25, 3.5, 4.75 ], "Rotation": [ 0.25, 0.5, 0.75, 1.0 ], "Scale": 5.5 })"); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp index 7f47699243..b73978c792 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp @@ -51,9 +51,9 @@ namespace AzToolsFramework const AZ::u32 ParentEntityCRC = AZ_CRC("Parent Entity", 0x5b1b276c); // Decompose a transform into euler angles in degrees, scale (along basis, any shear will be dropped), and translation. - void DecomposeTransform(const AZ::Transform& transform, AZ::Vector3& translation, AZ::Vector3& rotation, float& scale) + void DecomposeTransform(const AZ::Transform& transform, AZ::Vector3& translation, AZ::Vector3& rotation, AZ::Vector3& scale) { - scale = transform.GetUniformScale(); + scale = transform.GetScale(); translation = transform.GetTranslation(); rotation = transform.GetRotation().GetEulerDegrees(); } @@ -357,7 +357,7 @@ namespace AzToolsFramework AZ::Transform TransformComponent::GetLocalScaleTM() const { - return AZ::Transform::CreateUniformScale(m_editorTransform.m_scale); + return AZ::Transform::CreateUniformScale(m_editorTransform.m_scale.GetMaxElement()); } const AZ::Transform& TransformComponent::GetLocalTM() @@ -374,8 +374,7 @@ namespace AzToolsFramework // given a local transform, update local transform. void TransformComponent::SetLocalTM(const AZ::Transform& finalTx) { - AZ::Vector3 tx, rot; - float scale; + AZ::Vector3 tx, rot, scale; Internal::DecomposeTransform(finalTx, tx, rot, scale); m_editorTransform.m_translate = tx; @@ -680,13 +679,13 @@ namespace AzToolsFramework void TransformComponent::SetLocalScale(const AZ::Vector3& scale) { - m_editorTransform.m_scale = scale.GetMaxElement(); + m_editorTransform.m_scale = scale; TransformChanged(); } AZ::Vector3 TransformComponent::GetLocalScale() { - return AZ::Vector3(m_editorTransform.m_scale); + return m_editorTransform.m_scale; } AZ::Vector3 TransformComponent::GetWorldScale() @@ -696,13 +695,13 @@ namespace AzToolsFramework void TransformComponent::SetLocalUniformScale(float scale) { - m_editorTransform.m_scale = scale; + m_editorTransform.m_scale = AZ::Vector3(scale); TransformChanged(); } float TransformComponent::GetLocalUniformScale() { - return m_editorTransform.m_scale; + return m_editorTransform.m_scale.GetMaxElement(); } float TransformComponent::GetWorldUniformScale() @@ -1309,7 +1308,7 @@ namespace AzToolsFramework { AzToolsFramework::ScopedUndoBatch undo("Reset transform values"); m_editorTransform.m_translate = AZ::Vector3::CreateZero(); - m_editorTransform.m_scale = 1.0f; + m_editorTransform.m_scale = AZ::Vector3::CreateOne(); m_editorTransform.m_rotate = AZ::Vector3::CreateZero(); OnTransformChanged(); SetDirty(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponentBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponentBus.h index 6082bda4bd..437a39b1a0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponentBus.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponentBus.h @@ -30,7 +30,7 @@ namespace AzToolsFramework EditorTransform() { m_translate = AZ::Vector3::CreateZero(); - m_scale = 1.0f; + m_scale = AZ::Vector3::CreateOne(); m_rotate = AZ::Vector3::CreateZero(); m_locked = false; } @@ -41,7 +41,7 @@ namespace AzToolsFramework } AZ::Vector3 m_translate; //! Translation in engine units (meters) - float m_scale; + AZ::Vector3 m_scale; AZ::Vector3 m_rotate; //! Rotation in degrees bool m_locked; }; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/PolygonLightDelegate.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/PolygonLightDelegate.cpp index 6ec780c2ab..e01559041c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/PolygonLightDelegate.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/PolygonLightDelegate.cpp @@ -50,6 +50,7 @@ namespace AZ AZStd::vector vertices = m_shapeBus->GetPolygonPrism()->m_vertexContainer.GetVertices(); Transform transform = GetTransform(); + transform.SetUniformScale(transform.GetUniformScale()); // Poly Prism only supports uniform scale. AZStd::vector transformedVertices; transformedVertices.reserve(vertices.size());