Merge pull request #1039 from aws-lumberyard-dev/transform-float-scale-3
refactor vector scale in Transform to float scale
This commit is contained in:
@@ -219,18 +219,11 @@ namespace AZ
|
||||
|
||||
//! Scale modifiers
|
||||
//! @{
|
||||
//! Set local scale of the transform.
|
||||
//! @param scale The new scale to set.
|
||||
virtual void SetLocalScale([[maybe_unused]] const AZ::Vector3& scale) {}
|
||||
|
||||
//! Get the scale value in local space.
|
||||
//! @deprecated GetLocalScale is deprecated, and is left only to allow migration of legacy vector scale.
|
||||
//! Get the legacy vector scale value in local space.
|
||||
//! @return The scale value in local space.
|
||||
virtual AZ::Vector3 GetLocalScale() { return AZ::Vector3(FLT_MAX); }
|
||||
|
||||
//! Get the scale value in world space.
|
||||
//! @return The scale value in world space.
|
||||
virtual AZ::Vector3 GetWorldScale() { return AZ::Vector3(FLT_MAX); }
|
||||
|
||||
//! Set the uniform scale value in local space.
|
||||
virtual void SetLocalUniformScale([[maybe_unused]] float scale) {}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace AZ
|
||||
// the min and max of each part and sum them to get the min and max co-ordinate of the transformed box. For a given new axis,
|
||||
// the coefficients for what proportion of each original axis is rotated onto that new axis are the same as the components we
|
||||
// would get by performing the inverse rotation on the new axis, so we need to take the conjugate to get the inverse rotation.
|
||||
axisCoeffs = transform.GetScale() * (transform.GetRotation().GetConjugate().TransformVector(axis));
|
||||
axisCoeffs = transform.GetUniformScale() * (transform.GetRotation().GetConjugate().TransformVector(axis));
|
||||
a = axisCoeffs * m_min;
|
||||
b = axisCoeffs * m_max;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace AZ
|
||||
return Obb::CreateFromPositionRotationAndHalfLengths(
|
||||
transform.TransformPoint(obb.GetPosition()),
|
||||
transform.GetRotation() * obb.GetRotation(),
|
||||
transform.GetScale() * obb.GetHalfLengths()
|
||||
transform.GetUniformScale() * obb.GetHalfLengths()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +130,8 @@ namespace AZ
|
||||
const Transform* transform = reinterpret_cast<const Transform*>(classPtr);
|
||||
float data[NumFloats];
|
||||
transform->GetRotation().StoreToFloat4(data);
|
||||
transform->GetScale().StoreToFloat3(&data[4]);
|
||||
transform->GetTranslation().StoreToFloat3(&data[7]);
|
||||
data[4] = transform->GetUniformScale();
|
||||
transform->GetTranslation().StoreToFloat3(&data[5]);
|
||||
|
||||
for (int i = 0; i < NumFloats; i++)
|
||||
{
|
||||
@@ -159,8 +159,8 @@ namespace AZ
|
||||
|
||||
size_t TransformSerializer::TextToData(const char* text, unsigned int textVersion, IO::GenericStream& stream, bool isDataBigEndian)
|
||||
{
|
||||
const size_t dataBufferSize = AZStd::max(NumFloatsVersion0, NumFloats);
|
||||
const size_t numElements = textVersion < 1 ? NumFloatsVersion0 : NumFloats;
|
||||
const size_t dataBufferSize = AZStd::max(AZStd::max(NumFloatsVersion1, NumFloatsVersion0), NumFloats);
|
||||
const size_t numElements = textVersion < 1 ? NumFloatsVersion0 : (textVersion == 1 ? NumFloatsVersion1 : NumFloats);
|
||||
|
||||
size_t nextNumberIndex = 0;
|
||||
AZStd::array<float, dataBufferSize> data;
|
||||
@@ -201,7 +201,34 @@ namespace AZ
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise load as a separate rotation, scale and translation
|
||||
// version 1 had a quaternion rotation, vector3 scale and vector3 translation
|
||||
else if (version == 1)
|
||||
{
|
||||
float data[NumFloatsVersion1];
|
||||
if (stream.GetLength() < sizeof(data))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stream.Read(sizeof(data), reinterpret_cast<void*>(data));
|
||||
|
||||
for (unsigned int i = 0; i < AZ_ARRAY_SIZE(data); ++i)
|
||||
{
|
||||
AZ_SERIALIZE_SWAP_ENDIAN(data[i], isDataBigEndian);
|
||||
}
|
||||
|
||||
Quaternion rotation = Quaternion::CreateFromFloat4(data);
|
||||
Vector3 vectorScale = Vector3::CreateFromFloat3(&data[4]);
|
||||
Vector3 translation = Vector3::CreateFromFloat3(&data[7]);
|
||||
|
||||
float uniformScale = vectorScale.GetMaxElement();
|
||||
|
||||
*reinterpret_cast<Transform*>(classPtr) =
|
||||
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateUniformScale(uniformScale);
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise load as a quaternion rotation, float scale and vector3 translation
|
||||
float data[NumFloats];
|
||||
if (stream.GetLength() < sizeof(data))
|
||||
{
|
||||
@@ -216,11 +243,11 @@ namespace AZ
|
||||
}
|
||||
|
||||
Quaternion rotation = Quaternion::CreateFromFloat4(data);
|
||||
Vector3 scale = Vector3::CreateFromFloat3(&data[4]);
|
||||
Vector3 translation = Vector3::CreateFromFloat3(&data[7]);
|
||||
float scale = data[4];
|
||||
Vector3 translation = Vector3::CreateFromFloat3(&data[5]);
|
||||
|
||||
*reinterpret_cast<Transform*>(classPtr) =
|
||||
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateScale(scale);
|
||||
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateUniformScale(scale);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -237,7 +264,7 @@ namespace AZ
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<Transform>()
|
||||
->Version(1)
|
||||
->Version(2)
|
||||
->Serializer<TransformSerializer>();
|
||||
}
|
||||
|
||||
@@ -250,7 +277,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 Vector3&>()->
|
||||
Constructor<const Vector3&, const Quaternion&, float>()->
|
||||
Method("GetBasis", &Transform::GetBasis)->
|
||||
Method("GetBasisX", &Transform::GetBasisX)->
|
||||
Method("GetBasisY", &Transform::GetBasisY)->
|
||||
@@ -283,15 +310,10 @@ namespace AZ
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Method("GetRotation", &Transform::GetRotation)->
|
||||
Method<void (Transform::*)(const Quaternion&)>("SetRotation", &Transform::SetRotation)->
|
||||
Method("GetScale", &Transform::GetScale)->
|
||||
Method("GetUniformScale", &Transform::GetUniformScale)->
|
||||
Method("SetScale", &Transform::SetScale)->
|
||||
Method("SetUniformScale", &Transform::SetUniformScale)->
|
||||
Method("ExtractScale", &Transform::ExtractScale)->
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Method("ExtractUniformScale", &Transform::ExtractUniformScale)->
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Method("MultiplyByScale", &Transform::MultiplyByScale)->
|
||||
Method("MultiplyByUniformScale", &Transform::MultiplyByUniformScale)->
|
||||
Method("GetInverse", &Transform::GetInverse)->
|
||||
Method("Invert", &Transform::Invert)->
|
||||
@@ -310,7 +332,6 @@ namespace AZ
|
||||
Method("CreateFromQuaternionAndTranslation", &Transform::CreateFromQuaternionAndTranslation)->
|
||||
Method("CreateFromMatrix3x3", &Transform::CreateFromMatrix3x3)->
|
||||
Method("CreateFromMatrix3x3AndTranslation", &Transform::CreateFromMatrix3x3AndTranslation)->
|
||||
Method("CreateScale", &Transform::CreateScale)->
|
||||
Method("CreateUniformScale", &Transform::CreateUniformScale)->
|
||||
Method("CreateTranslation", &Transform::CreateTranslation)->
|
||||
Method("ConstructFromValuesNumeric", &Internal::ConstructTransformFromValues);
|
||||
@@ -321,7 +342,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
Matrix3x3 tmp = value;
|
||||
result.m_scale = tmp.ExtractScale();
|
||||
result.m_scale = tmp.ExtractScale().GetMaxElement();
|
||||
result.m_rotation = Quaternion::CreateFromMatrix3x3(tmp);
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
@@ -331,7 +352,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
Matrix3x3 tmp = value;
|
||||
result.m_scale = tmp.ExtractScale();
|
||||
result.m_scale = tmp.ExtractScale().GetMaxElement();
|
||||
result.m_rotation = Quaternion::CreateFromMatrix3x3(tmp);
|
||||
result.m_translation = p;
|
||||
return result;
|
||||
@@ -341,7 +362,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
Matrix3x4 tmp = value;
|
||||
result.m_scale = tmp.ExtractScale();
|
||||
result.m_scale = tmp.ExtractScale().GetMaxElement();
|
||||
result.m_rotation = Quaternion::CreateFromMatrix3x4(tmp);
|
||||
result.m_translation = value.GetTranslation();
|
||||
return result;
|
||||
|
||||
@@ -25,10 +25,13 @@ namespace AZ
|
||||
: public SerializeContext::IDataSerializer
|
||||
{
|
||||
public:
|
||||
// number of floats in the serialized representation, 4 for rotation, 3 for scale and 3 for translation
|
||||
static constexpr int NumFloats = 10;
|
||||
// number of floats in the serialized representation, 4 for rotation, 1 for scale and 3 for translation
|
||||
static constexpr int NumFloats = 8;
|
||||
|
||||
// number of floats in the old format, which stored a 3x4 matrix
|
||||
// number of floats in version 1, which used 4 for rotation, 3 for scale and 3 for translation
|
||||
static constexpr int NumFloatsVersion1 = 10;
|
||||
|
||||
// number of floats in version 0, which stored a 3x4 matrix
|
||||
static constexpr int NumFloatsVersion0 = 12;
|
||||
|
||||
size_t Save(const void* classPtr, IO::GenericStream& stream, bool isDataBigEndian) override;
|
||||
@@ -45,7 +48,7 @@ namespace AZ
|
||||
static constexpr float MaxTransformScale = 1e9f;
|
||||
//! @}
|
||||
|
||||
//! The basic transformation class, represented using a quaternion rotation, vector scale and vector translation.
|
||||
//! The basic transformation class, represented using a quaternion rotation, float scale and vector translation.
|
||||
//! By design, cannot represent skew transformations.
|
||||
class Transform
|
||||
{
|
||||
@@ -63,7 +66,7 @@ namespace AZ
|
||||
Transform() = default;
|
||||
|
||||
//! Construct a transform from components.
|
||||
Transform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale);
|
||||
Transform(const Vector3& translation, const Quaternion& rotation, float scale);
|
||||
|
||||
//! Creates an identity transform.
|
||||
static Transform CreateIdentity();
|
||||
@@ -82,16 +85,20 @@ namespace AZ
|
||||
static Transform CreateFromQuaternionAndTranslation(const class Quaternion& q, const Vector3& p);
|
||||
|
||||
//! Constructs from a Matrix3x3, translation is set to zero.
|
||||
//! Note that Transform only allows uniform scale, so if the matrix has different scale values along its axes,
|
||||
//! the largest matrix scale value will be used to uniformly scale the Transform.
|
||||
static Transform CreateFromMatrix3x3(const class Matrix3x3& value);
|
||||
|
||||
//! Constructs from a Matrix3x3, translation is set to zero.
|
||||
//! Constructs from a Matrix3x3 and translation Vector3.
|
||||
//! Note that Transform only allows uniform scale, so if the matrix has different scale values along its axes,
|
||||
//! the largest matrix scale value will be used to uniformly scale the Transform.
|
||||
static Transform CreateFromMatrix3x3AndTranslation(const class Matrix3x3& value, const Vector3& p);
|
||||
|
||||
//! Constructs from a Matrix3x4.
|
||||
//! Note that Transform only allows uniform scale, so if the matrix has different scale values along its axes,
|
||||
//! the largest matrix scale value will be used to uniformly scale the Transform.
|
||||
static Transform CreateFromMatrix3x4(const Matrix3x4& value);
|
||||
|
||||
//! 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.
|
||||
static Transform CreateUniformScale(const float scale);
|
||||
|
||||
@@ -122,18 +129,12 @@ namespace AZ
|
||||
const Quaternion& GetRotation() const;
|
||||
void SetRotation(const Quaternion& rotation);
|
||||
|
||||
Vector3 GetScale() const;
|
||||
float GetUniformScale() const;
|
||||
void SetScale(const Vector3& v);
|
||||
void SetUniformScale(const float scale);
|
||||
|
||||
//! Sets the transform's scale to a unit value and returns the previous scale value.
|
||||
Vector3 ExtractScale();
|
||||
|
||||
//! Sets the transform's scale to a unit value and returns the previous scale value.
|
||||
float ExtractUniformScale();
|
||||
|
||||
void MultiplyByScale(const AZ::Vector3& scale);
|
||||
void MultiplyByUniformScale(float scale);
|
||||
|
||||
Transform operator*(const Transform& rhs) const;
|
||||
@@ -168,7 +169,7 @@ namespace AZ
|
||||
private:
|
||||
|
||||
Quaternion m_rotation;
|
||||
Vector3 m_scale;
|
||||
float m_scale;
|
||||
Vector3 m_translation;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZ_MATH_INLINE Transform::Transform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale)
|
||||
AZ_MATH_INLINE Transform::Transform(const Vector3& translation, const Quaternion& rotation, float scale)
|
||||
: m_translation(translation)
|
||||
, m_rotation(rotation)
|
||||
, m_scale(scale)
|
||||
@@ -25,7 +25,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = q;
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
@@ -58,26 +58,16 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = q;
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::CreateScale(const Vector3& scale)
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "CreateScale is deprecated, please use CreateUniformScale instead.");
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = scale;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::CreateUniformScale(float scale)
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = Vector3(scale);
|
||||
result.m_scale = scale;
|
||||
result.m_translation = Vector3::CreateZero();
|
||||
return result;
|
||||
}
|
||||
@@ -86,7 +76,7 @@ namespace AZ
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = Quaternion::CreateIdentity();
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = translation;
|
||||
return result;
|
||||
}
|
||||
@@ -114,17 +104,17 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::GetBasisX() const
|
||||
{
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisX(m_scale.GetX()));
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisX(m_scale));
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::GetBasisY() const
|
||||
{
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisY(m_scale.GetY()));
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisY(m_scale));
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::GetBasisZ() const
|
||||
{
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisZ(m_scale.GetZ()));
|
||||
return m_rotation.TransformVector(Vector3::CreateAxisZ(m_scale));
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::GetBasisAndTranslation(Vector3* basisX, Vector3* basisY, Vector3* basisZ, Vector3* pos) const
|
||||
@@ -160,49 +150,23 @@ namespace AZ
|
||||
m_rotation = rotation;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::GetScale() const
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "GetScale is deprecated, please use GetUniformScale instead.");
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE float Transform::GetUniformScale() const
|
||||
{
|
||||
return m_scale.GetMaxElement();
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::SetScale(const Vector3& scale)
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "SetScale is deprecated, please use SetUniformScale instead.");
|
||||
m_scale = scale;
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::SetUniformScale(const float scale)
|
||||
{
|
||||
m_scale = Vector3(scale);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector3 Transform::ExtractScale()
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "ExtractScale is deprecated, please use ExtractUniformScale instead.");
|
||||
const Vector3 scale = m_scale;
|
||||
m_scale = Vector3::CreateOne();
|
||||
return scale;
|
||||
m_scale = scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE float Transform::ExtractUniformScale()
|
||||
{
|
||||
const float scale = m_scale.GetMaxElement();
|
||||
m_scale = Vector3::CreateOne();
|
||||
const float scale = m_scale;
|
||||
m_scale = 1.0f;
|
||||
return scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::MultiplyByScale(const Vector3& scale)
|
||||
{
|
||||
AZ_WarningOnce("Transform", false, "MultiplyByScale is deprecated, please use MultiplyByUniformScale instead.");
|
||||
m_scale *= scale;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::MultiplyByUniformScale(float scale)
|
||||
{
|
||||
m_scale *= scale;
|
||||
@@ -240,10 +204,9 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::GetInverse() const
|
||||
{
|
||||
// note - need to be careful about how to calculate inverse when there is non-uniform scale
|
||||
Transform out;
|
||||
out.m_rotation = m_rotation.GetConjugate();
|
||||
out.m_scale = m_scale.GetReciprocal();
|
||||
out.m_scale = 1.0f / m_scale;
|
||||
out.m_translation = -out.m_scale * (out.m_rotation.TransformVector(m_translation));
|
||||
return out;
|
||||
}
|
||||
@@ -255,27 +218,27 @@ namespace AZ
|
||||
|
||||
AZ_MATH_INLINE bool Transform::IsOrthogonal(float tolerance) const
|
||||
{
|
||||
return m_scale.IsClose(Vector3::CreateOne(), tolerance);
|
||||
return AZ::IsClose(m_scale, 1.0f, tolerance);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Transform Transform::GetOrthogonalized() const
|
||||
{
|
||||
Transform result;
|
||||
result.m_rotation = m_rotation;
|
||||
result.m_scale = Vector3::CreateOne();
|
||||
result.m_scale = 1.0f;
|
||||
result.m_translation = m_translation;
|
||||
return result;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::Orthogonalize()
|
||||
{
|
||||
m_scale = Vector3::CreateOne();
|
||||
m_scale = 1.0f;
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE bool Transform::IsClose(const Transform& rhs, float tolerance) const
|
||||
{
|
||||
return m_rotation.IsClose(rhs.m_rotation, tolerance)
|
||||
&& m_scale.IsClose(rhs.m_scale, tolerance)
|
||||
&& AZ::IsClose(m_scale, rhs.m_scale, tolerance)
|
||||
&& m_translation.IsClose(rhs.m_translation, tolerance);
|
||||
}
|
||||
|
||||
@@ -304,21 +267,21 @@ namespace AZ
|
||||
AZ_MATH_INLINE void Transform::SetFromEulerDegrees(const Vector3& eulerDegrees)
|
||||
{
|
||||
m_translation = Vector3::CreateZero();
|
||||
m_scale = Vector3::CreateOne();
|
||||
m_scale = 1.0f;
|
||||
m_rotation.SetFromEulerDegrees(eulerDegrees);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE void Transform::SetFromEulerRadians(const Vector3& eulerRadians)
|
||||
{
|
||||
m_translation = Vector3::CreateZero();
|
||||
m_scale = Vector3::CreateOne();
|
||||
m_scale = 1.0f;
|
||||
m_rotation.SetFromEulerRadians(eulerRadians);
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE bool Transform::IsFinite() const
|
||||
{
|
||||
return m_rotation.IsFinite()
|
||||
&& m_scale.IsFinite()
|
||||
&& AZ::IsFiniteFloat(m_scale)
|
||||
&& m_translation.IsFinite();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace AZ
|
||||
|
||||
result.Combine(loadResult);
|
||||
|
||||
transformInstance->SetScale(AZ::Vector3(scale));
|
||||
transformInstance->SetUniformScale(scale);
|
||||
}
|
||||
|
||||
return context.Report(
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace AZ
|
||||
return os
|
||||
<< "translation: " << transform.GetTranslation()
|
||||
<< " rotation: " << transform.GetRotation()
|
||||
<< " scale: " << transform.GetScale();
|
||||
<< " scale: " << transform.GetUniformScale();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Color& color)
|
||||
|
||||
@@ -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), AZ::Vector3(9.0f));
|
||||
AZ::Vector3(1.0f, 2.0f, 3.0f), AZ::Quaternion(0.25f, 0.5f, 0.75f, 1.0f), 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),
|
||||
AZ::Vector3(5.5f));
|
||||
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 })");
|
||||
|
||||
@@ -406,21 +406,10 @@ namespace AzFramework
|
||||
return m_localTM.GetRotation();
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalScale(const AZ::Vector3& scale)
|
||||
{
|
||||
AZ::Transform newLocalTM = m_localTM;
|
||||
newLocalTM.SetScale(scale);
|
||||
SetLocalTM(newLocalTM);
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetLocalScale()
|
||||
{
|
||||
return m_localTM.GetScale();
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetWorldScale()
|
||||
{
|
||||
return m_worldTM.GetScale();
|
||||
AZ_WarningOnce("TransformComponent", false, "GetLocalScale is deprecated, please use GetLocalUniformScale instead");
|
||||
return AZ::Vector3(m_localTM.GetUniformScale());
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalUniformScale(float scale)
|
||||
@@ -756,11 +745,11 @@ namespace AzFramework
|
||||
->Event("GetLocalRotationQuaternion", &AZ::TransformBus::Events::GetLocalRotationQuaternion)
|
||||
->Attribute("Rotation", AZ::Edit::Attributes::PropertyRotation)
|
||||
->VirtualProperty("Rotation", "GetLocalRotationQuaternion", "SetLocalRotationQuaternion")
|
||||
->Event("SetLocalScale", &AZ::TransformBus::Events::SetLocalScale)
|
||||
->Event("GetLocalScale", &AZ::TransformBus::Events::GetLocalScale)
|
||||
->Attribute("Scale", AZ::Edit::Attributes::PropertyScale)
|
||||
->VirtualProperty("Scale", "GetLocalScale", "SetLocalScale")
|
||||
->Event("GetWorldScale", &AZ::TransformBus::Events::GetWorldScale)
|
||||
->Event("SetLocalUniformScale", &AZ::TransformBus::Events::SetLocalUniformScale)
|
||||
->Event("GetLocalUniformScale", &AZ::TransformBus::Events::GetLocalUniformScale)
|
||||
->VirtualProperty("Uniform Scale", "GetLocalUniformScale", "SetLocalUniformScale")
|
||||
->Event("GetChildren", &AZ::TransformBus::Events::GetChildren)
|
||||
->Event("GetAllDescendants", &AZ::TransformBus::Events::GetAllDescendants)
|
||||
->Event("GetEntityAndAllDescendants", &AZ::TransformBus::Events::GetEntityAndAllDescendants)
|
||||
|
||||
@@ -128,9 +128,7 @@ namespace AzFramework
|
||||
AZ::Quaternion GetLocalRotationQuaternion() override;
|
||||
|
||||
// Scale Modifiers
|
||||
void SetLocalScale(const AZ::Vector3& scale) override;
|
||||
AZ::Vector3 GetLocalScale() override;
|
||||
AZ::Vector3 GetWorldScale() override;
|
||||
|
||||
void SetLocalUniformScale(float scale) override;
|
||||
float GetLocalUniformScale() override;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace AzToolsFramework
|
||||
AZ::Transform result;
|
||||
result.SetRotation(m_space.GetRotation() * localTransform.GetRotation());
|
||||
result.SetTranslation(m_space.TransformPoint(m_nonUniformScale * localTransform.GetTranslation()));
|
||||
result.SetScale(m_space.GetScale() * localTransform.GetUniformScale());
|
||||
result.SetUniformScale(m_space.GetUniformScale() * localTransform.GetUniformScale());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::Transform worldFromLocal = AZ::Transform::CreateIdentity();
|
||||
AZ::TransformBus::EventResult(worldFromLocal, m_entityComponentIdPair.GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
|
||||
worldFromLocal.ExtractScale();
|
||||
worldFromLocal.ExtractUniformScale();
|
||||
m_manipulators = AZStd::make_unique<ScaleManipulators>(worldFromLocal);
|
||||
m_manipulators->Register(g_mainManipulatorManagerId);
|
||||
m_manipulators->SetAxes(AZ::Vector3::CreateAxisX(), AZ::Vector3::CreateAxisY(), AZ::Vector3::CreateAxisZ());
|
||||
|
||||
+36
-27
@@ -32,7 +32,6 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorPendingCompositionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
@@ -50,10 +49,10 @@ 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, AZ::Vector3& scale)
|
||||
// Decompose a transform into euler angles in degrees, uniform scale, and translation.
|
||||
void DecomposeTransform(const AZ::Transform& transform, AZ::Vector3& translation, AZ::Vector3& rotation, float& scale)
|
||||
{
|
||||
scale = transform.GetScale();
|
||||
scale = transform.GetUniformScale();
|
||||
translation = transform.GetTranslation();
|
||||
rotation = transform.GetRotation().GetEulerDegrees();
|
||||
}
|
||||
@@ -120,7 +119,7 @@ namespace AzToolsFramework
|
||||
// Decompose the old slice-relative transform and set it as a our editor transform,
|
||||
// since the entity is now our parent.
|
||||
EditorTransform editorTransform;
|
||||
DecomposeTransform(sliceRelTransform, editorTransform.m_translate, editorTransform.m_rotate, editorTransform.m_scale);
|
||||
DecomposeTransform(sliceRelTransform, editorTransform.m_translate, editorTransform.m_rotate, editorTransform.m_uniformScale);
|
||||
editorTransformElement.Convert<EditorTransform>(context);
|
||||
editorTransformElement.SetData(context, editorTransform);
|
||||
}
|
||||
@@ -170,6 +169,23 @@ namespace AzToolsFramework
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorTransformDataConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
|
||||
{
|
||||
if (classElement.GetVersion() < 3)
|
||||
{
|
||||
// version 3 replaces vector scale with uniform scale but does not yet delete the legacy scale data
|
||||
// in order to allow for migration
|
||||
AZ::Vector3 vectorScale;
|
||||
if (classElement.FindSubElementAndGetData<AZ::Vector3>(AZ_CRC_CE("Scale"), vectorScale))
|
||||
{
|
||||
const float uniformScale = vectorScale.GetMaxElement();
|
||||
classElement.AddElementWithData(context, "UniformScale", uniformScale);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace Internal
|
||||
|
||||
TransformComponent::TransformComponent()
|
||||
@@ -357,7 +373,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::Transform TransformComponent::GetLocalScaleTM() const
|
||||
{
|
||||
return AZ::Transform::CreateUniformScale(m_editorTransform.m_scale.GetMaxElement());
|
||||
return AZ::Transform::CreateUniformScale(m_editorTransform.m_uniformScale);
|
||||
}
|
||||
|
||||
const AZ::Transform& TransformComponent::GetLocalTM()
|
||||
@@ -374,12 +390,13 @@ namespace AzToolsFramework
|
||||
// given a local transform, update local transform.
|
||||
void TransformComponent::SetLocalTM(const AZ::Transform& finalTx)
|
||||
{
|
||||
AZ::Vector3 tx, rot, scale;
|
||||
Internal::DecomposeTransform(finalTx, tx, rot, scale);
|
||||
AZ::Vector3 tx, rot;
|
||||
float uniformScale;
|
||||
Internal::DecomposeTransform(finalTx, tx, rot, uniformScale);
|
||||
|
||||
m_editorTransform.m_translate = tx;
|
||||
m_editorTransform.m_rotate = rot;
|
||||
m_editorTransform.m_scale = scale;
|
||||
m_editorTransform.m_uniformScale = uniformScale;
|
||||
|
||||
TransformChanged();
|
||||
}
|
||||
@@ -599,31 +616,21 @@ namespace AzToolsFramework
|
||||
return result;
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalScale(const AZ::Vector3& scale)
|
||||
{
|
||||
m_editorTransform.m_scale = scale;
|
||||
TransformChanged();
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetLocalScale()
|
||||
{
|
||||
return m_editorTransform.m_scale;
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetWorldScale()
|
||||
{
|
||||
return GetWorldTM().GetScale();
|
||||
AZ_WarningOnce("TransformComponent", false, "GetLocalScale is deprecated, please use GetLocalUniformScale instead");
|
||||
return m_editorTransform.m_legacyScale;
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalUniformScale(float scale)
|
||||
{
|
||||
m_editorTransform.m_scale = AZ::Vector3(scale);
|
||||
m_editorTransform.m_uniformScale = scale;
|
||||
TransformChanged();
|
||||
}
|
||||
|
||||
float TransformComponent::GetLocalUniformScale()
|
||||
{
|
||||
return m_editorTransform.m_scale.GetMaxElement();
|
||||
return m_editorTransform.m_uniformScale;
|
||||
}
|
||||
|
||||
float TransformComponent::GetWorldUniformScale()
|
||||
@@ -1141,9 +1148,10 @@ namespace AzToolsFramework
|
||||
serializeContext->Class<EditorTransform>()->
|
||||
Field("Translate", &EditorTransform::m_translate)->
|
||||
Field("Rotate", &EditorTransform::m_rotate)->
|
||||
Field("Scale", &EditorTransform::m_scale)->
|
||||
Field("Scale", &EditorTransform::m_legacyScale)->
|
||||
Field("Locked", &EditorTransform::m_locked)->
|
||||
Version(2);
|
||||
Field("UniformScale", &EditorTransform::m_uniformScale)->
|
||||
Version(3, &Internal::EditorTransformDataConverter);
|
||||
|
||||
serializeContext->Class<Components::TransformComponent, EditorComponentBase>()->
|
||||
Field("Parent Entity", &TransformComponent::m_parentEntityId)->
|
||||
@@ -1202,7 +1210,7 @@ namespace AzToolsFramework
|
||||
Attribute(AZ::Edit::Attributes::Suffix, " deg")->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)->
|
||||
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
|
||||
DataElement(TransformScaleHandler, &EditorTransform::m_scale, "Scale", "Local Scale")->
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &EditorTransform::m_uniformScale, "Uniform Scale", "Local Uniform Scale")->
|
||||
Attribute(AZ::Edit::Attributes::Step, 0.1f)->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)
|
||||
;
|
||||
@@ -1230,7 +1238,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
AzToolsFramework::ScopedUndoBatch undo("Reset transform values");
|
||||
m_editorTransform.m_translate = AZ::Vector3::CreateZero();
|
||||
m_editorTransform.m_scale = AZ::Vector3::CreateOne();
|
||||
m_editorTransform.m_legacyScale = AZ::Vector3::CreateOne();
|
||||
m_editorTransform.m_uniformScale = 1.0f;
|
||||
m_editorTransform.m_rotate = AZ::Vector3::CreateZero();
|
||||
OnTransformChanged();
|
||||
SetDirty();
|
||||
|
||||
@@ -115,9 +115,7 @@ namespace AzToolsFramework
|
||||
AZ::Quaternion GetLocalRotationQuaternion() override;
|
||||
|
||||
// Scale Modifiers
|
||||
void SetLocalScale(const AZ::Vector3& scale) override;
|
||||
AZ::Vector3 GetLocalScale() override;
|
||||
AZ::Vector3 GetWorldScale() override;
|
||||
|
||||
void SetLocalUniformScale(float scale) override;
|
||||
float GetLocalUniformScale() override;
|
||||
|
||||
+6
-4
@@ -30,7 +30,8 @@ namespace AzToolsFramework
|
||||
EditorTransform()
|
||||
{
|
||||
m_translate = AZ::Vector3::CreateZero();
|
||||
m_scale = AZ::Vector3::CreateOne();
|
||||
m_legacyScale = AZ::Vector3::CreateOne();
|
||||
m_uniformScale = 1.0f;
|
||||
m_rotate = AZ::Vector3::CreateZero();
|
||||
m_locked = false;
|
||||
}
|
||||
@@ -40,9 +41,10 @@ namespace AzToolsFramework
|
||||
return EditorTransform();
|
||||
}
|
||||
|
||||
AZ::Vector3 m_translate; //! Translation in engine units (meters)
|
||||
AZ::Vector3 m_scale;
|
||||
AZ::Vector3 m_rotate; //! Rotation in degrees
|
||||
AZ::Vector3 m_translate; //!< Translation in engine units (meters)
|
||||
AZ::Vector3 m_legacyScale; //!< Legacy vector scale value, retained only for migration.
|
||||
float m_uniformScale; //!< Single scale value applied uniformly.
|
||||
AZ::Vector3 m_rotate; //!< Rotation in degrees
|
||||
bool m_locked;
|
||||
};
|
||||
|
||||
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* 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 "AzToolsFramework_precompiled.h"
|
||||
#include <ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void RegisterTransformScaleHandler()
|
||||
{
|
||||
PropertyTypeRegistrationMessages::Bus::Broadcast(&PropertyTypeRegistrationMessages::RegisterPropertyType, aznew Components::TransformScalePropertyHandler());
|
||||
}
|
||||
|
||||
namespace Components
|
||||
{
|
||||
AZ::u32 TransformScalePropertyHandler::GetHandlerName(void) const
|
||||
{
|
||||
return TransformScaleHandler;
|
||||
}
|
||||
|
||||
QWidget* TransformScalePropertyHandler::CreateGUI(QWidget* parent)
|
||||
{
|
||||
AzQtComponents::DoubleSpinBox* newCtrl = new AzQtComponents::DoubleSpinBox(parent);
|
||||
connect(newCtrl, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), newCtrl, [newCtrl]()
|
||||
{
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, newCtrl);
|
||||
});
|
||||
|
||||
newCtrl->setMinimum(AZ::MinTransformScale);
|
||||
newCtrl->setMaximum(AZ::MaxTransformScale);
|
||||
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
|
||||
{
|
||||
if (attrib == AZ::Edit::Attributes::Suffix)
|
||||
{
|
||||
AZStd::string label;
|
||||
if (attrValue->Read<AZStd::string>(label))
|
||||
{
|
||||
GUI->setSuffix(label.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
const float value = aznumeric_cast<float>(GUI->value());
|
||||
const float currentMaxElement = instance.GetMaxElement();
|
||||
if (currentMaxElement != 0.0f)
|
||||
{
|
||||
instance *= value / currentMaxElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = AZ::Vector3(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool TransformScalePropertyHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
QSignalBlocker signalBlocker(GUI);
|
||||
GUI->setValue(instance.GetMaxElement());
|
||||
return true;
|
||||
}
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzQtComponents/Components/Widgets/SpinBox.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
static const AZ::Crc32 TransformScaleHandler = AZ_CRC_CE("TransformScale");
|
||||
|
||||
//! Handler to allow the scale field inside the Transform Component to be represented as a single value in
|
||||
//! the editor, but stored internally as a Vector3.
|
||||
//! The purpose for this is to prevent any new entities being created with non-uniform scale on the Transform
|
||||
//! Component, but preserve the data required for migrating any existing entities to use the Non-Uniform Scale
|
||||
//! Component, until all migration work is completed.
|
||||
//! The value shown in the editor will be the maximum value from the scale vector, and changing the value in
|
||||
//! the editor will update the vector so that its maximum value matches the newly edited value, but its
|
||||
//! components retain their existing proportion.
|
||||
//! For example, if the current vector scale is (2, 3, 4), the value in the editor will appear as 4. If the value
|
||||
//! in the editor is updated to 2, then the vector scale will update to (1, 1.5, 2), keeping the same proportion
|
||||
//! between the x, y and z components.
|
||||
class TransformScalePropertyHandler
|
||||
: public QObject
|
||||
, public AzToolsFramework::PropertyHandler<AZ::Vector3, AzQtComponents::DoubleSpinBox>
|
||||
{
|
||||
Q_OBJECT //AUTOMOC
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TransformScalePropertyHandler, AZ::SystemAllocator, 0);
|
||||
|
||||
AZ::u32 GetHandlerName(void) const override;
|
||||
QWidget* CreateGUI(QWidget* parent) override;
|
||||
void ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
void WriteGUIValuesIntoProperty(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
bool ReadValuesIntoGUI(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
-3
@@ -16,7 +16,6 @@
|
||||
#include <AzToolsFramework/ToolsComponents/EditorEntityIdContainer.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyAudioCtrlTypes.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/GenericComboBoxCtrl.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -38,7 +37,6 @@ namespace AzToolsFramework
|
||||
void RegisterButtonPropertyHandlers();
|
||||
void RegisterMultiLineEditHandler();
|
||||
void RegisterCrcHandler();
|
||||
void RegisterTransformScaleHandler();
|
||||
void ReflectPropertyEditor(AZ::ReflectContext* context);
|
||||
|
||||
namespace Components
|
||||
@@ -192,7 +190,6 @@ namespace AzToolsFramework
|
||||
RegisterVectorHandlers();
|
||||
RegisterButtonPropertyHandlers();
|
||||
RegisterMultiLineEditHandler();
|
||||
RegisterTransformScaleHandler();
|
||||
|
||||
// GenericComboBoxHandlers
|
||||
RegisterGenericComboBoxHandler<AZ::Crc32>();
|
||||
|
||||
@@ -293,8 +293,6 @@ set(FILES
|
||||
ToolsComponents/TransformComponent.h
|
||||
ToolsComponents/TransformComponent.cpp
|
||||
ToolsComponents/TransformComponentBus.h
|
||||
ToolsComponents/TransformScalePropertyHandler.cpp
|
||||
ToolsComponents/TransformScalePropertyHandler.h
|
||||
ToolsComponents/ScriptEditorComponent.cpp
|
||||
ToolsComponents/ScriptEditorComponent.h
|
||||
ToolsComponents/ToolsAssetCatalogComponent.cpp
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ namespace UnitTest
|
||||
|
||||
// Set the new entity's transform to non zero values
|
||||
// This helps validate in comparison tests that the transform values of created entities persist during slice operations
|
||||
entityTransform->SetLocalScale(AZ::Vector3(5, 5, 5));
|
||||
entityTransform->SetLocalUniformScale(5);
|
||||
entityTransform->SetLocalRotation(AZ::Vector3RadToDeg(AZ::Vector3(90, 90, 90)));
|
||||
entityTransform->SetLocalTranslation(AZ::Vector3(100, 100, 100));
|
||||
|
||||
|
||||
@@ -2012,9 +2012,9 @@ void CTrackViewAnimNode::SetPosRotScaleTracksDefaultValues(bool positionAllowed,
|
||||
}
|
||||
if (scaleAllowed)
|
||||
{
|
||||
AZ::Vector3 scale = AZ::Vector3::CreateOne();
|
||||
AZ::TransformBus::EventResult(scale, entityId, &AZ::TransformBus::Events::GetWorldScale);
|
||||
m_animNode->SetScale(time, AZVec3ToLYVec3(scale));
|
||||
float scale = 1.0f;
|
||||
AZ::TransformBus::EventResult(scale, entityId, &AZ::TransformBus::Events::GetWorldUniformScale);
|
||||
m_animNode->SetScale(time, Vec3(scale, scale, scale));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ void CTrackViewSequence::SyncSelectedTracksToBase()
|
||||
const Vec3 scale = pAnimNode->GetScale();
|
||||
|
||||
AZ::Transform transform = AZ::Transform::CreateIdentity();
|
||||
transform.SetScale(LYVec3ToAZVec3(scale));
|
||||
transform.SetUniformScale(LYVec3ToAZVec3(scale).GetMaxElement());
|
||||
transform.SetRotation(LYQuaternionToAZQuaternion(rotation));
|
||||
transform.SetTranslation(LYVec3ToAZVec3(position));
|
||||
|
||||
@@ -870,7 +870,7 @@ void CTrackViewSequence::SyncSelectedTracksFromBase()
|
||||
|
||||
pAnimNode->SetPos(AZVec3ToLYVec3(transform.GetTranslation()));
|
||||
pAnimNode->SetRotation(AZQuaternionToLYQuaternion(transform.GetRotation()));
|
||||
pAnimNode->SetScale(AZVec3ToLYVec3(transform.GetScale()));
|
||||
pAnimNode->SetScale(AZVec3ToLYVec3(AZ::Vector3(transform.GetUniformScale())));
|
||||
|
||||
bNothingWasSynced = false;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzToolsFramework/Debug/TraceContext.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyVectorCtrl.hxx>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyDoubleSpinCtrl.hxx>
|
||||
#include <SceneAPI/SceneUI/RowWidgets/TransformRowHandler.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -58,10 +59,11 @@ namespace AZ
|
||||
}
|
||||
else
|
||||
{
|
||||
AzToolsFramework::Vector3PropertyHandler handler;
|
||||
handler.ConsumeAttribute(widget->GetTranslationWidget(), attrib, attrValue, debugName);
|
||||
handler.ConsumeAttribute(widget->GetRotationWidget(), attrib, attrValue, debugName);
|
||||
handler.ConsumeAttribute(widget->GetScaleWidget(), attrib, attrValue, debugName);
|
||||
AzToolsFramework::Vector3PropertyHandler vector3Handler;
|
||||
vector3Handler.ConsumeAttribute(widget->GetTranslationWidget(), attrib, attrValue, debugName);
|
||||
vector3Handler.ConsumeAttribute(widget->GetRotationWidget(), attrib, attrValue, debugName);
|
||||
AzToolsFramework::doublePropertySpinboxHandler spinboxHandler;
|
||||
spinboxHandler.ConsumeAttribute(widget->GetScaleWidget(), attrib, attrValue, debugName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <QGridLayout>
|
||||
#include <SceneAPI/SceneUI/RowWidgets/TransformRowWidget.h>
|
||||
#include <AzQtComponents/Components/Widgets/VectorInput.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyDoubleSpinCtrl.hxx>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx>
|
||||
|
||||
@@ -47,7 +48,7 @@ namespace AZ
|
||||
ExpandedTransform::ExpandedTransform()
|
||||
: m_translation(0, 0, 0)
|
||||
, m_rotation(0, 0, 0)
|
||||
, m_scale(1, 1, 1)
|
||||
, m_scale(1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,14 +61,14 @@ namespace AZ
|
||||
{
|
||||
m_translation = transform.GetTranslation();
|
||||
m_rotation = transform.GetEulerDegrees();
|
||||
m_scale = transform.GetScale();
|
||||
m_scale = transform.GetUniformScale();
|
||||
}
|
||||
|
||||
void ExpandedTransform::GetTransform(AZ::Transform& transform) const
|
||||
{
|
||||
transform = Transform::CreateTranslation(m_translation);
|
||||
transform *= AZ::ConvertEulerDegreesToTransform(m_rotation);
|
||||
transform.MultiplyByScale(m_scale);
|
||||
transform.MultiplyByUniformScale(m_scale);
|
||||
}
|
||||
|
||||
const AZ::Vector3& ExpandedTransform::GetTranslation() const
|
||||
@@ -90,12 +91,12 @@ namespace AZ
|
||||
m_rotation = rotation;
|
||||
}
|
||||
|
||||
const AZ::Vector3& ExpandedTransform::GetScale() const
|
||||
const float ExpandedTransform::GetScale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
void ExpandedTransform::SetScale(const AZ::Vector3& scale)
|
||||
void ExpandedTransform::SetScale(const float scale)
|
||||
{
|
||||
m_scale = scale;
|
||||
}
|
||||
@@ -131,7 +132,7 @@ namespace AZ
|
||||
m_rotationWidget->setMaximum(360);
|
||||
m_rotationWidget->setSuffix(" degrees");
|
||||
|
||||
m_scaleWidget = new AzQtComponents::VectorInput(this, 3);
|
||||
m_scaleWidget = new AzToolsFramework::PropertyDoubleSpinCtrl(this);
|
||||
m_scaleWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
m_scaleWidget->setMinimum(0);
|
||||
m_scaleWidget->setMaximum(10000);
|
||||
@@ -191,13 +192,10 @@ namespace AZ
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, this);
|
||||
});
|
||||
|
||||
QObject::connect(m_scaleWidget, &AzQtComponents::VectorInput::valueChanged, this, [this]
|
||||
QObject::connect(m_scaleWidget, &AzToolsFramework::PropertyDoubleSpinCtrl::valueChanged, this, [this]
|
||||
{
|
||||
AzQtComponents::VectorInput* widget = this->GetScaleWidget();
|
||||
AZ::Vector3 scale;
|
||||
|
||||
PopulateVector3(widget, scale);
|
||||
|
||||
AzToolsFramework::PropertyDoubleSpinCtrl* widget = this->GetScaleWidget();
|
||||
float scale = aznumeric_cast<float>(widget->value());
|
||||
m_transform.SetScale(scale);
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, this);
|
||||
});
|
||||
@@ -224,9 +222,7 @@ namespace AZ
|
||||
m_rotationWidget->setValuebyIndex(m_transform.GetRotation().GetY(), 1);
|
||||
m_rotationWidget->setValuebyIndex(m_transform.GetRotation().GetZ(), 2);
|
||||
|
||||
m_scaleWidget->setValuebyIndex(m_transform.GetScale().GetX(), 0);
|
||||
m_scaleWidget->setValuebyIndex(m_transform.GetScale().GetY(), 1);
|
||||
m_scaleWidget->setValuebyIndex(m_transform.GetScale().GetZ(), 2);
|
||||
m_scaleWidget->setValue(m_transform.GetScale());
|
||||
|
||||
blockSignals(false);
|
||||
}
|
||||
@@ -251,7 +247,7 @@ namespace AZ
|
||||
return m_rotationWidget;
|
||||
}
|
||||
|
||||
AzQtComponents::VectorInput* TransformRowWidget::GetScaleWidget()
|
||||
AzToolsFramework::PropertyDoubleSpinCtrl* TransformRowWidget::GetScaleWidget()
|
||||
{
|
||||
return m_scaleWidget;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <SceneAPI/SceneUI/SceneUIConfiguration.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace AzQtComponents
|
||||
@@ -28,6 +29,11 @@ namespace AzQtComponents
|
||||
class VectorInput;
|
||||
}
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class PropertyDoubleSpinCtrl;
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace SceneAPI
|
||||
@@ -51,14 +57,14 @@ namespace AZ
|
||||
const AZ::Vector3& GetRotation() const;
|
||||
void SetRotation(const AZ::Vector3& translation);
|
||||
|
||||
const AZ::Vector3& GetScale() const;
|
||||
void SetScale(const AZ::Vector3& scale);
|
||||
const float GetScale() const;
|
||||
void SetScale(const float scale);
|
||||
|
||||
private:
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ::Vector3 m_translation;
|
||||
AZ::Vector3 m_rotation;
|
||||
AZ::Vector3 m_scale;
|
||||
float m_scale;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
@@ -78,7 +84,7 @@ namespace AZ
|
||||
|
||||
AzQtComponents::VectorInput* GetTranslationWidget();
|
||||
AzQtComponents::VectorInput* GetRotationWidget();
|
||||
AzQtComponents::VectorInput* GetScaleWidget();
|
||||
AzToolsFramework::PropertyDoubleSpinCtrl* GetScaleWidget();
|
||||
|
||||
protected:
|
||||
ExpandedTransform m_transform;
|
||||
@@ -87,7 +93,7 @@ namespace AZ
|
||||
|
||||
AzQtComponents::VectorInput* m_translationWidget;
|
||||
AzQtComponents::VectorInput* m_rotationWidget;
|
||||
AzQtComponents::VectorInput* m_scaleWidget;
|
||||
AzToolsFramework::PropertyDoubleSpinCtrl* m_scaleWidget;
|
||||
};
|
||||
} // namespace SceneUI
|
||||
} // namespace SceneAPI
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace AZ
|
||||
|
||||
Vector3 m_translation = Vector3(10.0f, 20.0f, 30.0f);
|
||||
Vector3 m_rotation = Vector3(30.0f, 45.0f, 60.0f);
|
||||
Vector3 m_scale = Vector3(2.0f, 3.0f, 4.0f);
|
||||
float m_scale = 3.0f;
|
||||
};
|
||||
|
||||
TEST_F(TransformRowWidgetTest, GetTranslation_TranslationInMatrix_TranslationCanBeRetrievedDirectly)
|
||||
@@ -83,26 +83,22 @@ namespace AZ
|
||||
|
||||
TEST_F(TransformRowWidgetTest, GetScale_ScaleInMatrix_ScaleCanBeRetrievedDirectly)
|
||||
{
|
||||
m_transform = Transform::CreateScale(m_scale);
|
||||
m_transform = Transform::CreateUniformScale(m_scale);
|
||||
m_expanded.SetTransform(m_transform);
|
||||
|
||||
const Vector3& returned = m_expanded.GetScale();
|
||||
EXPECT_NEAR(m_scale.GetX(), returned.GetX(), 0.1f);
|
||||
EXPECT_NEAR(m_scale.GetY(), returned.GetY(), 0.1f);
|
||||
EXPECT_NEAR(m_scale.GetZ(), returned.GetZ(), 0.1f);
|
||||
const float returned = m_expanded.GetScale();
|
||||
EXPECT_NEAR(m_scale, returned, 0.1f);
|
||||
}
|
||||
|
||||
TEST_F(TransformRowWidgetTest, GetScale_ScaleInMatrix_ScaleCanBeRetrievedFromTransform)
|
||||
{
|
||||
m_transform = Transform::CreateScale(m_scale);
|
||||
m_transform = Transform::CreateUniformScale(m_scale);
|
||||
m_expanded.SetTransform(m_transform);
|
||||
|
||||
Transform rebuild;
|
||||
m_expanded.GetTransform(rebuild);
|
||||
Vector3 returned = rebuild.GetScale();
|
||||
EXPECT_NEAR(m_scale.GetX(), returned.GetX(), 0.1f);
|
||||
EXPECT_NEAR(m_scale.GetY(), returned.GetY(), 0.1f);
|
||||
EXPECT_NEAR(m_scale.GetZ(), returned.GetZ(), 0.1f);
|
||||
float returned = rebuild.GetUniformScale();
|
||||
EXPECT_NEAR(m_scale, returned, 0.1f);
|
||||
}
|
||||
|
||||
TEST_F(TransformRowWidgetTest, GetTransform_RotateAndTranslateInMatrix_ReconstructedTransformMatchesOriginal)
|
||||
@@ -121,7 +117,7 @@ namespace AZ
|
||||
{
|
||||
Quaternion quaternion = AZ::ConvertEulerDegreesToQuaternion(m_rotation);
|
||||
m_transform = Transform::CreateFromQuaternionAndTranslation(quaternion, m_translation);
|
||||
m_transform.MultiplyByScale(m_scale);
|
||||
m_transform.MultiplyByUniformScale(m_scale);
|
||||
m_expanded.SetTransform(m_transform);
|
||||
|
||||
Transform rebuild;
|
||||
|
||||
+2
-2
@@ -209,8 +209,8 @@ namespace AZ
|
||||
AZ::Vector3 position = AZ::Vector3::CreateZero();
|
||||
AZ::TransformBus::EventResult(position, GetEntityId(), &AZ::TransformBus::Events::GetWorldTranslation);
|
||||
|
||||
AZ::Vector3 scale = AZ::Vector3::CreateOne();
|
||||
AZ::TransformBus::EventResult(scale, GetEntityId(), &AZ::TransformBus::Events::GetLocalScale);
|
||||
float scale = 1.0f;
|
||||
AZ::TransformBus::EventResult(scale, GetEntityId(), &AZ::TransformBus::Events::GetLocalUniformScale);
|
||||
|
||||
// draw AABB at probe position using the inner dimensions
|
||||
Color color(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace Blast
|
||||
m_damageManager = AZStd::make_unique<DamageManager>(blastMaterial, m_family->GetActorTracker());
|
||||
m_actorRenderManager = AZStd::make_unique<ActorRenderManager>(
|
||||
AZ::RPI::Scene::GetFeatureProcessorForEntity<AZ::Render::MeshFeatureProcessorInterface>(GetEntityId()),
|
||||
m_meshDataComponent, GetEntityId(), m_blastAsset->GetPxAsset()->getChunkCount(), transform.GetScale());
|
||||
m_meshDataComponent, GetEntityId(), m_blastAsset->GetPxAsset()->getChunkCount(), AZ::Vector3(transform.GetUniformScale()));
|
||||
|
||||
// Spawn the family
|
||||
m_family->Spawn(transform);
|
||||
|
||||
@@ -654,9 +654,7 @@ namespace Blast
|
||||
MOCK_METHOD1(RotateAroundLocalZ, void(float));
|
||||
MOCK_METHOD0(GetLocalRotation, AZ::Vector3());
|
||||
MOCK_METHOD0(GetLocalRotationQuaternion, AZ::Quaternion());
|
||||
MOCK_METHOD1(SetLocalScale, void(const AZ::Vector3&));
|
||||
MOCK_METHOD0(GetLocalScale, AZ::Vector3());
|
||||
MOCK_METHOD0(GetWorldScale, AZ::Vector3());
|
||||
MOCK_METHOD1(SetLocalUniformScale, void(float));
|
||||
MOCK_METHOD0(GetLocalUniformScale, float());
|
||||
MOCK_METHOD0(GetWorldUniformScale, float());
|
||||
|
||||
@@ -103,12 +103,12 @@ namespace GradientSignal
|
||||
//apply transform if set
|
||||
if (m_enableTransform && GradientSamplerUtil::AreTransformParamsSet(*this))
|
||||
{
|
||||
const AZ::Transform transform =
|
||||
AZ::Transform::CreateTranslation(m_translate) *
|
||||
AZ::ConvertEulerDegreesToTransform(m_rotate) *
|
||||
AZ::Transform::CreateScale(m_scale);
|
||||
AZ::Matrix3x4 matrix3x4;
|
||||
matrix3x4.SetFromEulerDegrees(m_rotate);
|
||||
matrix3x4.MultiplyByScale(m_scale);
|
||||
matrix3x4.SetTranslation(m_translate);
|
||||
|
||||
sampleParamsTransformed.m_position = transform.TransformPoint(sampleParamsTransformed.m_position);
|
||||
sampleParamsTransformed.m_position = matrix3x4 * sampleParamsTransformed.m_position;
|
||||
}
|
||||
|
||||
float output = 0.0f;
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace GradientSignal
|
||||
|
||||
if (!m_configuration.m_advancedMode || !m_configuration.m_overrideScale)
|
||||
{
|
||||
m_configuration.m_scale = shapeTransform.GetScale();
|
||||
m_configuration.m_scale = AZ::Vector3(shapeTransform.GetUniformScale());
|
||||
}
|
||||
|
||||
//rebuild bounds from parameters
|
||||
|
||||
@@ -205,8 +205,8 @@ namespace LmbrCentral
|
||||
{
|
||||
m_position = currentTransform.GetTranslation();
|
||||
m_quaternion = currentTransform.GetRotation();
|
||||
m_scaledWidth = configuration.m_width * currentTransform.GetScale().GetX() * currentNonUniformScale.GetX();
|
||||
m_scaledHeight = configuration.m_height * currentTransform.GetScale().GetY() * currentNonUniformScale.GetY();
|
||||
m_scaledWidth = configuration.m_width * currentTransform.GetUniformScale() * currentNonUniformScale.GetX();
|
||||
m_scaledHeight = configuration.m_height * currentTransform.GetUniformScale() * currentNonUniformScale.GetY();
|
||||
}
|
||||
|
||||
const QuadShapeConfig& QuadShape::GetQuadConfiguration() const
|
||||
|
||||
@@ -324,11 +324,11 @@ void CAnimComponentNode::ConvertBetweenWorldAndLocalRotation(Quat& rotation, ETr
|
||||
{
|
||||
AZ::Quaternion rot(rotation.v.x, rotation.v.y, rotation.v.z, rotation.w);
|
||||
AZ::Transform rotTransform = AZ::Transform::CreateFromQuaternion(rot);
|
||||
rotTransform.ExtractScale();
|
||||
rotTransform.ExtractUniformScale();
|
||||
|
||||
AZ::Transform parentTransform = AZ::Transform::Identity();
|
||||
GetParentWorldTransform(parentTransform);
|
||||
parentTransform.ExtractScale();
|
||||
parentTransform.ExtractUniformScale();
|
||||
if (conversionDirection == eTransformConverstionDirection_toLocalSpace)
|
||||
{
|
||||
parentTransform.Invert();
|
||||
@@ -344,7 +344,7 @@ void CAnimComponentNode::ConvertBetweenWorldAndLocalRotation(Quat& rotation, ETr
|
||||
void CAnimComponentNode::ConvertBetweenWorldAndLocalScale(Vec3& scale, ETransformSpaceConversionDirection conversionDirection) const
|
||||
{
|
||||
AZ::Transform parentTransform = AZ::Transform::Identity();
|
||||
AZ::Transform scaleTransform = AZ::Transform::CreateScale(AZ::Vector3(scale.x, scale.y, scale.z));
|
||||
AZ::Transform scaleTransform = AZ::Transform::CreateUniformScale(AZ::Vector3(scale.x, scale.y, scale.z).GetMaxElement());
|
||||
|
||||
GetParentWorldTransform(parentTransform);
|
||||
if (conversionDirection == eTransformConverstionDirection_toLocalSpace)
|
||||
@@ -353,8 +353,8 @@ void CAnimComponentNode::ConvertBetweenWorldAndLocalScale(Vec3& scale, ETransfor
|
||||
}
|
||||
scaleTransform = parentTransform * scaleTransform;
|
||||
|
||||
AZ::Vector3 vScale = scaleTransform.GetScale();
|
||||
scale.Set(vScale.GetX(), vScale.GetY(), vScale.GetZ());
|
||||
const float uniformScale = scaleTransform.GetUniformScale();
|
||||
scale.Set(uniformScale, uniformScale, uniformScale);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -280,6 +280,45 @@ static bool AnimNodeVersionConverter(
|
||||
rootElement.AddElement(serializeContext, "BaseClass1", azrtti_typeid<IAnimNode>());
|
||||
}
|
||||
|
||||
if (rootElement.GetVersion() < 4)
|
||||
{
|
||||
// remove vector scale tracks from transform anim nodes
|
||||
AZStd::string name;
|
||||
if (rootElement.FindSubElementAndGetData<AZStd::string>(AZ_CRC_CE("Name"), name) && name == "Transform")
|
||||
{
|
||||
auto tracksElement = rootElement.FindSubElement(AZ_CRC_CE("Tracks"));
|
||||
if (tracksElement)
|
||||
{
|
||||
for (int trackIndex = tracksElement->GetNumSubElements() - 1; trackIndex >= 0; trackIndex--)
|
||||
{
|
||||
auto trackElement = tracksElement->GetSubElement(trackIndex);
|
||||
bool isScale = false;
|
||||
|
||||
// trackElement should be an intrusive_ptr with one child
|
||||
if (trackElement.GetNumSubElements() == 1)
|
||||
{
|
||||
auto ptrElement = trackElement.GetSubElement(0);
|
||||
auto paramTypeElement = ptrElement.FindSubElement(AZ_CRC_CE("ParamType"));
|
||||
if (paramTypeElement)
|
||||
{
|
||||
AZStd::string paramName;
|
||||
if (paramTypeElement->FindSubElementAndGetData<AZStd::string>(AZ_CRC_CE("Name"), paramName) && paramName == "Scale")
|
||||
{
|
||||
isScale = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isScale)
|
||||
{
|
||||
tracksElement->RemoveElement(trackIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -288,7 +327,7 @@ void CAnimNode::Reflect(AZ::ReflectContext* context)
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<CAnimNode, IAnimNode>()
|
||||
->Version(3, &AnimNodeVersionConverter)
|
||||
->Version(4, &AnimNodeVersionConverter)
|
||||
->Field("ID", &CAnimNode::m_id)
|
||||
->Field("Name", &CAnimNode::m_name)
|
||||
->Field("Flags", &CAnimNode::m_flags)
|
||||
|
||||
@@ -878,9 +878,9 @@ namespace PhysX
|
||||
|
||||
AZ::Vector3 GetTransformScale(AZ::EntityId entityId)
|
||||
{
|
||||
AZ::Vector3 worldScale = AZ::Vector3::CreateOne();
|
||||
AZ::TransformBus::EventResult(worldScale, entityId, &AZ::TransformBus::Events::GetWorldScale);
|
||||
return worldScale;
|
||||
float worldUniformScale = 1.0f;
|
||||
AZ::TransformBus::EventResult(worldUniformScale, entityId, &AZ::TransformBus::Events::GetWorldUniformScale);
|
||||
return AZ::Vector3(worldUniformScale);
|
||||
}
|
||||
|
||||
AZ::Vector3 GetUniformScale(AZ::EntityId entityId)
|
||||
|
||||
@@ -2527,15 +2527,15 @@ namespace ScriptCanvas
|
||||
{
|
||||
Data::TransformType copy(source);
|
||||
AZ::Vector3 pos = copy.GetTranslation();
|
||||
AZ::Vector3 scale = copy.ExtractScale();
|
||||
float scale = copy.ExtractUniformScale();
|
||||
AZ::Vector3 rotation = AZ::ConvertTransformToEulerDegrees(copy);
|
||||
return AZStd::string::format
|
||||
( "(Position: X: %f, Y: %f, Z: %f,"
|
||||
" Rotation: X: %f, Y: %f, Z: %f,"
|
||||
" Scale: X: %f, Y: %f, Z: %f)"
|
||||
" Scale: %f)"
|
||||
, static_cast<float>(pos.GetX()), static_cast<float>(pos.GetY()), static_cast<float>(pos.GetZ())
|
||||
, static_cast<float>(rotation.GetX()), static_cast<float>(rotation.GetY()), static_cast<float>(rotation.GetZ())
|
||||
, static_cast<float>(scale.GetX()), static_cast<float>(scale.GetY()), static_cast<float>(scale.GetZ()));
|
||||
, scale);
|
||||
}
|
||||
|
||||
AZStd::string Datum::ToStringVector2(const AZ::Vector2& source) const
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace ScriptCanvas
|
||||
using namespace MathNodeUtilities;
|
||||
static const char* k_categoryName = "Math/Transform";
|
||||
|
||||
AZ_INLINE std::tuple<Vector3Type, TransformType> ExtractScale(TransformType source)
|
||||
AZ_INLINE std::tuple<NumberType, TransformType> ExtractUniformScale(TransformType source)
|
||||
{
|
||||
auto scale(source.ExtractScale());
|
||||
auto scale(source.ExtractUniformScale());
|
||||
return std::make_tuple( scale, source );
|
||||
}
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_MULTI_RESULTS_NODE(ExtractScale, k_categoryName, "{8DFE5247-0950-4CD1-87E6-0CAAD42F1637}", "returns a vector which is the length of the scale components, and a transform with the scale extracted ", "Source", "Scale", "Extracted");
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_MULTI_RESULTS_NODE(ExtractUniformScale, k_categoryName, "{8DFE5247-0950-4CD1-87E6-0CAAD42F1637}", "returns the uniform scale as a float, and a transform with the scale extracted ", "Source", "Uniform Scale", "Extracted");
|
||||
|
||||
AZ_INLINE TransformType FromMatrix3x3(Matrix3x3Type source)
|
||||
{
|
||||
@@ -57,11 +57,11 @@ namespace ScriptCanvas
|
||||
}
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(FromRotationAndTranslation, k_categoryName, "{99A4D55D-6EFB-4E24-8113-F5B46DE3A194}", "returns a transform from the rotation and the translation", "Rotation", "Translation");
|
||||
|
||||
AZ_INLINE TransformType FromScale(Vector3Type scale)
|
||||
AZ_INLINE TransformType FromScale(NumberType scale)
|
||||
{
|
||||
return TransformType::CreateScale(scale);
|
||||
return TransformType::CreateUniformScale(scale);
|
||||
}
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(FromScale, k_categoryName, "{4B6454BC-015C-41BB-9C78-34ADBCF70187}", "returns a scale matrix and the translation set to zero", "Scale");
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(FromScale, k_categoryName, "{4B6454BC-015C-41BB-9C78-34ADBCF70187}", "returns a transform which applies the specified uniform Scale, but no rotation or translation", "Scale");
|
||||
|
||||
AZ_INLINE TransformType FromTranslation(Vector3Type translation)
|
||||
{
|
||||
@@ -145,12 +145,12 @@ namespace ScriptCanvas
|
||||
}
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(Multiply3x3ByVector3, k_categoryName, "{4F2ABFC6-2E93-4A9D-8639-C7967DB318DB}", "returns Source's 3x3 upper matrix post multiplied by Multiplier", "Source", "Multiplier");
|
||||
|
||||
AZ_INLINE TransformType MultiplyByScale(TransformType source, Vector3Type scale)
|
||||
AZ_INLINE TransformType MultiplyByUniformScale(TransformType source, NumberType scale)
|
||||
{
|
||||
source.MultiplyByScale(scale);
|
||||
source.MultiplyByUniformScale(scale);
|
||||
return source;
|
||||
}
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(MultiplyByScale, k_categoryName, "{90472D62-65A8-40C1-AB08-FA66D793F689}", "returns Source multiplied by the scale matrix produced by Scale", "Source", "Scale");
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(MultiplyByUniformScale, k_categoryName, "{90472D62-65A8-40C1-AB08-FA66D793F689}", "returns Source multiplied uniformly by Scale", "Source", "Scale");
|
||||
|
||||
AZ_INLINE TransformType MultiplyByTransform(const TransformType& a, const TransformType& b)
|
||||
{
|
||||
@@ -194,16 +194,16 @@ namespace ScriptCanvas
|
||||
}
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(RotationZDegrees, k_categoryName, "{F848306A-C07C-4586-B52F-BEEE489045D2}", "returns a transform representing a rotation Degrees around the Z-Axis", "Degrees");
|
||||
|
||||
AZ_INLINE Vector3Type ToScale(const TransformType& source)
|
||||
AZ_INLINE NumberType ToScale(const TransformType& source)
|
||||
{
|
||||
return source.GetScale();
|
||||
return source.GetUniformScale();
|
||||
}
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(ToScale, k_categoryName, "{063C58AD-F567-464D-A432-F298FE3953A6}", "returns the scale part of the Source, the length of the scale components", "Source");
|
||||
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(ToScale, k_categoryName, "{063C58AD-F567-464D-A432-F298FE3953A6}", "returns the uniform scale of the Source", "Source");
|
||||
|
||||
using Registrar = RegistrarGeneric
|
||||
<
|
||||
#if ENABLE_EXTENDED_MATH_SUPPORT
|
||||
ExtractScaleNode ,
|
||||
ExtractUniformScaleNode ,
|
||||
#endif
|
||||
FromMatrix3x3AndTranslationNode
|
||||
, FromMatrix3x3Node
|
||||
@@ -230,7 +230,7 @@ namespace ScriptCanvas
|
||||
, Multiply3x3ByVector3Node
|
||||
#endif
|
||||
|
||||
, MultiplyByScaleNode
|
||||
, MultiplyByUniformScaleNode
|
||||
, MultiplyByTransformNode
|
||||
, MultiplyByVector3Node
|
||||
, MultiplyByVector4Node
|
||||
|
||||
Reference in New Issue
Block a user