more tidying up

This commit is contained in:
greerdv
2021-05-25 15:43:04 +01:00
parent ccccfb2c5b
commit 92311ddf0d
7 changed files with 18 additions and 18 deletions
@@ -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<const Vector3&, const Quaternion&, const float>()->
Constructor<const Vector3&, const Quaternion&, const Vector3&>()->
Method("GetBasis", &Transform::GetBasis)->
Method("GetBasisX", &Transform::GetBasisX)->
Method("GetBasisY", &Transform::GetBasisY)->
@@ -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.
@@ -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)
@@ -44,7 +44,7 @@ namespace JsonSerializationTests
AZStd::shared_ptr<AZ::Transform> CreateFullySetInstance() override
{
return AZStd::make_shared<AZ::Transform>(
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 })");
@@ -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();
@@ -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;
};
@@ -50,6 +50,7 @@ namespace AZ
AZStd::vector<Vector2> vertices = m_shapeBus->GetPolygonPrism()->m_vertexContainer.GetVertices();
Transform transform = GetTransform();
transform.SetUniformScale(transform.GetUniformScale()); // Poly Prism only supports uniform scale.
AZStd::vector<Vector3> transformedVertices;
transformedVertices.reserve(vertices.size());