Merge branch 'main' into jckand/FoundationAuto

main
jckand-amzn 5 years ago
commit 0fb65fd961

@ -287,71 +287,28 @@ namespace AZ
//! Scale modifiers
//! @{
//! @deprecated Use SetLocalScale()
//! Scales the entity along the world's axes. The origin of the axes is the entity's position in the world.
//! @param scale A three-dimensional vector that represents the multipliers with which to scale the entity in world space.
virtual void SetScale([[maybe_unused]] const AZ::Vector3& scale) {}
//! @deprecated Use SetLocalScaleX()
//! Scales the entity along the world's X axis. The origin of the axis is the entity's position in the world.
//! @param scaleX The multiplier by which to scale the entity along the X axis in world space.
virtual void SetScaleX([[maybe_unused]] float scaleX) {}
//! @deprecated Use SetLocalScaleY()
//! Scales the entity along the world's Y axis. The origin of the axis is the entity's position in the world.
//! @param scaleY The multiplier by which to scale the entity along the Y axis in world space.
virtual void SetScaleY([[maybe_unused]] float scaleY) {}
//! @deprecated Use SetLocalScaleZ()
//! Scales the entity along the world's Z axis. The origin of the axis is the entity's position in the world.
//! @param scaleZ The multiplier by which to scale the entity along the Z axis in world space.
virtual void SetScaleZ([[maybe_unused]] float scaleZ) {}
//! @deprecated Use GetLocalScale()
//! Gets the scale of the entity in world space.
//! @return A three-dimensional vector that represents the scale of the entity in world space.
virtual AZ::Vector3 GetScale() { return AZ::Vector3(FLT_MAX); }
//! @deprecated Use GetLocalScale()
//! Gets the amount by which an entity is scaled along the world's X axis.
//! @return The amount by which an entity is scaled along the X axis in world space.
virtual float GetScaleX() { return FLT_MAX; }
//! @deprecated Use GetLocalScale()
//! Gets the amount by which an entity is scaled along the world's Y axis.
//! @return The amount by which an entity is scaled along the Y axis in world space.
virtual float GetScaleY() { return FLT_MAX; }
//! @deprecated Use GetLocalScale()
//! Gets the amount by which an entity is scaled along the world's Z axis.
//! @return The amount by which an entity is scaled along the Z axis in world space.
virtual float GetScaleZ() { return FLT_MAX; }
//! Set local scale of the transform.
//! @param scale The new scale to set along three local axes.
//! @param scale The new scale to set.
virtual void SetLocalScale([[maybe_unused]] const AZ::Vector3& scale) {}
//! Set local scale of the transform on x-axis.
//! @param scaleX The new x-axis scale to set.
virtual void SetLocalScaleX([[maybe_unused]] float scaleX) {}
//! Get the scale value in local space.
//! @return The scale value in local space.
virtual AZ::Vector3 GetLocalScale() { return AZ::Vector3(FLT_MAX); }
//! Set local scale of the transform on y-axis.
//! @param scaleY The new y-axis scale to set.
virtual void SetLocalScaleY([[maybe_unused]] float scaleY) {}
//! Get the scale value in world space.
//! @return The scale value in world space.
virtual AZ::Vector3 GetWorldScale() { return AZ::Vector3(FLT_MAX); }
//! Set local scale of the transform on z-axis.
//! @param scaleZ The new z-axis scale to set.
virtual void SetLocalScaleZ([[maybe_unused]] float scaleZ) {}
//! Set the uniform scale value in local space.
virtual void SetLocalUniformScale([[maybe_unused]] float scale) {}
//! Get the scale value on each axis in local space
//! @return The scale value of type Vector3 along each axis in local space.
virtual AZ::Vector3 GetLocalScale() { return AZ::Vector3(FLT_MAX); }
//! Get the uniform scale value in local space.
//! @return The uniform scale value in local space.
virtual float GetLocalUniformScale() { return FLT_MAX; }
//! Get the scale value on each axis in world space.
//! Note the transform will be skewed when it is rotated and has a parent transform scaled, in which
//! case the returned world-scale from this function will be inaccurate.
//! @return The scale value of type Vector3 along each axis in world space.
virtual AZ::Vector3 GetWorldScale() { return AZ::Vector3(FLT_MAX); }
//! Get the uniform scale value in world space.
//! @return The uniform scale value in world space.
virtual float GetWorldUniformScale() { return FLT_MAX; }
//! @}
//! Transform hierarchy

@ -348,13 +348,20 @@ namespace AZ
return result.GetW() >= 0.0f ? result : -result;
}
const Quaternion Quaternion::CreateFromEulerAnglesDegrees(Vector3& anglesInDegrees)
const Quaternion Quaternion::CreateFromEulerAnglesDegrees(const Vector3& anglesInDegrees)
{
Quaternion result;
result.SetFromEulerDegrees(anglesInDegrees);
return result;
}
const Quaternion Quaternion::CreateFromEulerAnglesRadians(const Vector3& anglesInRadians)
{
Quaternion result;
result.SetFromEulerRadians(anglesInRadians);
return result;
}
Quaternion Quaternion::Slerp(const Quaternion& dest, float t) const
{
const float DestDot = Dot(dest);

@ -83,8 +83,11 @@ namespace AZ
static Quaternion CreateShortestArc(const Vector3& v1, const Vector3& v2);
/// Creates a quaternion using rotation in degrees about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis.
static const Quaternion CreateFromEulerAnglesDegrees(Vector3& anglesInDegrees);
//! Creates a quaternion using rotation in degrees about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis.
static const Quaternion CreateFromEulerAnglesDegrees(const Vector3& anglesInDegrees);
//! Creates a quaternion using rotation in radians about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis.
static const Quaternion CreateFromEulerAnglesRadians(const Vector3& anglesInRadians);
//! Stores the vector to an array of 4 floats. The floats need only be 4 byte aligned, 16 byte alignment is not required.
void StoreToFloat4(float* values) const;

@ -441,10 +441,10 @@ namespace AZ
const Transform& worldFromLocal, const Vector3& src, const Vector3& dir, const Spline& spline)
{
Transform worldFromLocalNormalized = worldFromLocal;
const Vector3 scale = worldFromLocalNormalized.ExtractScale();
const float scale = worldFromLocalNormalized.ExtractUniformScale();
const Transform localFromWorldNormalized = worldFromLocalNormalized.GetInverse();
const Vector3 localRayOrigin = localFromWorldNormalized.TransformPoint(src) * scale.GetReciprocal();
const Vector3 localRayOrigin = localFromWorldNormalized.TransformPoint(src) / scale;
const Vector3 localRayDirection = localFromWorldNormalized.TransformVector(dir);
return spline.GetNearestAddressRay(localRayOrigin, localRayDirection);
}

@ -284,10 +284,15 @@ namespace AZ
Method("GetRotation", &Transform::GetRotation)->
Method<void (Transform::*)(const Quaternion&)>("SetRotation", &Transform::SetRotation)->
Method("GetScale", &Transform::GetScale)->
Method<void (Transform::*)(const Vector3&)>("SetScale", &Transform::SetScale)->
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)->
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
@ -306,6 +311,7 @@ namespace AZ
Method("CreateFromMatrix3x3", &Transform::CreateFromMatrix3x3)->
Method("CreateFromMatrix3x3AndTranslation", &Transform::CreateFromMatrix3x3AndTranslation)->
Method("CreateScale", &Transform::CreateScale)->
Method("CreateUniformScale", &Transform::CreateUniformScale)->
Method("CreateTranslation", &Transform::CreateTranslation)->
Method("ConstructFromValuesNumeric", &Internal::ConstructTransformFromValues);
}

@ -89,8 +89,11 @@ namespace AZ
static Transform CreateFromMatrix3x4(const Matrix3x4& value);
//! Sets the matrix to be a scale matrix, translation is set to zero.
static Transform CreateScale(const Vector3& scale);
//! 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);
//! Sets the matrix to be a translation matrix, rotation part is set to identity.
static Transform CreateTranslation(const Vector3& translation);
@ -119,13 +122,19 @@ namespace AZ
const Quaternion& GetRotation() const;
void SetRotation(const Quaternion& rotation);
const Vector3& GetScale() const;
Vector3 GetScale() const;
float GetUniformScale() const;
void SetScale(const Vector3& v);
void SetUniformScale(const float scale);
//! Sets the transforms scale to a unit value and returns the previous scale value.
//! Sets the transform's scale to a unit value and returns the previous scale value.
Vector3 ExtractScale();
void MultiplyByScale(const Vector3& scale);
//! 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;
Transform& operator*=(const Transform& rhs);

@ -65,6 +65,7 @@ namespace AZ
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;
@ -72,6 +73,15 @@ namespace AZ
return result;
}
AZ_MATH_INLINE Transform Transform::CreateUniformScale(float scale)
{
Transform result;
result.m_rotation = Quaternion::CreateIdentity();
result.m_scale = Vector3(scale);
result.m_translation = Vector3::CreateZero();
return result;
}
AZ_MATH_INLINE Transform Transform::CreateTranslation(const Vector3& translation)
{
Transform result;
@ -150,24 +160,50 @@ namespace AZ
m_rotation = rotation;
}
AZ_MATH_INLINE const Vector3& Transform::GetScale() const
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;
}
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;
}
AZ_MATH_INLINE float Transform::ExtractUniformScale()
{
const float scale = m_scale.GetMaxElement();
m_scale = Vector3::CreateOne();
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;
}
@ -233,7 +269,7 @@ namespace AZ
AZ_MATH_INLINE void Transform::Orthogonalize()
{
*this = GetOrthogonalized();
m_scale = Vector3::CreateOne();
}
AZ_MATH_INLINE bool Transform::IsClose(const Transform& rhs, float tolerance) const

@ -60,7 +60,7 @@ namespace AZ
{
// Scale is transitioning to a single uniform scale value, but since it's still internally represented as a Vector3,
// we need to pick one number to use for load/store operations.
float scale = transformInstance->GetScale().GetMaxElement();
float scale = transformInstance->GetUniformScale();
JSR::ResultCode loadResult =
ContinueLoadingFromJsonObjectField(&scale, azrtti_typeid<decltype(scale)>(), inputValue, ScaleTag, context);
@ -124,8 +124,8 @@ namespace AZ
// Scale is transitioning to a single uniform scale value, but since it's still internally represented as a Vector3,
// we need to pick one number to use for load/store operations.
float scale = transformInstance->GetScale().GetMaxElement();
float defaultScale = defaultTransformInstance ? defaultTransformInstance->GetScale().GetMaxElement() : 0.0f;
float scale = transformInstance->GetUniformScale();
float defaultScale = defaultTransformInstance ? defaultTransformInstance->GetUniformScale() : 0.0f;
JSR::ResultCode storeResult = ContinueStoringToJsonObjectField(
outputValue, ScaleTag, &scale, defaultTransformInstance ? &defaultScale : nullptr, azrtti_typeid<decltype(scale)>(),

@ -31,6 +31,8 @@ namespace UnitTest
ErrorHandler::ErrorHandler(const char* errorPattern)
: m_errorCount(0)
, m_warningCount(0)
, m_expectedErrorCount(0)
, m_expectedWarningCount(0)
, m_errorPattern(errorPattern)
{
AZ::Debug::TraceMessageBus::Handler::BusConnect();
@ -51,6 +53,16 @@ namespace UnitTest
return m_warningCount;
}
int ErrorHandler::GetExpectedErrorCount() const
{
return m_expectedErrorCount;
}
int ErrorHandler::GetExpectedWarningCount() const
{
return m_expectedWarningCount;
}
bool ErrorHandler::SuppressExpectedErrors([[maybe_unused]] const char* window, const char* message)
{
return AZStd::string(message).find(m_errorPattern) != AZStd::string::npos;
@ -61,7 +73,9 @@ namespace UnitTest
[[maybe_unused]] const char* func, const char* message)
{
m_errorCount++;
return SuppressExpectedErrors(window, message);
bool suppress = SuppressExpectedErrors(window, message);
m_expectedErrorCount += suppress;
return suppress;
}
bool ErrorHandler::OnPreWarning(
@ -69,7 +83,9 @@ namespace UnitTest
[[maybe_unused]] const char* func, const char* message)
{
m_warningCount++;
return SuppressExpectedErrors(window, message);
bool suppress = SuppressExpectedErrors(window, message);
m_expectedWarningCount += suppress;
return suppress;
}
bool ErrorHandler::OnPrintf(const char* window, const char* message)

@ -30,8 +30,14 @@ namespace UnitTest
public:
explicit ErrorHandler(const char* errorPattern);
~ErrorHandler();
//! Returns the total number of errors encountered (including those which match the expected pattern).
int GetErrorCount() const;
//! Returns the total number of warnings encountered (including those which match the expected pattern).
int GetWarningCount() const;
//! Returns the number of errors encountered which matched the expected pattern.
int GetExpectedErrorCount() const;
//! Returns the number of warnings encountered which matched the expected pattern.
int GetExpectedWarningCount() const;
bool SuppressExpectedErrors(const char* window, const char* message);
// AZ::Debug::TraceMessageBus
@ -44,6 +50,8 @@ namespace UnitTest
AZStd::string m_errorPattern;
int m_errorCount;
int m_warningCount;
int m_expectedErrorCount;
int m_expectedWarningCount;
};
}

@ -61,8 +61,8 @@ namespace MathTestData
};
static const AZ::Transform NonOrthogonalTransforms[] = {
AZ::Transform::CreateScale(AZ::Vector3(2.4f, 0.3f, 1.7f)),
AZ::Transform::CreateRotationX(2.2f) * AZ::Transform::CreateScale(AZ::Vector3(0.2f, 0.8f, 1.4f))
AZ::Transform::CreateUniformScale(2.4f),
AZ::Transform::CreateRotationX(2.2f) * AZ::Transform::CreateUniformScale(0.8f)
};
static const AZ::Transform OrthogonalTransforms[] = {

@ -59,11 +59,11 @@ namespace UnitTest
TEST(MATH_Obb, TestScaleTransform)
{
Obb obb = Obb::CreateFromPositionRotationAndHalfLengths(position, rotation, halfLengths);
Vector3 scaleFactors = Vector3(1.0f, 2.0f, 3.0f);
Transform transform = Transform::CreateScale(scaleFactors);
float scale = 3.0f;
Transform transform = Transform::CreateUniformScale(scale);
obb = transform * obb;
EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(1.0f, 4.0f, 9.0f)));
EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(0.5f, 1.0f, 1.5f)));
EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(3.0f, 6.0f, 9.0f)));
EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(1.5f, 1.5f, 1.5f)));
}
TEST(MATH_Obb, TestSetPosition)

@ -180,13 +180,13 @@ namespace Benchmark
}
}
BENCHMARK_F(BM_MathTransform, CreateScale)(benchmark::State& state)
BENCHMARK_F(BM_MathTransform, CreateUniformScale)(benchmark::State& state)
{
for (auto _ : state)
{
for (auto& testData : m_testDataArray)
{
AZ::Transform result = AZ::Transform::CreateScale(testData.v3);
AZ::Transform result = AZ::Transform::CreateUniformScale(testData.value[0]);
benchmark::DoNotOptimize(result);
}
}
@ -344,39 +344,39 @@ namespace Benchmark
}
}
BENCHMARK_F(BM_MathTransform, GetScale)(benchmark::State& state)
BENCHMARK_F(BM_MathTransform, GetUniformScale)(benchmark::State& state)
{
for (auto _ : state)
{
for (auto& testData : m_testDataArray)
{
AZ::Vector3 result = testData.t1.GetScale();
float result = testData.t1.GetUniformScale();
benchmark::DoNotOptimize(result);
}
}
}
BENCHMARK_F(BM_MathTransform, SetScale)(benchmark::State& state)
BENCHMARK_F(BM_MathTransform, SetUniformScale)(benchmark::State& state)
{
for (auto _ : state)
{
for (auto& testData : m_testDataArray)
{
AZ::Transform testTransform = testData.t2;
testTransform.SetScale(testData.v3);
testTransform.SetUniformScale(testData.value[0]);
benchmark::DoNotOptimize(testTransform);
}
}
}
BENCHMARK_F(BM_MathTransform, ExtractScale)(benchmark::State& state)
BENCHMARK_F(BM_MathTransform, ExtractUniformScale)(benchmark::State& state)
{
for (auto _ : state)
{
for (auto& testData : m_testDataArray)
{
AZ::Transform testTransform = testData.t2;
AZ::Vector3 result = testTransform.ExtractScale();
float result = testTransform.ExtractUniformScale();
benchmark::DoNotOptimize(result);
}
}

@ -159,37 +159,14 @@ namespace UnitTest
INSTANTIATE_TEST_CASE_P(MATH_Transform, TransformCreateFromQuaternionFixture, ::testing::ValuesIn(MathTestData::UnitQuaternions));
using TransformCreateFromMatrix3x3Fixture = ::testing::TestWithParam<AZ::Matrix3x3>;
TEST_P(TransformCreateFromMatrix3x3Fixture, CreateFromMatrix3x3)
{
const AZ::Matrix3x3 matrix3x3 = GetParam();
const AZ::Transform transform = AZ::Transform::CreateFromMatrix3x3(matrix3x3);
EXPECT_THAT(transform.GetTranslation(), IsClose(AZ::Vector3::CreateZero()));
const AZ::Vector3 vector(2.3f, -0.6, 1.8f);
EXPECT_THAT(transform.TransformPoint(vector), IsClose(matrix3x3 * vector));
}
TEST_P(TransformCreateFromMatrix3x3Fixture, CreateFromMatrix3x3AndTranslation)
{
const AZ::Matrix3x3 matrix3x3 = GetParam();
const AZ::Vector3 translation(-2.6f, 1.7f, 0.8f);
const AZ::Transform transform = AZ::Transform::CreateFromMatrix3x3AndTranslation(matrix3x3, translation);
EXPECT_THAT(transform.GetTranslation(), IsClose(translation));
const AZ::Vector3 vector(2.3f, -0.6, 1.8f);
EXPECT_THAT(transform.TransformPoint(vector), IsClose(matrix3x3 * vector + translation));
}
INSTANTIATE_TEST_CASE_P(MATH_Transform, TransformCreateFromMatrix3x3Fixture, ::testing::ValuesIn(MathTestData::Matrix3x3s));
TEST(MATH_Transform, CreateScale)
TEST(MATH_Transform, CreateUniformScale)
{
const AZ::Vector3 scale(1.7f, 0.3f, 2.4f);
const AZ::Transform transform = AZ::Transform::CreateScale(scale);
const float scale = 1.7f;
const AZ::Transform transform = AZ::Transform::CreateUniformScale(scale);
const AZ::Vector3 vector(0.2f, -1.6f, 0.4f);
EXPECT_THAT(transform.GetTranslation(), IsClose(AZ::Vector3::CreateZero()));
const AZ::Vector3 transformedVector = transform.TransformPoint(vector);
const AZ::Vector3 expected(0.34f, -0.48f, 0.96f);
const AZ::Vector3 expected(0.34f, -2.72f, 0.68f);
EXPECT_THAT(transformedVector, IsClose(expected));
}
@ -237,10 +214,10 @@ namespace UnitTest
TEST(MATH_Transform, MultiplyByTransform)
{
const AZ::Transform transform1 = AZ::Transform::CreateRotationY(0.3f);
const AZ::Transform transform2 = AZ::Transform::CreateScale(AZ::Vector3(1.3f, 1.5f, 0.4f));
const AZ::Transform transform2 = AZ::Transform::CreateUniformScale(1.3f);
const AZ::Transform transform3 = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.42f, 0.46f, -0.66f, 0.42f), AZ::Vector3(2.8f, -3.7f, 1.6f));
const AZ::Transform transform4 = AZ::Transform::CreateRotationX(-0.7f) * AZ::Transform::CreateScale(AZ::Vector3(0.6f, 1.3f, 0.7f));
const AZ::Transform transform4 = AZ::Transform::CreateRotationX(-0.7f) * AZ::Transform::CreateUniformScale(0.6f);
AZ::Transform transform5 = transform1;
transform5 *= transform4;
const AZ::Vector3 vector(1.9f, 2.3f, 0.2f);
@ -254,14 +231,14 @@ namespace UnitTest
TEST(MATH_Transform, TranslationCorrectInTransformHierarchy)
{
AZ::Transform parent = AZ::Transform::CreateRotationZ(AZ::DegToRad(45.0f));
parent.SetScale(AZ::Vector3(3.0f, 2.0f, 1.0f));
parent.SetUniformScale(3.0f);
parent.SetTranslation(AZ::Vector3(0.2f, 0.3f, 0.4f));
AZ::Transform child = AZ::Transform::CreateRotationZ(AZ::DegToRad(90.0f));
child.SetTranslation(AZ::Vector3(0.5f, 0.6f, 0.7f));
const AZ::Transform overallTransform = parent * child;
const AZ::Vector3 overallTranslation = overallTransform.GetTranslation();
const AZ::Vector3 expectedTranslation(0.412132f, 2.20919f, 1.1f);
EXPECT_THAT(overallTranslation, IsClose(AZ::Vector3(0.412132f, 2.20919f, 1.1f)));
const AZ::Vector3 expectedTranslation(-0.012132f, 2.633452f, 2.5f);
EXPECT_THAT(overallTranslation, IsClose(expectedTranslation));
}
TEST(MATH_Transform, TransformPointVector3)
@ -337,14 +314,14 @@ namespace UnitTest
TEST_P(TransformScaleFixture, Scale)
{
const AZ::Transform orthogonalTransform = GetParam();
EXPECT_THAT(orthogonalTransform.GetScale(), IsClose(AZ::Vector3::CreateOne()));
EXPECT_NEAR(orthogonalTransform.GetUniformScale(), 1.0f, AZ::Constants::Tolerance);
AZ::Transform unscaledTransform = orthogonalTransform;
unscaledTransform.ExtractScale();
EXPECT_THAT(unscaledTransform.GetScale(), IsClose(AZ::Vector3::CreateOne()));
const AZ::Vector3 scale(2.8f, 0.7f, 1.3f);
unscaledTransform.ExtractUniformScale();
EXPECT_NEAR(unscaledTransform.GetUniformScale(), 1.0f, AZ::Constants::Tolerance);
const float scale = 2.8f;
AZ::Transform scaledTransform = orthogonalTransform;
scaledTransform.MultiplyByScale(scale);
EXPECT_THAT(scaledTransform.GetScale(), IsClose(scale));
scaledTransform.MultiplyByUniformScale(scale);
EXPECT_NEAR(scaledTransform.GetUniformScale(), scale, AZ::Constants::Tolerance);
}
INSTANTIATE_TEST_CASE_P(MATH_Transform, TransformScaleFixture, ::testing::ValuesIn(MathTestData::OrthogonalTransforms));
@ -353,24 +330,11 @@ namespace UnitTest
{
EXPECT_TRUE(AZ::Transform::CreateIdentity().IsOrthogonal());
EXPECT_TRUE(AZ::Transform::CreateRotationZ(0.3f).IsOrthogonal());
EXPECT_FALSE(AZ::Transform::CreateScale(AZ::Vector3(0.8f, 0.3f, 1.2f)).IsOrthogonal());
EXPECT_FALSE(AZ::Transform::CreateUniformScale(0.8f).IsOrthogonal());
EXPECT_TRUE(AZ::Transform::CreateFromQuaternion(AZ::Quaternion(-0.52f, -0.08f, 0.56f, 0.64f)).IsOrthogonal());
AZ::Transform transform;
transform.SetFromEulerRadians(AZ::Vector3(0.2f, 0.4f, 0.1f));
EXPECT_TRUE(transform.IsOrthogonal());
// want to test each possible way the transform could fail to be orthogonal, which we can do by testing for one
// axis, then using a rotation which cycles the axes
const AZ::Transform axisCycle = AZ::Transform::CreateFromQuaternion(AZ::Quaternion(0.5f, 0.5f, 0.5f, 0.5f));
// a transform which is normalized in 2 axes, but not the third
AZ::Transform nonOrthogonalTransform1 = AZ::Transform::CreateScale(AZ::Vector3(1.0f, 1.0f, 2.0f));
for (int i = 0; i < 3; i++)
{
EXPECT_FALSE(nonOrthogonalTransform1.IsOrthogonal());
nonOrthogonalTransform1 = axisCycle * nonOrthogonalTransform1;
}
}
using TransformSetFromEulerDegreesFixture = ::testing::TestWithParam<AZ::Vector3>;
@ -459,16 +423,17 @@ namespace UnitTest
{
const char* objectStreamBuffer =
R"DELIMITER(<ObjectStream version="3">
<Class name="Transform" field="m_data" value="0.79429845 0.8545947 -0.94273965 -0.05367075 0.3899708 0.30828915 1.0097652 -0.31084164 0.56899188 513.7845459 492.5420837 32.0000000" type="{5D9958E9-9F1E-4985-B532-FFFDE75FEDFD}"/>
<Class name="Transform" field="m_data" value="0.79429845 0.8545947 -0.94273965 -0.1610121 1.1699124 0.92486745 1.2622065 -0.3885522 0.71123985 513.7845459 492.5420837 32.0000000" type="{5D9958E9-9F1E-4985-B532-FFFDE75FEDFD}"/>
</ObjectStream>)DELIMITER";
AZ::Transform* deserializedTransform = AZ::Utils::LoadObjectFromBuffer<AZ::Transform>(objectStreamBuffer, strlen(objectStreamBuffer) + 1);
const AZ::Vector3 expectedTranslation(513.7845459f, 492.5420837f, 32.0000000f);
const AZ::Vector3 expectedScale(1.5f, 0.5f, 1.2f);
const float expectedScale = 1.5f;
const AZ::Quaternion expectedRotation(0.2624075f, 0.4405251f, 0.2029076f, 0.8342113f);
const AZ::Transform expectedTransform =
AZ::Transform::CreateFromQuaternionAndTranslation(expectedRotation, expectedTranslation) * AZ::Transform::CreateScale(expectedScale);
AZ::Transform::CreateFromQuaternionAndTranslation(expectedRotation, expectedTranslation) *
AZ::Transform::CreateUniformScale(expectedScale);
EXPECT_TRUE(deserializedTransform->IsClose(expectedTransform));
azfree(deserializedTransform);

@ -1275,10 +1275,10 @@ namespace UnitTest
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(1, 0, 0)))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 1, 0)):IsClose(Vector3(0, 0.866, 0.5)))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 0, 1)):IsClose(Vector3(0, -0.5, 0.866)))");
script->Execute("t1 = Transform.CreateScale(Vector3(1, 2, 3))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(1, 0, 0)))");
script->Execute("t1 = Transform.CreateUniformScale(2)");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(2, 0, 0)))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 1, 0)):IsClose(Vector3(0, 2, 0)))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 0, 1)):IsClose(Vector3(0, 0, 3)))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 0, 1)):IsClose(Vector3(0, 0, 2)))");
script->Execute("t1 = Transform.CreateTranslation(Vector3(1, 2, 3))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(1, 0, 0)):IsClose(Vector3(1, 0, 0)))");
script->Execute("AZTestAssert(t1:TransformVector(Vector3(0, 1, 0)):IsClose(Vector3(0, 1, 0)))");
@ -1341,19 +1341,19 @@ namespace UnitTest
script->Execute("AZTestAssert(t3:GetTranslation():IsClose(Vector3(-5.90, 25.415, 19.645), 0.001))");
////test inverse, should handle non-orthogonal matrices
script->Execute("t1 = Transform.CreateRotationX(1) * Transform.CreateScale(Vector3(1, 2, 3))");
script->Execute("t1 = Transform.CreateRotationX(1) * Transform.CreateUniformScale(2)");
script->Execute("AZTestAssert((t1*t1:GetInverse()):IsClose(Transform.CreateIdentity()))");
////scale access
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(40)) * Transform.CreateScale(Vector3(2, 3, 4))");
script->Execute("AZTestAssert(t1:GetScale():IsClose(Vector3(2, 3, 4)))");
script->Execute("AZTestAssert(t1:ExtractScale():IsClose(Vector3(2, 3, 4)))");
script->Execute("AZTestAssert(t1:GetScale():IsClose(Vector3.CreateOne()))");
script->Execute("t1:MultiplyByScale(Vector3(3, 4, 5))");
script->Execute("AZTestAssert(t1:GetScale():IsClose(Vector3(3, 4, 5)))");
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(40)) * Transform.CreateUniformScale(3)");
script->Execute("AZTestAssertFloatClose(t1:GetUniformScale(), 3)");
script->Execute("AZTestAssertFloatClose(t1:ExtractUniformScale(), 3)");
script->Execute("AZTestAssertFloatClose(t1:GetUniformScale(), 1)");
script->Execute("t1:MultiplyByUniformScale(2)");
script->Execute("AZTestAssertFloatClose(t1:GetUniformScale(), 2)");
////orthogonalize
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateScale(Vector3(2, 3, 4))");
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateUniformScale(3)");
script->Execute("t1:SetTranslation(Vector3(1,2,3))");
script->Execute("t2 = t1:GetOrthogonalized()");
script->Execute("AZTestAssertFloatClose(t2:GetBasisX():GetLength(), 1)");
@ -1372,7 +1372,7 @@ namespace UnitTest
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30))");
script->Execute("t1:SetTranslation(Vector3(1, 2, 3))");
script->Execute("AZTestAssert(t1:IsOrthogonal(0.05))");
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateScale(Vector3(2, 3, 4))");
script->Execute("t1 = Transform.CreateRotationX(Math.DegToRad(30)) * Transform.CreateUniformScale(2)");
script->Execute("AZTestAssert( not t1:IsOrthogonal(0.05))");
////IsClose

@ -189,7 +189,7 @@ namespace JsonSerializationTests
TEST_F(JsonTransformSerializerTests, Load_FullySetTransform_ReturnsSuccessWithOnlyScale)
{
AZ::Transform testTransform = AZ::Transform::CreateIdentity();
AZ::Transform expectedTransform = AZ::Transform::CreateScale(AZ::Vector3(5.5f));
AZ::Transform expectedTransform = AZ::Transform::CreateUniformScale(5.5f);
rapidjson::Document json;
json.Parse(R"({ "Scale" : 5.5 })");

@ -432,46 +432,26 @@ namespace AzFramework
void TransformComponent::SetLocalRotation(const AZ::Vector3& eulerRadianAngles)
{
AZ::Transform newLocalTM = AZ::ConvertEulerRadiansToTransform(eulerRadianAngles);
newLocalTM.SetScale(m_localTM.GetScale());
newLocalTM.SetTranslation(m_localTM.GetTranslation());
AZ::Transform newLocalTM = m_localTM;
newLocalTM.SetRotation(AZ::Quaternion::CreateFromEulerAnglesRadians(eulerRadianAngles));
SetLocalTM(newLocalTM);
}
void TransformComponent::SetLocalRotationQuaternion(const AZ::Quaternion& quaternion)
{
AZ::Transform newLocalTM;
newLocalTM.SetScale(m_localTM.GetScale());
newLocalTM.SetTranslation(m_localTM.GetTranslation());
AZ::Transform newLocalTM = m_localTM;
newLocalTM.SetRotation(quaternion);
SetLocalTM(newLocalTM);
}
static AZ::Transform RotateAroundLocalHelper(float eulerAngleRadian, const AZ::Transform& localTM, AZ::Vector3 axis)
{
//get the existing translation and scale
AZ::Vector3 translation = localTM.GetTranslation();
AZ::Vector3 scale = localTM.GetScale();
//normalize the axis before creating rotation
axis.Normalize();
AZ::Quaternion rotate = AZ::Quaternion::CreateFromAxisAngle(axis, eulerAngleRadian);
//create new rotation transform
AZ::Quaternion currentRotate = localTM.GetRotation();
AZ::Quaternion newRotate = rotate * currentRotate;
newRotate.Normalize();
//scale
AZ::Transform newLocalTM = AZ::Transform::CreateScale(scale);
//rotate
AZ::Transform rotateLocalTM = AZ::Transform::CreateFromQuaternion(newRotate);
newLocalTM = rotateLocalTM * newLocalTM;
//translate
newLocalTM.SetTranslation(translation);
AZ::Transform newLocalTM = localTM;
newLocalTM.SetRotation((rotate * localTM.GetRotation()).GetNormalized());
return newLocalTM;
}
@ -512,75 +492,6 @@ namespace AzFramework
return m_localTM.GetRotation();
}
void TransformComponent::SetScale(const AZ::Vector3& scale)
{
AZ_Warning("TransformComponent", false, "SetScale is deprecated, please use SetLocalScale");
if (!m_worldTM.GetScale().IsClose(scale))
{
AZ::Transform newWorldTransform = m_worldTM;
newWorldTransform.SetScale(scale);
SetWorldTM(newWorldTransform);
}
}
void TransformComponent::SetScaleX(float scaleX)
{
AZ_Warning("TransformComponent", false, "SetScaleX is deprecated, please use SetLocalScaleX");
AZ::Vector3 newScale = m_worldTM.GetScale();
newScale.SetX(scaleX);
AZ::Transform newWorldTransform = m_worldTM;
newWorldTransform.SetScale(newScale);
SetWorldTM(newWorldTransform);
}
void TransformComponent::SetScaleY(float scaleY)
{
AZ_Warning("TransformComponent", false, "SetScaleY is deprecated, please use SetLocalScaleY");
AZ::Vector3 newScale = m_worldTM.GetScale();
newScale.SetY(scaleY);
AZ::Transform newWorldTransform = m_worldTM;
newWorldTransform.SetScale(newScale);
SetWorldTM(newWorldTransform);
}
void TransformComponent::SetScaleZ(float scaleZ)
{
AZ_Warning("TransformComponent", false, "SetScaleZ is deprecated, please use SetLocalScaleZ");
AZ::Vector3 newScale = m_worldTM.GetScale();
newScale.SetZ(scaleZ);
AZ::Transform newWorldTransform = m_worldTM;
newWorldTransform.SetScale(newScale);
SetWorldTM(newWorldTransform);
}
AZ::Vector3 TransformComponent::GetScale()
{
AZ_Warning("TransformComponent", false, "GetScale is deprecated, please use GetLocalScale");
return m_worldTM.GetScale();
}
float TransformComponent::GetScaleX()
{
AZ_Warning("TransformComponent", false, "GetScaleX is deprecated, please use GetLocalScale");
return m_worldTM.GetScale().GetX();
}
float TransformComponent::GetScaleY()
{
AZ_Warning("TransformComponent", false, "GetScaleY is deprecated, please use GetLocalScale");
return m_worldTM.GetScale().GetY();
}
float TransformComponent::GetScaleZ()
{
AZ_Warning("TransformComponent", false, "GetScaleZ is deprecated, please use GetLocalScale");
return m_worldTM.GetScale().GetZ();
}
void TransformComponent::SetLocalScale(const AZ::Vector3& scale)
{
AZ::Transform newLocalTM = m_localTM;
@ -588,41 +499,31 @@ namespace AzFramework
SetLocalTM(newLocalTM);
}
void TransformComponent::SetLocalScaleX(float scaleX)
AZ::Vector3 TransformComponent::GetLocalScale()
{
AZ::Transform newLocalTM = m_localTM;
AZ::Vector3 newScale = newLocalTM.GetScale();
newScale.SetX(scaleX);
newLocalTM.SetScale(newScale);
SetLocalTM(newLocalTM);
return m_localTM.GetScale();
}
void TransformComponent::SetLocalScaleY(float scaleY)
AZ::Vector3 TransformComponent::GetWorldScale()
{
AZ::Transform newLocalTM = m_localTM;
AZ::Vector3 newScale = newLocalTM.GetScale();
newScale.SetY(scaleY);
newLocalTM.SetScale(newScale);
SetLocalTM(newLocalTM);
return m_worldTM.GetScale();
}
void TransformComponent::SetLocalScaleZ(float scaleZ)
void TransformComponent::SetLocalUniformScale(float scale)
{
AZ::Transform newLocalTM = m_localTM;
AZ::Vector3 newScale = newLocalTM.GetScale();
newScale.SetZ(scaleZ);
newLocalTM.SetScale(newScale);
newLocalTM.SetUniformScale(scale);
SetLocalTM(newLocalTM);
}
AZ::Vector3 TransformComponent::GetLocalScale()
float TransformComponent::GetLocalUniformScale()
{
return m_localTM.GetScale();
return m_localTM.GetUniformScale();
}
AZ::Vector3 TransformComponent::GetWorldScale()
float TransformComponent::GetWorldUniformScale()
{
return m_worldTM.GetScale();
return m_worldTM.GetUniformScale();
}
AZStd::vector<AZ::EntityId> TransformComponent::GetChildren()
@ -979,34 +880,7 @@ namespace AzFramework
->Event("GetLocalRotationQuaternion", &AZ::TransformBus::Events::GetLocalRotationQuaternion)
->Attribute("Rotation", AZ::Edit::Attributes::PropertyRotation)
->VirtualProperty("Rotation", "GetLocalRotationQuaternion", "SetLocalRotationQuaternion")
->Event("SetScale", &AZ::TransformBus::Events::SetScale)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("SetScaleX", &AZ::TransformBus::Events::SetScaleX)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("SetScaleY", &AZ::TransformBus::Events::SetScaleY)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("SetScaleZ", &AZ::TransformBus::Events::SetScaleZ)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("GetScale", &AZ::TransformBus::Events::GetScale)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("GetScaleX", &AZ::TransformBus::Events::GetScaleX)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("GetScaleY", &AZ::TransformBus::Events::GetScaleY)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("GetScaleZ", &AZ::TransformBus::Events::GetScaleZ)
->Attribute(AZ::Script::Attributes::Deprecated, true)
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Event("SetLocalScale", &AZ::TransformBus::Events::SetLocalScale)
->Event("SetLocalScaleX", &AZ::TransformBus::Events::SetLocalScaleX)
->Event("SetLocalScaleY", &AZ::TransformBus::Events::SetLocalScaleY)
->Event("SetLocalScaleZ", &AZ::TransformBus::Events::SetLocalScaleZ)
->Event("GetLocalScale", &AZ::TransformBus::Events::GetLocalScale)
->Attribute("Scale", AZ::Edit::Attributes::PropertyScale)
->VirtualProperty("Scale", "GetLocalScale", "SetLocalScale")

@ -143,24 +143,14 @@ namespace AzFramework
AZ::Quaternion GetLocalRotationQuaternion() override;
// Scale Modifiers
void SetScale(const AZ::Vector3& scale) override;
void SetScaleX(float scaleX) override;
void SetScaleY(float scaleY) override;
void SetScaleZ(float scaleZ) override;
AZ::Vector3 GetScale() override;
float GetScaleX() override;
float GetScaleY() override;
float GetScaleZ() override;
void SetLocalScale(const AZ::Vector3& scale) override;
void SetLocalScaleX(float scaleX) override;
void SetLocalScaleY(float scaleY) override;
void SetLocalScaleZ(float scaleZ) override;
AZ::Vector3 GetLocalScale() override;
AZ::Vector3 GetWorldScale() override;
void SetLocalUniformScale(float scale) override;
float GetLocalUniformScale() override;
float GetWorldUniformScale() override;
// Transform hierarchy
AZStd::vector<AZ::EntityId> GetChildren() override;
AZStd::vector<AZ::EntityId> GetAllDescendants() override;

@ -82,9 +82,7 @@ namespace AzToolsFramework
m_uniformScaleManipulator->SetVisualOrientationOverride(
QuaternionFromTransformNoScaling(localTransform));
m_uniformScaleManipulator->SetLocalTransform(
AZ::Transform::CreateTranslation(localTransform.GetTranslation()) *
AZ::Transform::CreateScale(localTransform.GetScale()));
m_uniformScaleManipulator->SetLocalOrientation(AZ::Quaternion::CreateIdentity());
}
void ScaleManipulators::SetLocalPositionImpl(const AZ::Vector3& localPosition)

@ -33,8 +33,7 @@ namespace AzToolsFramework
inline AZ::Transform TransformUniformScale(const AZ::Transform& transform)
{
AZ::Transform transformUniformScale = transform;
const float maxScale = transformUniformScale.GetScale().GetMaxElement();
transformUniformScale.SetScale(AZ::Vector3(maxScale));
transformUniformScale.SetUniformScale(transformUniformScale.GetUniformScale());
return transformUniformScale;
}

@ -1475,10 +1475,8 @@ namespace AzToolsFramework
// to avoid pushing them to the slice.
// Only scale is preserved on the root entity of a slice.
transformComponent->SetParent(AZ::EntityId());
AZ::Vector3 scale = transformComponent->GetLocalScale();
transformComponent->SetWorldTranslation(AZ::Vector3::CreateZero());
transformComponent->SetLocalRotation(AZ::Vector3::CreateZero());
transformComponent->SetLocalScale(scale);
}
}

@ -357,7 +357,7 @@ namespace AzToolsFramework
AZ::Transform TransformComponent::GetLocalScaleTM() const
{
return AZ::Transform::CreateScale(m_editorTransform.m_scale);
return AZ::Transform::CreateUniformScale(m_editorTransform.m_scale.GetMaxElement());
}
const AZ::Transform& TransformComponent::GetLocalTM()
@ -677,108 +677,36 @@ namespace AzToolsFramework
return result;
}
void TransformComponent::SetScale(const AZ::Vector3& newScale)
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "SetScale is deprecated, please use SetLocalScale");
AZ::Transform newWorldTransform = GetWorldTM();
AZ::Vector3 prevScale = newWorldTransform.ExtractScale();
if (!prevScale.IsClose(newScale))
{
newWorldTransform.MultiplyByScale(newScale);
SetWorldTM(newWorldTransform);
}
}
void TransformComponent::SetScaleX(float newScale)
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "SetScaleX is deprecated, please use SetLocalScaleX");
AZ::Transform newWorldTransform = GetWorldTM();
AZ::Vector3 scale = newWorldTransform.ExtractScale();
scale.SetX(newScale);
newWorldTransform.MultiplyByScale(scale);
SetWorldTM(newWorldTransform);
}
void TransformComponent::SetScaleY(float newScale)
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "SetScaleY is deprecated, please use SetLocalScaleY");
AZ::Transform newWorldTransform = GetWorldTM();
AZ::Vector3 scale = newWorldTransform.ExtractScale();
scale.SetY(newScale);
newWorldTransform.MultiplyByScale(scale);
SetWorldTM(newWorldTransform);
}
void TransformComponent::SetScaleZ(float newScale)
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "SetScaleZ is deprecated, please use SetLocalScaleZ");
AZ::Transform newWorldTransform = GetWorldTM();
AZ::Vector3 scale = newWorldTransform.ExtractScale();
scale.SetZ(newScale);
newWorldTransform.MultiplyByScale(scale);
SetWorldTM(newWorldTransform);
}
AZ::Vector3 TransformComponent::GetScale()
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "GetScale is deprecated, please use GetLocalScale");
return GetWorldTM().GetScale();
}
float TransformComponent::GetScaleX()
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "GetScaleX is deprecated, please use GetLocalScale");
return GetWorldTM().GetScale().GetX();
}
float TransformComponent::GetScaleY()
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "GetScaleY is deprecated, please use GetLocalScale");
return GetWorldTM().GetScale().GetY();
}
float TransformComponent::GetScaleZ()
{
AZ_Warning("AzToolsFramework::TransformComponent", false, "GetScaleZ is deprecated, please use GetLocalScale");
return GetWorldTM().GetScale().GetZ();
}
void TransformComponent::SetLocalScale(const AZ::Vector3& scale)
{
m_editorTransform.m_scale = scale;
TransformChanged();
}
void TransformComponent::SetLocalScaleX(float scaleX)
AZ::Vector3 TransformComponent::GetLocalScale()
{
m_editorTransform.m_scale.SetX(scaleX);
TransformChanged();
return m_editorTransform.m_scale;
}
void TransformComponent::SetLocalScaleY(float scaleY)
AZ::Vector3 TransformComponent::GetWorldScale()
{
m_editorTransform.m_scale.SetY(scaleY);
TransformChanged();
return GetWorldTM().GetScale();
}
void TransformComponent::SetLocalScaleZ(float scaleZ)
void TransformComponent::SetLocalUniformScale(float scale)
{
m_editorTransform.m_scale.SetZ(scaleZ);
m_editorTransform.m_scale = AZ::Vector3(scale);
TransformChanged();
}
AZ::Vector3 TransformComponent::GetLocalScale()
float TransformComponent::GetLocalUniformScale()
{
return m_editorTransform.m_scale;
return m_editorTransform.m_scale.GetMaxElement();
}
AZ::Vector3 TransformComponent::GetWorldScale()
float TransformComponent::GetWorldUniformScale()
{
return GetWorldTM().GetScale();
return GetWorldTM().GetUniformScale();
}
const AZ::Transform& TransformComponent::GetParentWorldTM() const
@ -1183,12 +1111,6 @@ namespace AzToolsFramework
ModifyEditorTransform(m_editorTransform.m_rotate, data, parent);
}
void TransformComponent::ScaleBy(const AZ::Vector3& data)
{
//scale is always local
ModifyEditorTransform(m_editorTransform.m_scale, data, AZ::Transform::Identity());
}
AZ::EntityId TransformComponent::GetSliceEntityParentId()
{
return GetParentId();

@ -130,24 +130,14 @@ namespace AzToolsFramework
AZ::Quaternion GetLocalRotationQuaternion() override;
// Scale Modifiers
void SetScale(const AZ::Vector3& newScale) override;
void SetScaleX(float newScale) override;
void SetScaleY(float newScale) override;
void SetScaleZ(float newScale) override;
AZ::Vector3 GetScale() override;
float GetScaleX() override;
float GetScaleY() override;
float GetScaleZ() override;
void SetLocalScale(const AZ::Vector3& scale) override;
void SetLocalScaleX(float scaleX) override;
void SetLocalScaleY(float scaleY) override;
void SetLocalScaleZ(float scaleZ) override;
AZ::Vector3 GetLocalScale() override;
AZ::Vector3 GetWorldScale() override;
void SetLocalUniformScale(float scale) override;
float GetLocalUniformScale() override;
float GetWorldUniformScale() override;
AZ::EntityId GetParentId() override;
AZ::TransformInterface* GetParent() override;
void SetParent(AZ::EntityId parentId) override;
@ -161,7 +151,6 @@ namespace AzToolsFramework
// TransformComponentMessages::Bus
void TranslateBy(const AZ::Vector3&) override;
void RotateBy(const AZ::Vector3&) override; // euler in degrees
void ScaleBy(const AZ::Vector3&) override;
const EditorTransform& GetLocalEditorTransform() override;
void SetLocalEditorTransform(const EditorTransform& dest) override;
bool IsTransformLocked() override;

@ -65,7 +65,6 @@ namespace AzToolsFramework
virtual void TranslateBy(const AZ::Vector3&) = 0;
virtual void RotateBy(const AZ::Vector3&) = 0;
virtual void ScaleBy(const AZ::Vector3&) = 0;
virtual bool IsTransformLocked() = 0;
};

@ -1474,7 +1474,7 @@ namespace AzToolsFramework
{
const AZ::Quaternion rotation = entityIdLookupIt->second.m_initial.GetRotation().GetNormalized();
const AZ::Vector3 position = entityIdLookupIt->second.m_initial.GetTranslation();
const AZ::Vector3 scale = entityIdLookupIt->second.m_initial.GetScale();
const float scale = entityIdLookupIt->second.m_initial.GetUniformScale();
const AZ::Vector3 centerOffset = CalculateCenterOffset(entityId, m_pivotMode);
@ -1485,7 +1485,7 @@ namespace AzToolsFramework
AZ::Transform::CreateFromQuaternion(rotation) *
AZ::Transform::CreateTranslation(centerOffset) * offsetRotation *
AZ::Transform::CreateTranslation(-centerOffset) *
AZ::Transform::CreateScale(scale));
AZ::Transform::CreateUniformScale(scale));
}
break;
case ReferenceFrame::Parent:
@ -1597,16 +1597,15 @@ namespace AzToolsFramework
}
const AZ::Transform initial = entityIdLookupIt->second.m_initial;
const AZ::Vector3 initialScale = initial.GetScale();
const float initialScale = initial.GetUniformScale();
const auto sumVectorElements = [](const AZ::Vector3& vec) {
return vec.GetX() + vec.GetY() + vec.GetZ();
};
const AZ::Vector3 uniformScale = AZ::Vector3(action.m_start.m_sign * sumVectorElements(action.LocalScaleOffset()));
const AZ::Vector3 scale = (AZ::Vector3::CreateOne() +
(uniformScale / initialScale)).GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale));
const AZ::Transform scaleTransform = AZ::Transform::CreateScale(scale);
const float uniformScale = action.m_start.m_sign * sumVectorElements(action.LocalScaleOffset());
const float scale = AZ::GetClamp(1.0f + uniformScale / initialScale, AZ::MinTransformScale, AZ::MaxTransformScale);
const AZ::Transform scaleTransform = AZ::Transform::CreateUniformScale(scale);
if (action.m_modifiers.Alt())
{
@ -1872,7 +1871,7 @@ namespace AzToolsFramework
CopyOrientationToSelectedEntitiesGroup(QuaternionFromTransformNoScaling(worldFromLocal));
break;
case Mode::Scale:
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetScale());
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetUniformScale());
break;
case Mode::Translation:
CopyTranslationToSelectedEntitiesGroup(worldFromLocal.GetTranslation());
@ -1901,7 +1900,7 @@ namespace AzToolsFramework
CopyOrientationToSelectedEntitiesIndividual(QuaternionFromTransformNoScaling(worldFromLocal));
break;
case Mode::Scale:
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetScale());
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetUniformScale());
break;
case Mode::Translation:
CopyTranslationToSelectedEntitiesIndividual(worldFromLocal.GetTranslation());
@ -2394,7 +2393,7 @@ namespace AzToolsFramework
ResetOrientationForSelectedEntitiesLocal();
break;
case Mode::Scale:
CopyScaleToSelectedEntitiesIndividualLocal(AZ::Vector3::CreateOne());
CopyScaleToSelectedEntitiesIndividualLocal(1.0f);
break;
case Mode::Translation:
ResetTranslationForSelectedEntitiesLocal();
@ -2420,7 +2419,7 @@ namespace AzToolsFramework
ResetOrientationForSelectedEntitiesLocal();
break;
case Mode::Scale:
CopyScaleToSelectedEntitiesIndividualWorld(AZ::Vector3::CreateOne());
CopyScaleToSelectedEntitiesIndividualWorld(1.0f);
break;
case Mode::Translation:
// do nothing
@ -2940,7 +2939,7 @@ namespace AzToolsFramework
}
}
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualWorld(const AZ::Vector3& scale)
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualWorld(float scale)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
@ -2955,7 +2954,7 @@ namespace AzToolsFramework
const auto transformsBefore = RecordTransformsBefore(manipulatorEntityIds.m_entityIds);
// update scale relative to initial
const AZ::Transform scaleTransform = AZ::Transform::CreateScale(scale);
const AZ::Transform scaleTransform = AZ::Transform::CreateUniformScale(scale);
for (AZ::EntityId entityId : manipulatorEntityIds.m_entityIds)
{
ScopedUndoBatch::MarkEntityDirty(entityId);
@ -2974,7 +2973,7 @@ namespace AzToolsFramework
RefreshUiAfterChange(manipulatorEntityIds.m_entityIds);
}
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualLocal(const AZ::Vector3& scale)
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualLocal(float scale)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
@ -3020,9 +3019,9 @@ namespace AzToolsFramework
if (transformIt != transformsBefore.end())
{
AZ::Transform newWorldFromLocal = transformIt->second;
const AZ::Vector3 scale = newWorldFromLocal.GetScale();
const float scale = newWorldFromLocal.GetUniformScale();
newWorldFromLocal.SetRotation(orientation);
newWorldFromLocal *= AZ::Transform::CreateScale(scale);
newWorldFromLocal *= AZ::Transform::CreateUniformScale(scale);
SetEntityWorldTransform(entityId, newWorldFromLocal);
}
@ -3669,7 +3668,7 @@ namespace AzToolsFramework
}
void EditorTransformComponentSelection::SetEntityLocalScale(
const AZ::EntityId entityId, const AZ::Vector3& localScale)
const AZ::EntityId entityId, const float localScale)
{
ETCS::SetEntityLocalScale(entityId, localScale, m_transformChangedInternally);
}
@ -3722,11 +3721,11 @@ namespace AzToolsFramework
entityId, &AZ::TransformBus::Events::SetWorldTM, worldTransform);
}
void SetEntityLocalScale(AZ::EntityId entityId, const AZ::Vector3& localScale, bool& internal)
void SetEntityLocalScale(AZ::EntityId entityId, float localScale, bool& internal)
{
ScopeSwitch sw(internal);
AZ::TransformBus::Event(
entityId, &AZ::TransformBus::Events::SetLocalScale, localScale);
entityId, &AZ::TransformBus::Events::SetLocalUniformScale, localScale);
}
void SetEntityLocalRotation(AZ::EntityId entityId, const AZ::Vector3& localRotation, bool& internal)

@ -214,8 +214,8 @@ namespace AzToolsFramework
void CopyOrientationToSelectedEntitiesIndividual(const AZ::Quaternion& orientation);
void CopyOrientationToSelectedEntitiesGroup(const AZ::Quaternion& orientation);
void ResetOrientationForSelectedEntitiesLocal();
void CopyScaleToSelectedEntitiesIndividualLocal(const AZ::Vector3& scale);
void CopyScaleToSelectedEntitiesIndividualWorld(const AZ::Vector3& scale);
void CopyScaleToSelectedEntitiesIndividualLocal(float scale);
void CopyScaleToSelectedEntitiesIndividualWorld(float scale);
// EditorManipulatorCommandUndoRedoRequestBus ...
void UndoRedoEntityManipulatorCommand(
@ -250,7 +250,7 @@ namespace AzToolsFramework
void SetEntityWorldTranslation(AZ::EntityId entityId, const AZ::Vector3& worldTranslation);
void SetEntityLocalTranslation(AZ::EntityId entityId, const AZ::Vector3& localTranslation);
void SetEntityWorldTransform(AZ::EntityId entityId, const AZ::Transform& worldTransform);
void SetEntityLocalScale(AZ::EntityId entityId, const AZ::Vector3& localScale);
void SetEntityLocalScale(AZ::EntityId entityId, float localScale);
void SetEntityLocalRotation(AZ::EntityId entityId, const AZ::Vector3& localRotation);
AZ::EntityId m_hoveredEntityId; //!< What EntityId is the mouse currently hovering over (if any).
@ -320,7 +320,7 @@ namespace AzToolsFramework
void SetEntityWorldTranslation(AZ::EntityId entityId, const AZ::Vector3& worldTranslation, bool& internal);
void SetEntityLocalTranslation(AZ::EntityId entityId, const AZ::Vector3& localTranslation, bool& internal);
void SetEntityWorldTransform(AZ::EntityId entityId, const AZ::Transform& worldTransform, bool& internal);
void SetEntityLocalScale(AZ::EntityId entityId, const AZ::Vector3& localScale, bool& internal);
void SetEntityLocalScale(AZ::EntityId entityId, float localScale, bool& internal);
void SetEntityLocalRotation(AZ::EntityId entityId, const AZ::Vector3& localRotation, bool& internal);
} // namespace ETCS
} // namespace AzToolsFramework

@ -101,10 +101,10 @@ namespace AzToolsFramework
virtual void ResetOrientationForSelectedEntitiesLocal() = 0;
/// Copy scale to each individual entity in local space without moving position.
virtual void CopyScaleToSelectedEntitiesIndividualLocal(const AZ::Vector3& scale) = 0;
virtual void CopyScaleToSelectedEntitiesIndividualLocal(float scale) = 0;
/// Copy scale to to each individual entity in world (absolute) space.
virtual void CopyScaleToSelectedEntitiesIndividualWorld(const AZ::Vector3& scale) = 0;
virtual void CopyScaleToSelectedEntitiesIndividualWorld(float scale) = 0;
protected:
~EditorTransformComponentSelectionRequests() = default;

@ -483,6 +483,9 @@ namespace UnitTest
{
AUTO_RESULT_IF_SETTING_TRUE(UnitTest::prefabSystemSetting, true)
// Swallow deprecation warnings from the Transform component as they are not relevant to this test
UnitTest::ErrorHandler errorHandler("GetScale is deprecated");
// Create a parent entity with a transform component
AZ::Entity* parentEntity = aznew AZ::Entity("TestParentEntity");
parentEntity->CreateComponent<AzToolsFramework::Components::TransformComponent>();

@ -610,15 +610,15 @@ namespace AzToolsFramework
m_layerEntity.m_layer->ClearUnsavedChanges();
// Change the scale of the child entity so it registers as an unsaved change on the layer.
AZ::Vector3 scale(-1.0f,0.0f,0.0f);
float scale = 0.0f;
AZ::TransformBus::EventResult(
scale,
childEntity->GetId(),
&AZ::TransformBus::Events::GetLocalScale);
scale.SetX(scale.GetX() + 1.0f);
&AZ::TransformBus::Events::GetLocalUniformScale);
scale += 1.0f;
AZ::TransformBus::Event(
childEntity->GetId(),
&AZ::TransformBus::Events::SetLocalScale,
&AZ::TransformBus::Events::SetLocalUniformScale,
scale);
bool hasUnsavedChanges = false;

@ -52,19 +52,19 @@ namespace AzToolsFramework
TransformTestEntityHierarchy hierarchy = BuildTestHierarchy();
// Set scale to parent entity
const AZ::Vector3 parentScale(2.0f, 1.0f, 3.0f);
AZ::TransformBus::Event(hierarchy.m_parentId, &AZ::TransformInterface::SetLocalScale, parentScale);
const float parentScale = 2.0f;
AZ::TransformBus::Event(hierarchy.m_parentId, &AZ::TransformInterface::SetLocalUniformScale, parentScale);
// Set scale to child entity
const AZ::Vector3 childScale(5.0f, 6.0f, 10.0f);
AZ::TransformBus::Event(hierarchy.m_childId, &AZ::TransformInterface::SetLocalScale, childScale);
const float childScale = 5.0f;
AZ::TransformBus::Event(hierarchy.m_childId, &AZ::TransformInterface::SetLocalUniformScale, childScale);
const AZ::Vector3 expectedScale = childScale * parentScale;
const float expectedScale = childScale * parentScale;
AZ::Vector3 childWorldScale = AZ::Vector3::CreateOne();
AZ::TransformBus::EventResult(childWorldScale, hierarchy.m_childId, &AZ::TransformBus::Events::GetWorldScale);
float childWorldScale = 1.0f;
AZ::TransformBus::EventResult(childWorldScale, hierarchy.m_childId, &AZ::TransformBus::Events::GetWorldUniformScale);
EXPECT_THAT(childWorldScale, UnitTest::IsClose(expectedScale));
EXPECT_NEAR(childWorldScale, expectedScale, AZ::Constants::Tolerance);
}
TEST_F(EditorTransformComponentTest, TransformTests_GetChildren_DirectChildrenMatchHierarchy)

@ -24,6 +24,8 @@
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
#include <AZTestShared/Math/MathTestHelpers.h>
using namespace AZ;
using namespace AzFramework;
@ -362,8 +364,8 @@ namespace UnitTest
TEST_F(TransformComponentTransformMatrixSetGet, SetLocalRotation_SimpleValues_Set)
{
// add some scale first
float sx = 1.03f, sy = 0.67f, sz = 1.23f;
Transform tm = Transform::CreateScale(Vector3(sx, sy, sz));
float scale = 1.23f;
Transform tm = Transform::CreateUniformScale(scale);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalTM, tm);
float rx = 42.435f;
@ -379,13 +381,13 @@ namespace UnitTest
Matrix3x3 finalRotate = rotateX * rotateY * rotateZ;
Vector3 basisX = tm.GetBasisX();
Vector3 expectedBasisX = finalRotate.GetBasisX() * sx;
Vector3 expectedBasisX = finalRotate.GetBasisX() * scale;
EXPECT_TRUE(basisX.IsClose(expectedBasisX));
Vector3 basisY = tm.GetBasisY();
Vector3 expectedBasisY = finalRotate.GetBasisY() * sy;
Vector3 expectedBasisY = finalRotate.GetBasisY() * scale;
EXPECT_TRUE(basisY.IsClose(expectedBasisY));
Vector3 basisZ = tm.GetBasisZ();
Vector3 expectedBasisZ = finalRotate.GetBasisZ() * sz;
Vector3 expectedBasisZ = finalRotate.GetBasisZ() * scale;
EXPECT_TRUE(basisZ.IsClose(expectedBasisZ));
}
@ -476,18 +478,15 @@ namespace UnitTest
{
TransformBus::Event(m_childId, &TransformBus::Events::RotateAroundLocalX, rx);
}
Vector3 localScale;
TransformBus::EventResult(localScale, m_childId, &TransformBus::Events::GetLocalScale);
EXPECT_TRUE(localScale.IsClose(Vector3(1.0f, 1.0f, 1.0f)));
float localScale = FLT_MAX;
TransformBus::EventResult(localScale, m_childId, &TransformBus::Events::GetLocalUniformScale);
EXPECT_NEAR(localScale, 1.0f, AZ::Constants::Tolerance);
}
TEST_F(TransformComponentTransformMatrixSetGet, RotateAroundLocalX_ScaleDoesNotSkewRotation)
{
float sx = 42.564f;
float sy = 12.460f;
float sz = 28.692f;
Vector3 expectedScales(sx, sy, sz);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalScale, expectedScales);
float expectedScale = 42.564f;
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalUniformScale, expectedScale);
float rx = 1.43f;
TransformBus::Event(m_childId, &TransformBus::Events::RotateAroundLocalX, rx);
@ -513,18 +512,15 @@ namespace UnitTest
{
TransformBus::Event(m_childId, &TransformBus::Events::RotateAroundLocalY, ry);
}
Vector3 localScale;
TransformBus::EventResult(localScale, m_childId, &TransformBus::Events::GetLocalScale);
EXPECT_TRUE(localScale.IsClose(Vector3(1.0f, 1.0f, 1.0f)));
float localScale = FLT_MAX;
TransformBus::EventResult(localScale, m_childId, &TransformBus::Events::GetLocalUniformScale);
EXPECT_NEAR(localScale, 1.0f, AZ::Constants::Tolerance);
}
TEST_F(TransformComponentTransformMatrixSetGet, RotateAroundLocalY_ScaleDoesNotSkewRotation)
{
float sx = 42.564f;
float sy = 12.460f;
float sz = 28.692f;
Vector3 expectedScales(sx, sy, sz);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalScale, expectedScales);
float expectedScale = 42.564f;
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalUniformScale, expectedScale);
float ry = 1.43f;
TransformBus::Event(m_childId, &TransformBus::Events::RotateAroundLocalY, ry);
@ -550,18 +546,15 @@ namespace UnitTest
{
TransformBus::Event(m_childId, &TransformBus::Events::RotateAroundLocalZ, rz);
}
Vector3 localScale;
TransformBus::EventResult(localScale, m_childId, &TransformBus::Events::GetLocalScale);
EXPECT_TRUE(localScale.IsClose(Vector3(1.0f, 1.0f, 1.0f)));
float localScale = FLT_MAX;
TransformBus::EventResult(localScale, m_childId, &TransformBus::Events::GetLocalUniformScale);
EXPECT_NEAR(localScale, 1.0f, AZ::Constants::Tolerance);
}
TEST_F(TransformComponentTransformMatrixSetGet, RotateAroundLocalZ_ScaleDoesNotSkewRotation)
{
float sx = 42.564f;
float sy = 12.460f;
float sz = 28.692f;
Vector3 expectedScales(sx, sy, sz);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalScale, expectedScales);
float expectedScale = 42.564f;
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalUniformScale, expectedScale);
float rz = 1.43f;
TransformBus::Event(m_childId, &TransformBus::Events::RotateAroundLocalZ, rz);
@ -572,110 +565,50 @@ namespace UnitTest
TEST_F(TransformComponentTransformMatrixSetGet, SetLocalScale_SimpleValues_Set)
{
float sx = 42.564f;
float sy = 12.460f;
float sz = 28.692f;
Vector3 expectedScales(sx, sy, sz);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalScale, expectedScales);
Transform tm ;
TransformBus::EventResult(tm, m_childId, &TransformBus::Events::GetLocalTM);
Vector3 scales = tm.GetScale();
EXPECT_TRUE(scales.IsClose(expectedScales));
}
TEST_F(TransformComponentTransformMatrixSetGet, SetLocalScaleX_SimpleValues_Set)
{
float sx = 64.336f;
Transform tm;
TransformBus::EventResult(tm, m_childId, &TransformBus::Events::GetLocalTM);
Vector3 expectedScales = tm.GetScale();
expectedScales.SetX(sx);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalScaleX, sx);
TransformBus::EventResult(tm, m_childId, &TransformBus::Events::GetLocalTM);
Vector3 scales = tm.GetScale();
EXPECT_TRUE(scales.IsClose(expectedScales));
}
TEST_F(TransformComponentTransformMatrixSetGet, SetLocalScaleY_SimpleValues_Set)
{
float sy = 23.754f;
Transform tm;
TransformBus::EventResult(tm, m_childId, &TransformBus::Events::GetLocalTM);
Vector3 expectedScales = tm.GetScale();
expectedScales.SetY(sy);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalScaleY, sy);
TransformBus::EventResult(tm, m_childId, &TransformBus::Events::GetLocalTM);
Vector3 scales = tm.GetScale();
EXPECT_TRUE(scales.IsClose(expectedScales));
}
float expectedScale = 42.564f;
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalUniformScale, expectedScale);
TEST_F(TransformComponentTransformMatrixSetGet, SetLocalScaleZ_SimpleValues_Set)
{
float sz = 65.140f;
Transform tm;
TransformBus::EventResult(tm, m_childId, &TransformBus::Events::GetLocalTM);
Vector3 expectedScales = tm.GetScale();
expectedScales.SetZ(sz);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalScaleZ, sz);
TransformBus::EventResult(tm, m_childId, &TransformBus::Events::GetLocalTM);
Vector3 scales = tm.GetScale();
EXPECT_TRUE(scales.IsClose(expectedScales));
float scale = tm.GetUniformScale();
EXPECT_NEAR(scale, expectedScale, AZ::Constants::Tolerance);
}
TEST_F(TransformComponentTransformMatrixSetGet, GetLocalScale_SimpleValues_Return)
{
float sx = 43.463f;
float sy = 346.22f;
float sz = 863.32f;
Vector3 expectedScales(sx, sy, sz);
Transform scaleTM = Transform::CreateScale(expectedScales);
float expectedScale = 43.463f;
Transform scaleTM = Transform::CreateUniformScale(expectedScale);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalTM, scaleTM);
Vector3 scales;
TransformBus::EventResult(scales, m_childId, &TransformBus::Events::GetLocalScale);
EXPECT_TRUE(scales.IsClose(expectedScales));
float scale;
TransformBus::EventResult(scale, m_childId, &TransformBus::Events::GetLocalUniformScale);
EXPECT_NEAR(scale, expectedScale, AZ::Constants::Tolerance);
}
TEST_F(TransformComponentTransformMatrixSetGet, GetWorldScale_ChildHasNoScale_ReturnScaleSameAsParent)
{
float sx = 43.463f;
float sy = 346.22f;
float sz = 863.32f;
Vector3 expectedScales(sx, sy, sz);
Transform scaleTM = Transform::CreateScale(expectedScales);
float expectedScale = 43.463f;
Transform scaleTM = Transform::CreateUniformScale(expectedScale);
TransformBus::Event(m_parentId, &TransformBus::Events::SetLocalTM, scaleTM);
Vector3 scales;
TransformBus::EventResult(scales, m_childId, &TransformBus::Events::GetWorldScale);
EXPECT_TRUE(scales.IsClose(expectedScales));
float scale = FLT_MAX;
TransformBus::EventResult(scale, m_childId, &TransformBus::Events::GetWorldUniformScale);
EXPECT_NEAR(scale, expectedScale, AZ::Constants::Tolerance);
}
TEST_F(TransformComponentTransformMatrixSetGet, GetWorldScale_ChildHasScale_ReturnCompoundScale)
{
float sx = 4.463f;
float sy = 3.22f;
float sz = 8.32f;
Vector3 parentScales(sx, sy, sz);
Transform parentScaleTM = Transform::CreateScale(parentScales);
float parentScale = 4.463f;
Transform parentScaleTM = Transform::CreateUniformScale(parentScale);
TransformBus::Event(m_parentId, &TransformBus::Events::SetLocalTM, parentScaleTM);
float csx = 1.64f;
float csy = 9.35f;
float csz = 1.57f;
Vector3 childScales(csx, csy, csz);
Transform childScaleTM = Transform::CreateScale(childScales);
float childScale = 1.64f;
Transform childScaleTM = Transform::CreateUniformScale(childScale);
TransformBus::Event(m_childId, &TransformBus::Events::SetLocalTM, childScaleTM);
Vector3 scales;
TransformBus::EventResult(scales, m_childId, &TransformBus::Events::GetWorldScale);
EXPECT_TRUE(scales.IsClose(parentScales * childScales));
float scale = FLT_MAX;
TransformBus::EventResult(scale, m_childId, &TransformBus::Events::GetWorldUniformScale);
EXPECT_NEAR(scale, parentScale * childScale, AZ::Constants::Tolerance);
}
class TransformComponentHierarchy

@ -482,28 +482,6 @@ void CSelectionGroup::StartScaling()
}
void CSelectionGroup::FinishScaling(const Vec3& scale, [[maybe_unused]] int referenceCoordSys)
{
if (fabs(scale.x - scale.y) < 0.001f &&
fabs(scale.y - scale.z) < 0.001f &&
fabs(scale.z - scale.x) < 0.001f)
{
return;
}
for (int i = 0; i < GetFilteredCount(); ++i)
{
CBaseObject* obj = GetFilteredObject(i);
Vec3 OriginalScale;
if (obj->GetUntransformedScale(OriginalScale))
{
obj->TransformScale(scale);
obj->SetScale(OriginalScale);
}
}
}
//////////////////////////////////////////////////////////////////////////
void CSelectionGroup::Align()
{

@ -103,7 +103,6 @@ public:
void StartScaling();
void Scale(const Vec3& scale, int referenceCoordSys);
void SetScale(const Vec3& scale, int referenceCoordSys);
void FinishScaling(const Vec3& scale, int referenceCoordSys);
//! Align objects in selection to surface normal
void Align();
//! Very special method to move contents of a voxel.

@ -79,7 +79,7 @@ namespace AZ
if (coordinateSystemRule->GetScale() != 1.0f)
{
float scale = coordinateSystemRule->GetScale();
matrix.MultiplyByScale(Vector3(scale, scale, scale));
matrix.MultiplyByScale(Vector3(scale));
}
if (!coordinateSystemRule->GetOriginNodeName().empty())
{

@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
from __future__ import annotations
import logging
from PySide2.QtGui import QPixmap
from PySide2.QtGui import QIcon
from PySide2.QtWidgets import (QMainWindow, QStackedWidget, QWidget)
from model import (error_messages, view_size_constants)
@ -43,7 +43,7 @@ class ViewManager(object):
def __init__(self) -> None:
if ViewManager.__instance is None:
self._main_window: QMainWindow = QMainWindow()
self._main_window.setWindowIcon(QPixmap(":/stylesheet/img/ly_application_icon.png"))
self._main_window.setWindowIcon(QIcon(":/Application/res/o3de_editor.ico"))
self._main_window.setWindowTitle("Resource Mapping")
self._main_window.setGeometry(0, 0,
view_size_constants.TOOL_APPLICATION_MAIN_WINDOW_WIDTH,

@ -50,6 +50,7 @@ if __name__ == "__main__":
from manager.thread_manager import ThreadManager
from manager.view_manager import ViewManager
from style import azqtcomponents_resources
from style import editormainwindow_resources
except ImportError as e:
logger.error(f"Failed to import module [{e.name}] {e}")
environment_utils.cleanup_qt_environment()

@ -16,6 +16,7 @@
#include <AzCore/Component/Component.h>
#include <AzFramework/Components/TransformComponent.h>
#include <AzFramework/Components/NonUniformScaleComponent.h>
#include <AzFramework/Entity/GameEntityContextBus.h>
#include <AtomCore/Instance/InstanceDatabase.h>
@ -182,9 +183,10 @@ namespace MaterialEditor
m_shadowCatcherEntity->CreateComponent(AZ::Render::MeshComponentTypeId);
m_shadowCatcherEntity->CreateComponent(AZ::Render::MaterialComponentTypeId);
m_shadowCatcherEntity->CreateComponent(azrtti_typeid<AzFramework::TransformComponent>());
m_shadowCatcherEntity->CreateComponent(azrtti_typeid<AzFramework::NonUniformScaleComponent>());
m_shadowCatcherEntity->Activate();
AZ::TransformBus::Event(m_shadowCatcherEntity->GetId(), &AZ::TransformBus::Events::SetLocalScale, AZ::Vector3{ 100, 100, 1.0 });
AZ::NonUniformScaleRequestBus::Event(m_shadowCatcherEntity->GetId(), &AZ::NonUniformScaleRequests::SetScale, AZ::Vector3{ 100, 100, 1.0 });
AZ::Data::AssetId shadowCatcherModelAssetId = RPI::AssetUtils::GetAssetIdForProductPath("materialeditor/viewportmodels/plane_1x1.azmodel", RPI::AssetUtils::TraceLevel::Error);
AZ::Render::MeshComponentRequestBus::Event(m_shadowCatcherEntity->GetId(),

@ -50,7 +50,7 @@ namespace AZ
AZStd::vector<Vector2> vertices = m_shapeBus->GetPolygonPrism()->m_vertexContainer.GetVertices();
Transform transform = GetTransform();
transform.SetScale(Vector3(transform.GetScale().GetMaxElement())); // Poly Prism only supports uniform scale, so use max element.
transform.SetUniformScale(transform.GetUniformScale()); // Poly Prism only supports uniform scale.
AZStd::vector<Vector3> transformedVertices;
transformedVertices.reserve(vertices.size());

@ -666,20 +666,12 @@ namespace Blast
MOCK_METHOD1(RotateAroundLocalZ, void(float));
MOCK_METHOD0(GetLocalRotation, AZ::Vector3());
MOCK_METHOD0(GetLocalRotationQuaternion, AZ::Quaternion());
MOCK_METHOD1(SetScale, void(const AZ::Vector3&));
MOCK_METHOD1(SetScaleX, void(float));
MOCK_METHOD1(SetScaleY, void(float));
MOCK_METHOD1(SetScaleZ, void(float));
MOCK_METHOD0(GetScale, AZ::Vector3());
MOCK_METHOD0(GetScaleX, float());
MOCK_METHOD0(GetScaleY, float());
MOCK_METHOD0(GetScaleZ, float());
MOCK_METHOD1(SetLocalScale, void(const AZ::Vector3&));
MOCK_METHOD1(SetLocalScaleX, void(float));
MOCK_METHOD1(SetLocalScaleY, void(float));
MOCK_METHOD1(SetLocalScaleZ, void(float));
MOCK_METHOD0(GetLocalScale, AZ::Vector3());
MOCK_METHOD0(GetWorldScale, AZ::Vector3());
MOCK_METHOD1(SetLocalUniformScale, void(float));
MOCK_METHOD0(GetLocalUniformScale, float());
MOCK_METHOD0(GetWorldUniformScale, float());
MOCK_METHOD0(GetParentId, AZ::EntityId());
MOCK_METHOD0(GetParent, TransformInterface*());
MOCK_METHOD1(SetParent, void(AZ::EntityId));

@ -1157,7 +1157,7 @@ namespace MCommon
void RenderUtil::RenderSphere(const AZ::Vector3& position, float radius, const MCore::RGBAColor& color)
{
// setup the world space matrix of the sphere
AZ::Transform sphereTransform = AZ::Transform::CreateScale(AZ::Vector3(radius, radius, radius));
AZ::Transform sphereTransform = AZ::Transform::CreateUniformScale(radius);
sphereTransform.SetTranslation(position);
// render the sphere

@ -14,6 +14,7 @@
#include <AzCore/Math/Aabb.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/Math/Matrix3x4.h>
#include <AzCore/Math/Transform.h>
#include <LmbrCentral/Shape/ShapeComponentBus.h>
@ -64,15 +65,15 @@ namespace GradientSignal
AZ::LerpInverse(bounds.GetMin().GetZ(), bounds.GetMax().GetZ(), point.GetZ()));
}
inline void GetObbParamsFromShape(const AZ::EntityId& entity, AZ::Aabb& bounds, AZ::Transform& worldToBoundsTransform)
inline void GetObbParamsFromShape(const AZ::EntityId& entity, AZ::Aabb& bounds, AZ::Matrix3x4& worldToBoundsTransform)
{
//get bound and transform data for associated shape
bounds = AZ::Aabb::CreateNull();
worldToBoundsTransform = AZ::Transform::CreateIdentity();
AZ::Transform transform = AZ::Transform::CreateIdentity();
if (entity.IsValid())
{
LmbrCentral::ShapeComponentRequestsBus::Event(entity, &LmbrCentral::ShapeComponentRequestsBus::Events::GetTransformAndLocalBounds, worldToBoundsTransform, bounds);
worldToBoundsTransform.Invert();
LmbrCentral::ShapeComponentRequestsBus::Event(entity, &LmbrCentral::ShapeComponentRequestsBus::Events::GetTransformAndLocalBounds, transform, bounds);
worldToBoundsTransform = AZ::Matrix3x4::CreateFromTransform(transform.GetInverse());
}
}

@ -334,7 +334,7 @@ namespace GradientSignal
AZStd::lock_guard<decltype(m_cacheMutex)> lock(m_cacheMutex);
//transforming coordinate into "local" relative space of shape bounds
outUVW = m_shapeTransformInverse.TransformPoint(inPosition);
outUVW = m_shapeTransformInverse * inPosition;
if (!m_configuration.m_advancedMode || !m_configuration.m_is3d)
{
@ -388,7 +388,7 @@ namespace GradientSignal
void GradientTransformComponent::GetGradientEncompassingBounds(AZ::Aabb& bounds) const
{
bounds = m_shapeBounds;
bounds.ApplyTransform(m_shapeTransformInverse.GetInverse());
bounds.ApplyMatrix3x4(m_shapeTransformInverse.GetInverseFull());
}
void GradientTransformComponent::OnCompositionChanged()
@ -501,10 +501,11 @@ namespace GradientSignal
m_shapeBounds = AZ::Aabb::CreateFromMinMax(-m_configuration.m_bounds * 0.5f, m_configuration.m_bounds * 0.5f);
//rebuild transform from parameters
AZ::Quaternion rotation;
rotation.SetFromEulerDegrees(m_configuration.m_rotate);
const AZ::Transform shapeTransformFinal(m_configuration.m_translate, rotation, m_configuration.m_scale);
m_shapeTransformInverse = shapeTransformFinal.GetInverse();
AZ::Matrix3x4 shapeTransformFinal;
shapeTransformFinal.SetFromEulerDegrees(m_configuration.m_rotate);
shapeTransformFinal.SetTranslation(m_configuration.m_translate);
shapeTransformFinal.MultiplyByScale(m_configuration.m_scale);
m_shapeTransformInverse = shapeTransformFinal.GetInverseFull();
}
AZ::EntityId GradientTransformComponent::GetShapeEntityId() const

@ -15,6 +15,7 @@
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Math/Aabb.h>
#include <AzCore/Math/Matrix3x4.h>
#include <AzCore/Math/Transform.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/std/parallel/atomic.h>
@ -172,7 +173,7 @@ namespace GradientSignal
mutable AZStd::recursive_mutex m_cacheMutex;
GradientTransformConfig m_configuration;
AZ::Aabb m_shapeBounds = AZ::Aabb::CreateNull();
AZ::Transform m_shapeTransformInverse = AZ::Transform::CreateIdentity();
AZ::Matrix3x4 m_shapeTransformInverse = AZ::Matrix3x4::CreateIdentity();
LmbrCentral::DependencyMonitor m_dependencyMonitor;
AZStd::atomic_bool m_dirty{ false };
};

@ -169,22 +169,24 @@ namespace LmbrCentral
{
AZ::TransformNotificationBus::MultiHandler::BusDisconnect(GetEntityId());
{
AZ::Transform currentTM = AZ::Transform::CreateIdentity();
EBUS_EVENT_ID_RESULT(currentTM, GetEntityId(), AZ::TransformBus, GetWorldTM);
AZ::Vector3 currentScale = currentTM.ExtractScale();
AZ::Transform sourceTM = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(sourceTM, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
AZ::Transform targetTM = AZ::Transform::CreateIdentity();
EBUS_EVENT_ID_RESULT(targetTM, m_targetId, AZ::TransformBus, GetWorldTM);
AZ::TransformBus::EventResult(targetTM, m_targetId, &AZ::TransformBus::Events::GetWorldTM);
AZ::Transform lookAtTransform = AZ::Transform::CreateLookAt(
currentTM.GetTranslation(),
sourceTM.GetTranslation(),
targetTM.GetTranslation(),
m_forwardAxis
);
lookAtTransform.MultiplyByScale(currentScale);
// update the rotation and translation for sourceTM based on lookAtTransform, but leave scale unchanged
sourceTM.SetRotation(lookAtTransform.GetRotation());
sourceTM.SetTranslation(lookAtTransform.GetTranslation());
EBUS_EVENT_ID(GetEntityId(), AZ::TransformBus, SetWorldTM, lookAtTransform);
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformBus::Events::SetWorldTM, sourceTM);
}
AZ::TransformNotificationBus::MultiHandler::BusConnect(GetEntityId());
}

@ -251,7 +251,7 @@ namespace LmbrCentral
const AZ::Transform& currentTransform, const BoxShapeConfig& configuration, const AZ::Vector3& currentNonUniformScale)
{
AZ::Transform worldFromLocalNormalized = currentTransform;
const float entityScale = worldFromLocalNormalized.ExtractScale().GetMaxElement();
const float entityScale = worldFromLocalNormalized.ExtractUniformScale();
m_currentPosition = worldFromLocalNormalized.GetTranslation();
m_scaledDimensions = configuration.m_dimensions * currentNonUniformScale * entityScale;

@ -434,8 +434,7 @@ namespace LmbrCentral
const AZ::Vector3& nonUniformScale = polygonPrism.GetNonUniformScale();
AZ::Transform worldFromLocalUniformScale = worldFromLocal;
const float entityScale = worldFromLocalUniformScale.ExtractScale().GetMaxElement();
worldFromLocalUniformScale *= AZ::Transform::CreateScale(AZ::Vector3(entityScale));
worldFromLocalUniformScale.SetUniformScale(worldFromLocalUniformScale.GetUniformScale());
AZ::Aabb aabb = AZ::Aabb::CreateNull();
// check base of prism
@ -465,8 +464,7 @@ namespace LmbrCentral
const size_t vertexCount = vertices.size();
AZ::Transform worldFromLocalWithUniformScale = worldFromLocal;
const float transformScale = worldFromLocalWithUniformScale.ExtractScale().GetMaxElement();
worldFromLocalWithUniformScale *= AZ::Transform::CreateScale(AZ::Vector3(transformScale));
worldFromLocalWithUniformScale.SetUniformScale(worldFromLocalWithUniformScale.GetUniformScale());
// transform point to local space
// it's fine to invert the transform including scale here, because it won't affect whether the point is inside the prism
@ -530,7 +528,7 @@ namespace LmbrCentral
// but inverting any scale in the transform would mess up the distance, so extract that first and apply scale separately to the
// prism
AZ::Transform worldFromLocalNoScale = worldFromLocal;
const float transformScale = worldFromLocalNoScale.ExtractScale().GetMaxElement();
const float transformScale = worldFromLocalNoScale.ExtractUniformScale();
const AZ::Vector3 combinedScale = transformScale * nonUniformScale;
const float scaledHeight = height * combinedScale.GetZ();
@ -606,9 +604,9 @@ namespace LmbrCentral
}
// transform ray into local space
AZ::Transform worldFromLocalNomalized = worldFromLocal;
const float entityScale = worldFromLocalNomalized.ExtractScale().GetMaxElement();
const AZ::Transform localFromWorldNormalized = worldFromLocalNomalized.GetInverse();
AZ::Transform worldFromLocalNormalized = worldFromLocal;
const float entityScale = worldFromLocalNormalized.ExtractUniformScale();
const AZ::Transform localFromWorldNormalized = worldFromLocalNormalized.GetInverse();
const float rayLength = 1000.0f;
const AZ::Vector3 localSrc = localFromWorldNormalized.TransformPoint(src);
const AZ::Vector3 localDir = localFromWorldNormalized.TransformVector(dir);

@ -44,8 +44,7 @@ namespace LmbrCentral
// only uniform scale is supported in physics so the debug visuals reflect this fact
AZ::Transform worldFromLocalWithUniformScale = worldFromLocal;
const AZ::Vector3 scale = worldFromLocalWithUniformScale.ExtractScale();
worldFromLocalWithUniformScale.MultiplyByScale(AZ::Vector3(scale.GetMaxElement()));
worldFromLocalWithUniformScale.SetUniformScale(worldFromLocalWithUniformScale.GetUniformScale());
debugDisplay.PushMatrix(worldFromLocalWithUniformScale);

@ -187,7 +187,7 @@ namespace LmbrCentral
static AZ::Aabb CalculateTubeBounds(const TubeShape& tubeShape, const AZ::Transform& transform)
{
const auto maxScale = transform.GetScale().GetMaxElement();
const auto maxScale = transform.GetUniformScale();
const auto scaledRadiusFn =
[&tubeShape, maxScale](const AZ::SplineAddress& splineAddress)
{
@ -217,8 +217,7 @@ namespace LmbrCentral
}
AZ::Transform worldFromLocalUniformScale = m_currentTransform;
const float maxScale = worldFromLocalUniformScale.ExtractScale().GetMaxElement();
worldFromLocalUniformScale *= AZ::Transform::CreateScale(AZ::Vector3(maxScale));
worldFromLocalUniformScale.SetUniformScale(worldFromLocalUniformScale.GetUniformScale());
return CalculateTubeBounds(*this, worldFromLocalUniformScale);
}
@ -237,45 +236,43 @@ namespace LmbrCentral
}
AZ::Transform worldFromLocalNormalized = m_currentTransform;
const AZ::Vector3 scale = AZ::Vector3(worldFromLocalNormalized.ExtractScale().GetMaxElement());
const float scale = worldFromLocalNormalized.ExtractUniformScale();
const AZ::Transform localFromWorldNormalized = worldFromLocalNormalized.GetInverse();
const AZ::Vector3 localPoint = localFromWorldNormalized.TransformPoint(point) * scale.GetReciprocal();
const AZ::Vector3 localPoint = localFromWorldNormalized.TransformPoint(point) / scale;
const auto address = m_spline->GetNearestAddressPosition(localPoint).m_splineAddress;
const float radiusSq = powf(m_radius, 2.0f);
const float variableRadiusSq =
powf(m_variableRadius.GetElementInterpolated(address, Lerpf), 2.0f);
return (m_spline->GetPosition(address) - localPoint).GetLengthSq() < (radiusSq + variableRadiusSq) *
scale.GetMaxElement();
return (m_spline->GetPosition(address) - localPoint).GetLengthSq() < (radiusSq + variableRadiusSq) * scale;
}
float TubeShape::DistanceSquaredFromPoint(const AZ::Vector3& point)
{
AZ::Transform worldFromLocalNormalized = m_currentTransform;
const AZ::Vector3 maxScale = AZ::Vector3(worldFromLocalNormalized.ExtractScale().GetMaxElement());
const float uniformScale = worldFromLocalNormalized.ExtractUniformScale();
const AZ::Transform localFromWorldNormalized = worldFromLocalNormalized.GetInverse();
const AZ::Vector3 localPoint = localFromWorldNormalized.TransformPoint(point) * maxScale.GetReciprocal();
const AZ::Vector3 localPoint = localFromWorldNormalized.TransformPoint(point) / uniformScale;
const auto splineQueryResult = m_spline->GetNearestAddressPosition(localPoint);
const float variableRadius =
m_variableRadius.GetElementInterpolated(splineQueryResult.m_splineAddress, Lerpf);
return powf((sqrtf(splineQueryResult.m_distanceSq) - (m_radius + variableRadius)) * maxScale.GetMaxElement(), 2.0f);
return powf((sqrtf(splineQueryResult.m_distanceSq) - (m_radius + variableRadius)) * uniformScale, 2.0f);
}
bool TubeShape::IntersectRay(const AZ::Vector3& src, const AZ::Vector3& dir, float& distance)
{
AZ::Transform transformUniformScale = m_currentTransform;
const float maxScale = transformUniformScale.ExtractScale().GetMaxElement();
transformUniformScale *= AZ::Transform::CreateScale(AZ::Vector3(maxScale));
transformUniformScale.SetUniformScale(transformUniformScale.GetUniformScale());
const auto splineQueryResult = IntersectSpline(transformUniformScale, src, dir, *m_spline);
const float variableRadius = m_variableRadius.GetElementInterpolated(
splineQueryResult.m_splineAddress, Lerpf);
const float totalRadius = m_radius + variableRadius;
distance = (splineQueryResult.m_rayDistance - totalRadius) * m_currentTransform.GetScale().GetMaxElement();
distance = (splineQueryResult.m_rayDistance - totalRadius) * m_currentTransform.GetUniformScale();
return static_cast<float>(sqrtf(splineQueryResult.m_distanceSq)) < totalRadius;
}

@ -262,7 +262,7 @@ namespace UnitTest
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisY(), AZ::Constants::QuarterPi),
AZ::Vector3(0.0f, 0.0f, 5.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(3.0f)),
AZ::Transform::CreateUniformScale(3.0f),
AZ::Vector3(2.0f, 4.0f, 1.0f), entity);
bool rayHit = false;
@ -295,7 +295,7 @@ namespace UnitTest
{
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateTranslation(AZ::Vector3(2.0f, -5.0f, 3.0f));
transform.MultiplyByScale(AZ::Vector3(0.5f));
transform.MultiplyByUniformScale(0.5f);
const AZ::Vector3 dimensions(2.2f, 1.8f, 0.4f);
const AZ::Vector3 nonUniformScale(0.2f, 2.6f, 1.2f);
CreateBoxWithNonUniformScale(transform, dimensions, nonUniformScale, entity);
@ -340,7 +340,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.50f, 0.10f, 0.02f, 0.86f), AZ::Vector3(4.0f, 1.0f, -2.0f));
transform.MultiplyByScale(AZ::Vector3(1.5f));
transform.MultiplyByUniformScale(1.5f);
const AZ::Vector3 dimensions(1.2f, 0.7f, 2.1f);
const AZ::Vector3 nonUniformScale(0.8f, 0.6f, 0.7f);
CreateBoxWithNonUniformScale(transform, dimensions, nonUniformScale, entity);
@ -433,7 +433,7 @@ namespace UnitTest
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisY(), AZ::Constants::QuarterPi),
AZ::Vector3::CreateZero()) *
AZ::Transform::CreateScale(AZ::Vector3(3.0f)),
AZ::Transform::CreateUniformScale(3.0f),
AZ::Vector3(2.0f, 4.0f, 1.0f), entity);
AZ::Aabb aabb;
@ -483,7 +483,7 @@ namespace UnitTest
AZ::Transform transformIn = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisX(), AZ::Constants::QuarterPi) * AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisY(), AZ::Constants::QuarterPi),
AZ::Vector3(9.0f, 11.0f, 13.0f));
transformIn.MultiplyByScale(AZ::Vector3(3.0f));
transformIn.MultiplyByUniformScale(3.0f);
CreateBox(transformIn, AZ::Vector3(1.5f, 3.5f, 5.5f), entity);
AZ::Transform transformOut;
@ -500,7 +500,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transformIn = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.62f, 0.62f, 0.14f, 0.46f), AZ::Vector3(0.8f, -1.2f, 2.7f));
transformIn.MultiplyByScale(AZ::Vector3(2.0f));
transformIn.MultiplyByUniformScale(2.0f);
const AZ::Vector3 nonUniformScale(1.5f, 2.0f, 0.4f);
const AZ::Vector3 boxDimensions(2.0f, 1.7f, 0.5f);
CreateBoxWithNonUniformScale(transformIn, nonUniformScale, boxDimensions, entity);
@ -531,7 +531,7 @@ namespace UnitTest
AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisZ(), AZ::Constants::QuarterPi),
AZ::Vector3(23.0f, 12.0f, 40.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(3.0f)),
AZ::Transform::CreateUniformScale(3.0f),
AZ::Vector3(2.0f, 6.0f, 3.5f), entity);
// test some pairs of nearby points which should be just either side of the surface of the box
@ -551,7 +551,7 @@ namespace UnitTest
AZ::Transform::CreateTranslation(AZ::Vector3(23.0f, 12.0f, 40.0f)) *
AZ::Transform::CreateRotationX(-AZ::Constants::QuarterPi) *
AZ::Transform::CreateRotationZ(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f)),
AZ::Transform::CreateUniformScale(2.0f),
AZ::Vector3(4.0f, 7.0f, 3.5f), entity);
// test some pairs of nearby points which should be just either side of the surface of the box
@ -588,14 +588,14 @@ namespace UnitTest
CreateBox(
AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 37.0f, 32.0f)) *
AZ::Transform::CreateRotationZ(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(3.0f, 1.0f, 1.0f)),
AZ::Vector3(4.0f, 2.0f, 10.0f), entity);
AZ::Transform::CreateUniformScale(2.0f),
AZ::Vector3(6.0f, 1.0f, 5.0f), entity);
float distance;
LmbrCentral::ShapeComponentRequestsBus::EventResult(
distance, entity.GetId(), &LmbrCentral::ShapeComponentRequests::DistanceFromPoint, AZ::Vector3(3.6356f, 30.636f, 40.0f));
distance, entity.GetId(), &LmbrCentral::ShapeComponentRequests::DistanceFromPoint, AZ::Vector3(4.0f, 33.5f, 38.0f));
EXPECT_NEAR(distance, 3.0f, 1e-2f);
EXPECT_NEAR(distance, 1.45f, 1e-2f);
}
// distance scaled
@ -606,14 +606,14 @@ namespace UnitTest
AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 37.0f, 32.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationY(AZ::Constants::HalfPi) *
AZ::Transform::CreateScale(AZ::Vector3(3.0f, 1.0f, 1.0f)),
AZ::Vector3(4.0f, 2.0f, 10.0f), entity);
AZ::Transform::CreateUniformScale(0.5f),
AZ::Vector3(24.0f, 4.0f, 20.0f), entity);
float distance;
LmbrCentral::ShapeComponentRequestsBus::EventResult(
distance, entity.GetId(), &LmbrCentral::ShapeComponentRequests::DistanceFromPoint, AZ::Vector3(10.0f, 37.0f, 48.0f));
EXPECT_NEAR(distance, 13.0f, 1e-2f);
EXPECT_NEAR(distance, 15.0f, 1e-2f);
}
TEST_F(BoxShapeTest, DistanceFromPointNonUniformScale)
@ -621,7 +621,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateRotationY(AZ::DegToRad(30.0f)), AZ::Vector3(3.0f, 4.0f, 5.0f));
transform.MultiplyByScale(AZ::Vector3(2.0f));
transform.MultiplyByUniformScale(2.0f);
const AZ::Vector3 dimensions(2.0f, 3.0f, 1.5f);
const AZ::Vector3 nonUniformScale(1.4f, 2.2f, 0.8f);
CreateBoxWithNonUniformScale(transform, nonUniformScale, dimensions, entity);
@ -638,7 +638,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.70f, 0.10f, 0.34f, 0.62f), AZ::Vector3(3.0f, -1.0f, 2.0f));
transform.MultiplyByScale(AZ::Vector3(2.0f));
transform.MultiplyByUniformScale(2.0f);
const AZ::Vector3 dimensions(1.2f, 0.8f, 1.7f);
const AZ::Vector3 nonUniformScale(2.4f, 1.3f, 1.8f);
CreateBoxWithNonUniformScale(transform, nonUniformScale, dimensions, entity);

@ -144,7 +144,7 @@ namespace UnitTest
CreateCapsule(
AZ::Transform::CreateTranslation(AZ::Vector3(-4.0f, -12.0f, -3.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateScale(AZ::Vector3(6.0f)),
AZ::Transform::CreateUniformScale(6.0f),
0.25f, 1.5f, entity);
bool rayHit = false;
@ -208,7 +208,7 @@ namespace UnitTest
TEST_F(CapsuleShapeTest, GetAabb3)
{
AZ::Entity entity;
CreateCapsule(AZ::Transform::CreateScale(AZ::Vector3(3.5f)), 2.0f, 4.0f, entity);
CreateCapsule(AZ::Transform::CreateUniformScale(3.5f), 2.0f, 4.0f, entity);
AZ::Aabb aabb;
LmbrCentral::ShapeComponentRequestsBus::EventResult(
@ -224,7 +224,7 @@ namespace UnitTest
AZ::Entity entity;
CreateCapsule(
AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 20.0f, 0.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.5f)), 1.0f, 5.0f, entity);
AZ::Transform::CreateUniformScale(2.5f), 1.0f, 5.0f, entity);
AZ::Aabb aabb;
LmbrCentral::ShapeComponentRequestsBus::EventResult(
@ -255,7 +255,7 @@ namespace UnitTest
AZ::Transform transformIn = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisX(), AZ::Constants::HalfPi) *
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisY(), AZ::Constants::QuarterPi), AZ::Vector3(-10.0f, -10.0f, 0.0f));
transformIn.MultiplyByScale(AZ::Vector3(3.0f));
transformIn.MultiplyByUniformScale(3.0f);
CreateCapsule(transformIn, 5.0f, 2.0f, entity);
AZ::Transform transformOut;
@ -273,7 +273,7 @@ namespace UnitTest
AZ::Transform transformIn = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisX(), AZ::Constants::HalfPi) *
AZ::Quaternion::CreateFromAxisAngle(AZ::Vector3::CreateAxisY(), AZ::Constants::QuarterPi), AZ::Vector3(-10.0f, -10.0f, 0.0f));
transformIn.MultiplyByScale(AZ::Vector3(3.0f));
transformIn.MultiplyByUniformScale(3.0f);
CreateCapsule(transformIn, 2.0f, 5.0f, entity);
AZ::Transform transformOut;
@ -291,7 +291,7 @@ namespace UnitTest
AZ::Entity entity;
CreateCapsule(
AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.5f, 1.0f, 1.0f)), // test max scale
AZ::Transform::CreateUniformScale(2.5f),
0.5f, 2.0f, entity);
bool inside;
@ -309,7 +309,7 @@ namespace UnitTest
AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationY(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(0.5f)),
AZ::Transform::CreateUniformScale(0.5f),
0.5f, 2.0f, entity);
bool inside;
@ -327,7 +327,7 @@ namespace UnitTest
AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationY(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f)),
AZ::Transform::CreateUniformScale(2.0f),
0.5f, 4.0f, entity);
float distance;
@ -345,7 +345,7 @@ namespace UnitTest
AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationY(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f)),
AZ::Transform::CreateUniformScale(2.0f),
0.5f, 4.0f, entity);
float distance;

@ -138,7 +138,7 @@ namespace UnitTest
{ AZ::Transform::CreateTranslation(AZ::Vector3(-14.0f, -14.0f, -1.0f)) *
AZ::Transform::CreateRotationY(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationZ(AZ::Constants::HalfPi) *
AZ::Transform::CreateScale(AZ::Vector3(4.0f)),
AZ::Transform::CreateUniformScale(4.0f),
1.0f, 1.25f },
// Result: hit, distance, epsilon
{ true, 2.5f, 1e-2f }
@ -203,7 +203,7 @@ namespace UnitTest
// Test case 2
{ // Cylinder: transform, radius, height
{ AZ::Transform::CreateTranslation(AZ::Vector3(-10.0f, -10.0f, 10.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(3.5f)),
AZ::Transform::CreateUniformScale(3.5f),
1.0f, 5.0f },
// AABB: min, max
{ AZ::Vector3(-13.5f, -13.5f, 1.25f), AZ::Vector3(-6.5f, -6.5f, 18.75f) } },
@ -236,7 +236,7 @@ namespace UnitTest
{ AZ::Vector3(-5.0f, -5.0f, -0.5f), AZ::Vector3(5.0f, 5.0f, 0.5f) } },
// Test case 1
{ // Cylinder: transform, radius, height
{ AZ::Transform::CreateTranslation(AZ::Vector3(-10.0f, -10.0f, 10.0f)) * AZ::Transform::CreateScale(AZ::Vector3(3.5f)),
{ AZ::Transform::CreateTranslation(AZ::Vector3(-10.0f, -10.0f, 10.0f)) * AZ::Transform::CreateUniformScale(3.5f),
5.0f, 5.0f },
// Local bounds: min, max
{ AZ::Vector3(-5.0f, -5.0f, -2.5f), AZ::Vector3(5.0f, 5.0f, 2.5f) } },
@ -264,7 +264,7 @@ namespace UnitTest
// Test case 0
{ // Cylinder: transform, radius, height
{AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.5f, 1.0f, 1.0f)), // test max scale
AZ::Transform::CreateUniformScale(2.5f),
0.5f, 2.0f},
// Point
AZ::Vector3(27.0f, 28.5f, 40.0f),
@ -275,7 +275,7 @@ namespace UnitTest
{AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationY(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(0.5f)),
AZ::Transform::CreateUniformScale(0.5f),
0.5f, 2.0f},
// Point
AZ::Vector3(27.0f, 28.155f, 37.82f),
@ -316,7 +316,7 @@ namespace UnitTest
{ AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationY(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f)),
AZ::Transform::CreateUniformScale(2.0f),
0.5f, 4.0f },
// Point
AZ::Vector3(27.0f, 28.0f, 41.0f),
@ -327,7 +327,7 @@ namespace UnitTest
{ AZ::Transform::CreateTranslation(AZ::Vector3(27.0f, 28.0f, 38.0f)) *
AZ::Transform::CreateRotationX(AZ::Constants::HalfPi) *
AZ::Transform::CreateRotationY(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f)),
AZ::Transform::CreateUniformScale(2.0f),
0.5f, 4.0f },
// Point
AZ::Vector3(22.757f, 32.243f, 38.0f),

@ -307,7 +307,7 @@ namespace UnitTest
AZ::Entity entity;
CreateDisk(
AZ::Transform::CreateTranslation(AZ::Vector3(100.0f, 200.0f, 300.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.5f)),
AZ::Transform::CreateUniformScale(2.5f),
0.5f, entity);
AZ::Aabb aabb;

@ -329,7 +329,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateRotationY(AZ::DegToRad(45.0f)), AZ::Vector3(3.0f, 4.0f, 5.0f));
transform.MultiplyByScale(AZ::Vector3(1.5f, 1.5f, 1.5f));
transform.MultiplyByUniformScale(1.5f);
const float height = 1.2f;
const AZ::Vector3 nonUniformScale(2.0f, 1.2f, 0.5f);
const AZStd::vector<AZ::Vector2> vertices =
@ -447,7 +447,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateRotationY(AZ::DegToRad(45.0f)), AZ::Vector3(3.0f, 4.0f, 5.0f));
transform.MultiplyByScale(AZ::Vector3(1.5f, 1.5f, 1.5f));
transform.MultiplyByUniformScale(1.5f);
const float height = 1.2f;
const AZ::Vector3 nonUniformScale(2.0f, 1.2f, 0.5f);
const AZStd::vector<AZ::Vector2> vertices =
@ -608,7 +608,7 @@ namespace UnitTest
AZ::Entity entity;
CreatePolygonPrism(
AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 40.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(3.0f)), 2.0f,
AZ::Transform::CreateUniformScale(3.0f), 2.0f,
AZStd::vector<AZ::Vector2>(
{
AZ::Vector2(-2.0f, -2.0f),
@ -669,7 +669,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateRotationY(AZ::DegToRad(60.0f)), AZ::Vector3(1.0f, 2.5f, -1.0f));
transform.MultiplyByScale(AZ::Vector3(2.0f, 2.0f, 2.0f));
transform.MultiplyByUniformScale(2.0f);
const float height = 1.5f;
const AZ::Vector3 nonUniformScale(0.5f, 1.5f, 2.0f);
@ -772,7 +772,7 @@ namespace UnitTest
AZ::Entity entity;
CreatePolygonPrism(
AZ::Transform::CreateTranslation(AZ::Vector3(5.0f, 15.0f, 40.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(3.0f)), 1.5f,
AZ::Transform::CreateUniformScale(3.0f), 1.5f,
AZStd::vector<AZ::Vector2>(
{
AZ::Vector2(-2.0f, -2.0f),
@ -795,7 +795,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion::CreateRotationX(AZ::DegToRad(30.0f)), AZ::Vector3(2.0f, -5.0f, 3.0f));
transform.MultiplyByScale(AZ::Vector3(2.0f, 2.0f, 2.0f));
transform.MultiplyByUniformScale(2.0f);
const float height = 1.2f;
const AZ::Vector3 nonUniformScale(1.5f, 0.8f, 2.0f);
const AZStd::vector<AZ::Vector2> vertices =

@ -188,7 +188,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transformIn = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.46f, 0.34f, 0.02f, 0.82f), AZ::Vector3(1.7f, -0.4f, 2.3f));
transformIn.MultiplyByScale(AZ::Vector3(2.2f));
transformIn.MultiplyByUniformScale(2.2f);
const AZ::Vector3 nonUniformScale(0.8f, 0.6f, 1.3f);
const float width = 0.7f;
const float height = 1.3f;
@ -327,7 +327,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.64f, 0.16f, 0.68f, 0.32f), AZ::Vector3(0.4f, -2.3f, -0.9f));
transform.MultiplyByScale(AZ::Vector3(1.3f));
transform.MultiplyByUniformScale(1.3f);
const AZ::Vector3 nonUniformScale(0.7f, 0.5f, 1.3f);
const float width = 0.9f;
const float height = 1.3f;
@ -384,7 +384,7 @@ namespace UnitTest
AZ::Entity entity;
CreateQuad(
AZ::Transform::CreateTranslation(AZ::Vector3(100.0f, 200.0f, 300.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.5f)),
AZ::Transform::CreateUniformScale(2.5f),
1.0f, 2.0f, entity);
AZ::Aabb aabb;
@ -425,7 +425,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.44f, 0.24f, 0.48f, 0.72f), AZ::Vector3(3.4f, 1.2f, -2.8f));
transform.MultiplyByScale(AZ::Vector3(1.5f));
transform.MultiplyByUniformScale(1.5f);
const AZ::Vector3 nonUniformScale(1.2f, 1.1f, 0.8f);
const float width = 1.2f;
const float height = 1.7f;
@ -518,7 +518,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.24f, 0.72f, 0.44f, 0.48f), AZ::Vector3(2.7f, 2.3f, -1.8f));
transform.MultiplyByScale(AZ::Vector3(1.2f));
transform.MultiplyByUniformScale(1.2f);
const AZ::Vector3 nonUniformScale(0.4f, 2.2f, 1.3f);
const float width = 1.6f;
const float height = 0.7f;
@ -546,7 +546,7 @@ namespace UnitTest
AZ::Entity entity;
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(
AZ::Quaternion(0.70f, 0.10f, 0.34f, 0.62f), AZ::Vector3(3.0f, -1.0f, 2.0f));
transform.MultiplyByScale(AZ::Vector3(2.0f));
transform.MultiplyByUniformScale(2.0f);
const AZ::Vector3 nonUniformScale(2.4f, 1.3f, 1.8f);
const float width = 0.8f;
const float height = 1.4f;

@ -179,7 +179,7 @@ namespace UnitTest
AZ::Entity entity;
CreateSphere(
AZ::Transform::CreateTranslation(AZ::Vector3(-8.0f, -15.0f, 5.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(5.0f)),
AZ::Transform::CreateUniformScale(5.0f),
0.25f, entity);
bool rayHit = false;
@ -240,7 +240,7 @@ namespace UnitTest
AZ::Entity entity;
CreateSphere(
AZ::Transform::CreateTranslation(AZ::Vector3(100.0f, 200.0f, 300.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.5f)),
AZ::Transform::CreateUniformScale(2.5f),
0.5f, entity);
AZ::Aabb aabb;
@ -269,7 +269,7 @@ namespace UnitTest
TEST_F(SphereShapeTest, GetTransformAndLocalBounds2)
{
AZ::Entity entity;
AZ::Transform transformIn = AZ::Transform::CreateTranslation(AZ::Vector3(100.0f, 200.0f, 300.0f)) * AZ::Transform::CreateScale(AZ::Vector3(2.5f));
AZ::Transform transformIn = AZ::Transform::CreateTranslation(AZ::Vector3(100.0f, 200.0f, 300.0f)) * AZ::Transform::CreateUniformScale(2.5f);
CreateSphere(transformIn, 2.0f, entity);
AZ::Transform transformOut;
@ -287,7 +287,7 @@ namespace UnitTest
AZ::Entity entity;
CreateSphere(
AZ::Transform::CreateTranslation(AZ::Vector3(-30.0f, -30.0f, 22.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f)),
AZ::Transform::CreateUniformScale(2.0f),
1.2f, entity);
bool inside;
@ -303,7 +303,7 @@ namespace UnitTest
AZ::Entity entity;
CreateSphere(
AZ::Transform::CreateTranslation(AZ::Vector3(-30.0f, -30.0f, 22.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(1.5f)),
AZ::Transform::CreateUniformScale(1.5f),
1.6f, entity);
bool inside;
@ -319,7 +319,7 @@ namespace UnitTest
AZ::Entity entity;
CreateSphere(
AZ::Transform::CreateTranslation(AZ::Vector3(19.0f, 34.0f, 37.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f)),
AZ::Transform::CreateUniformScale(2.0f),
1.0f, entity);
float distance;
@ -335,7 +335,7 @@ namespace UnitTest
AZ::Entity entity;
CreateSphere(
AZ::Transform::CreateTranslation(AZ::Vector3(19.0f, 34.0f, 37.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(0.5f)),
AZ::Transform::CreateUniformScale(0.5f),
1.0f, entity);
float distance;

@ -139,7 +139,7 @@ namespace UnitTest
AZ::Entity entity;
CreateTube(
AZ::Transform::CreateTranslation(AZ::Vector3(-40.0f, 6.0f, 1.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.5f, 1.0f, 1.0f)), // test max scale
AZ::Transform::CreateUniformScale(2.5f),
1.0f,
entity);
@ -232,7 +232,7 @@ namespace UnitTest
TEST_F(TubeShapeTest, GetAabb4)
{
AZ::Entity entity;
CreateTube(AZ::Transform::CreateScale(AZ::Vector3(1.0f, 1.0f, 2.0f)), 1.0f, entity);
CreateTube(AZ::Transform::CreateUniformScale(2.0f), 1.0f, entity);
// set variable radius
LmbrCentral::TubeShapeComponentRequestsBus::Event(
@ -254,7 +254,7 @@ namespace UnitTest
AZ::Entity entity;
CreateTube(
AZ::Transform::CreateTranslation(AZ::Vector3(37.0f, 36.0f, 32.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(1.0f, 2.0f, 1.0f)), 1.5f, entity);
AZ::Transform::CreateUniformScale(2.0f), 1.5f, entity);
// set variable radius
LmbrCentral::TubeShapeComponentRequestsBus::Event(
@ -277,7 +277,7 @@ namespace UnitTest
AZ::Transform::CreateTranslation(AZ::Vector3(37.0f, 36.0f, 32.0f)) *
AZ::Transform::CreateRotationZ(AZ::Constants::QuarterPi) *
AZ::Transform::CreateRotationY(AZ::Constants::QuarterPi) *
AZ::Transform::CreateScale(AZ::Vector3(0.8f, 1.5f, 1.5f)), 1.5f, entity);
AZ::Transform::CreateUniformScale(1.5f), 1.5f, entity);
// set variable radius
LmbrCentral::TubeShapeComponentRequestsBus::Event(
@ -302,7 +302,7 @@ namespace UnitTest
AZ::Entity entity;
CreateTube(
AZ::Transform::CreateTranslation(AZ::Vector3(37.0f, 36.0f, 39.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f, 1.5f, 1.5f)), 1.5f, entity);
AZ::Transform::CreateUniformScale(2.0f), 1.5f, entity);
LmbrCentral::TubeShapeComponentRequestsBus::Event(
entity.GetId(), &LmbrCentral::TubeShapeComponentRequestsBus::Events::SetVariableRadius, 0, 1.0f);
@ -326,7 +326,7 @@ namespace UnitTest
AZ::Entity entity;
CreateTube(
AZ::Transform::CreateTranslation(AZ::Vector3(37.0f, 36.0f, 39.0f)) *
AZ::Transform::CreateScale(AZ::Vector3(2.0f, 1.5f, 1.5f)), 1.5f, entity);
AZ::Transform::CreateUniformScale(2.0f), 1.5f, entity);
LmbrCentral::TubeShapeComponentRequestsBus::Event(
entity.GetId(), &LmbrCentral::TubeShapeComponentRequestsBus::Events::SetVariableRadius, 0, 1.0f);

@ -201,9 +201,8 @@ namespace PhysX
AZ::Quaternion newRotation = AZ::Quaternion::CreateIdentity();
m_interpolator->GetInterpolated(newPosition, newRotation, deltaTime);
AZ::Transform interpolatedTransform = AZ::Transform::CreateFromQuaternionAndTranslation(newRotation, newPosition);
interpolatedTransform.MultiplyByScale(m_initialScale);
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformInterface::SetWorldTM, interpolatedTransform);
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformInterface::SetRotationQuaternion, newRotation);
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformInterface::SetWorldTranslation, newPosition);
}
}
@ -257,12 +256,8 @@ namespace PhysX
}
else
{
// Maintain scale (this must be precise).
AZ::Transform entityTransform = AZ::Transform::Identity();
AZ::TransformBus::EventResult(entityTransform, GetEntityId(), &AZ::TransformInterface::GetWorldTM);
transform.MultiplyByScale(m_initialScale);
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformInterface::SetWorldTM, transform);
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformInterface::SetRotationQuaternion, rigidBody->GetOrientation());
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformInterface::SetWorldTranslation, rigidBody->GetPosition());
}
m_isLastMovementFromKinematicSource = false;
}
@ -353,8 +348,6 @@ namespace PhysX
m_interpolator = std::make_unique<TransformForwardTimeInterpolator>();
m_interpolator->Reset(transform.GetTranslation(), rotation);
m_initialScale = transform.ExtractScale();
Physics::RigidBodyNotificationBus::Event(GetEntityId(), &Physics::RigidBodyNotificationBus::Events::OnPhysicsEnabled);
}

@ -161,7 +161,6 @@ namespace PhysX
AzPhysics::SimulatedBodyHandle m_rigidBodyHandle = AzPhysics::InvalidSimulatedBodyHandle;
AzPhysics::SceneHandle m_attachedSceneHandle = AzPhysics::InvalidSceneHandle;
AZ::Vector3 m_initialScale = AZ::Vector3::CreateOne();
bool m_staticTransformAtActivation = false; ///< Whether the transform was static when the component last activated.
bool m_isLastMovementFromKinematicSource = false; ///< True when the source of the movement comes from SetKinematicTarget as opposed to coming from a Transform change
bool m_rigidBodyTransformNeedsUpdateOnPhysReEnable = false; ///< True if rigid body transform needs to be synced to the entity's when physics is re-enabled

@ -68,7 +68,7 @@ namespace PhysXEditorTests
AZ::EntityId editorId = editorEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.5f));
worldTM.SetUniformScale(1.5f);
worldTM.SetTranslation(AZ::Vector3(5.0f, 6.0f, 7.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationX(AZ::DegToRad(30.0f)));
AZ::TransformBus::Event(editorId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -99,7 +99,7 @@ namespace PhysXEditorTests
AZ::EntityId editorId = editorEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.5f));
worldTM.SetUniformScale(1.5f);
worldTM.SetTranslation(AZ::Vector3(5.0f, 6.0f, 7.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationX(AZ::DegToRad(30.0f)));
AZ::TransformBus::Event(editorId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -144,7 +144,7 @@ namespace PhysXEditorTests
AZ::EntityId capsuleId = editorEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(0.5f));
worldTM.SetUniformScale(0.5f);
worldTM.SetTranslation(AZ::Vector3(3.0f, 1.0f, -4.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationY(AZ::DegToRad(90.0f)));
AZ::TransformBus::Event(capsuleId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -176,7 +176,7 @@ namespace PhysXEditorTests
AZ::EntityId capsuleId = editorEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(0.5f));
worldTM.SetUniformScale(0.5f);
worldTM.SetTranslation(AZ::Vector3(3.0f, 1.0f, -4.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationY(AZ::DegToRad(90.0f)));
AZ::TransformBus::Event(capsuleId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -222,7 +222,7 @@ namespace PhysXEditorTests
AZ::EntityId sphereId = editorEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.2f));
worldTM.SetUniformScale(1.2f);
worldTM.SetTranslation(AZ::Vector3(-2.0f, -1.0f, 3.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)));
AZ::TransformBus::Event(sphereId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -254,7 +254,7 @@ namespace PhysXEditorTests
AZ::EntityId sphereId = editorEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.2f));
worldTM.SetUniformScale(1.2f);
worldTM.SetTranslation(AZ::Vector3(-2.0f, -1.0f, 3.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)));
AZ::TransformBus::Event(sphereId, &AZ::TransformBus::Events::SetWorldTM, worldTM);

@ -32,7 +32,7 @@ namespace PhysXEditorTests
AZ::EntityId boxId = boxEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.5f));
worldTM.SetUniformScale(1.5f);
worldTM.SetTranslation(AZ::Vector3(5.0f, 6.0f, 7.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationX(AZ::DegToRad(30.0f)));
AZ::TransformBus::Event(boxId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -61,7 +61,7 @@ namespace PhysXEditorTests
AZ::EntityId boxId = boxEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.2f));
worldTM.SetUniformScale(1.2f);
worldTM.SetTranslation(AZ::Vector3(4.0f, -3.0f, 1.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationZ(AZ::DegToRad(45.0f)));
AZ::TransformBus::Event(boxId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -91,7 +91,7 @@ namespace PhysXEditorTests
AZ::EntityId boxId = boxEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.2f));
worldTM.SetUniformScale(1.2f);
worldTM.SetTranslation(AZ::Vector3(4.0f, -3.0f, 1.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationZ(AZ::DegToRad(45.0f)));
AZ::TransformBus::Event(boxId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -129,7 +129,7 @@ namespace PhysXEditorTests
AZ::EntityId capsuleId = capsuleEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(0.5f));
worldTM.SetUniformScale(0.5f);
worldTM.SetTranslation(AZ::Vector3(3.0f, 1.0f, -4.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationY(AZ::DegToRad(90.0f)));
AZ::TransformBus::Event(capsuleId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -158,7 +158,7 @@ namespace PhysXEditorTests
AZ::EntityId capsuleId = capsuleEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.4f));
worldTM.SetUniformScale(1.4f);
worldTM.SetTranslation(AZ::Vector3(1.0f, -4.0f, 4.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationX(AZ::DegToRad(45.0f)));
AZ::TransformBus::Event(capsuleId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -189,7 +189,7 @@ namespace PhysXEditorTests
AZ::EntityId sphereId = sphereEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(1.2f));
worldTM.SetUniformScale(1.2f);
worldTM.SetTranslation(AZ::Vector3(-2.0f, -1.0f, 3.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)));
AZ::TransformBus::Event(sphereId, &AZ::TransformBus::Events::SetWorldTM, worldTM);
@ -218,7 +218,7 @@ namespace PhysXEditorTests
AZ::EntityId sphereId = sphereEntity->GetId();
AZ::Transform worldTM;
worldTM.SetScale(AZ::Vector3(0.8f));
worldTM.SetUniformScale(0.8f);
worldTM.SetTranslation(AZ::Vector3(2.0f, -1.0f, 3.0f));
worldTM.SetRotation(AZ::Quaternion::CreateRotationY(AZ::DegToRad(45.0f)));
AZ::TransformBus::Event(sphereId, &AZ::TransformBus::Events::SetWorldTM, worldTM);

@ -93,39 +93,43 @@ namespace PhysXEditorTests
editorEntity->CreateComponent<PhysX::EditorShapeColliderComponent>();
editorEntity->CreateComponent(LmbrCentral::EditorCylinderShapeComponentTypeId);
editorEntity->Activate();
{
UnitTest::ErrorHandler warningHandler("Negative or zero cylinder dimensions are invalid");
UnitTest::ErrorHandler dimensionWarningHandler("Negative or zero cylinder dimensions are invalid");
UnitTest::ErrorHandler colliderWarningHandler("No Collider or Shape information found when creating Rigid body");
LmbrCentral::CylinderShapeComponentRequestsBus::Event(editorEntity->GetId(),
&LmbrCentral::CylinderShapeComponentRequests::SetRadius, radius);
// expect 2 warnings
//1 if the radius is invalid
//2 when re-creating the underlying simulated body
int expectedWarningCount = radius <= 0.f ? 2 : 0;
EXPECT_EQ(warningHandler.GetWarningCount(), expectedWarningCount);
int expectedWarningCount = radius <= 0.f ? 1 : 0;
EXPECT_EQ(dimensionWarningHandler.GetExpectedWarningCount(), expectedWarningCount);
EXPECT_EQ(colliderWarningHandler.GetExpectedWarningCount(), expectedWarningCount);
}
{
UnitTest::ErrorHandler warningHandler("Negative or zero cylinder dimensions are invalid");
UnitTest::ErrorHandler dimensionWarningHandler("Negative or zero cylinder dimensions are invalid");
UnitTest::ErrorHandler colliderWarningHandler("No Collider or Shape information found when creating Rigid body");
LmbrCentral::CylinderShapeComponentRequestsBus::Event(editorEntity->GetId(),
&LmbrCentral::CylinderShapeComponentRequests::SetHeight, height);
// expect 2 warnings
//1 if the radius or height is invalid
//2 when re-creating the underlying simulated body
int expectedWarningCount = radius <= 0.f || height <= 0.f ? 2 : 0;
EXPECT_EQ(warningHandler.GetWarningCount(), expectedWarningCount);
int expectedWarningCount = radius <= 0.f || height <= 0.f ? 1 : 0;
EXPECT_EQ(dimensionWarningHandler.GetExpectedWarningCount(), expectedWarningCount);
EXPECT_EQ(colliderWarningHandler.GetExpectedWarningCount(), expectedWarningCount);
}
EntityPtr gameEntity = CreateActiveGameEntityFromEditorEntity(editorEntity.get());
// since there was no editor rigid body component, the runtime entity should have a static rigid body
const auto* staticBody = azdynamic_cast<PhysX::StaticRigidBody*>(gameEntity->FindComponent<PhysX::StaticRigidBodyComponent>()->GetSimulatedBody());
const auto* pxRigidStatic = static_cast<const physx::PxRigidStatic*>(staticBody->GetNativePointer());
PHYSX_SCENE_READ_LOCK(pxRigidStatic->getScene());
// there should be no shapes on the rigid body because the cylinder radius and/or height is invalid
EXPECT_EQ(pxRigidStatic->getNbShapes(), 0);
}

@ -38,8 +38,8 @@ namespace PhysXEditorTests
const AZ::Aabb originalAabb = rigidBodyComponent->GetRigidBody()->GetAabb();
// Update the scale
const AZ::Vector3 scale(2.0f);
AZ::TransformBus::Event(editorEntity->GetId(), &AZ::TransformInterface::SetLocalScale, scale);
float scale = 2.0f;
AZ::TransformBus::Event(editorEntity->GetId(), &AZ::TransformInterface::SetLocalUniformScale, scale);
// Trigger editor physics world update so EditorRigidBodyComponent can process scale change
auto* physicsSystem = AZ::Interface<AzPhysics::SystemInterface>::Get();
@ -89,8 +89,8 @@ namespace PhysXEditorTests
idPair, &PhysX::EditorColliderComponentRequests::SetColliderOffset, offset);
// Update the scale
const AZ::Vector3 scale(2.0f);
AZ::TransformBus::Event(editorEntity->GetId(), &AZ::TransformInterface::SetLocalScale, scale);
float scale = 2.0f;
AZ::TransformBus::Event(editorEntity->GetId(), &AZ::TransformInterface::SetLocalUniformScale, scale);
// Update editor world to let updates to be applied
physicsSystem->Simulate(0.1f);

@ -241,7 +241,7 @@ namespace PhysXEditorTests
SetPolygonPrismHeight(entityId, 2.0f);
// update the transform scale and non-uniform scale
AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetScale, AZ::Vector3(2.0f));
AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalUniformScale, 2.0f);
AZ::NonUniformScaleRequestBus::Event(entityId, &AZ::NonUniformScaleRequests::SetScale, AZ::Vector3(0.5f, 1.5f, 2.0f));
EntityPtr gameEntity = CreateActiveGameEntityFromEditorEntity(editorEntity.get());
@ -347,6 +347,7 @@ namespace PhysXEditorTests
TEST_F(PhysXEditorFixture, EditorShapeColliderComponent_ShapeColliderWithUnsupportedShape_HandledGracefully)
{
UnitTest::ErrorHandler unsupportedShapeWarningHandler("Unsupported shape");
UnitTest::ErrorHandler rigidBodyWarningHandler("No Collider or Shape information found when creating Rigid body");
// create an editor entity with a shape collider component and a cylinder shape component
// the cylinder shape is not currently supported by the shape collider component
@ -355,10 +356,8 @@ namespace PhysXEditorTests
editorEntity->CreateComponent(LmbrCentral::EditorCompoundShapeComponentTypeId);
editorEntity->Activate();
// expect 2 warnings
//1 raised for the unsupported shape
//2 when re-creating the underlying simulated body
EXPECT_EQ(unsupportedShapeWarningHandler.GetWarningCount(), 2);
EXPECT_EQ(unsupportedShapeWarningHandler.GetExpectedWarningCount(), 1);
EXPECT_EQ(rigidBodyWarningHandler.GetExpectedWarningCount(), 1);
EntityPtr gameEntity = CreateActiveGameEntityFromEditorEntity(editorEntity.get());
@ -435,8 +434,8 @@ namespace PhysXEditorTests
&LmbrCentral::BoxShapeComponentRequests::GetBoxDimensions);
// update the transform
const AZ::Vector3 scale(2.0f);
AZ::TransformBus::Event(editorEntityId, &AZ::TransformInterface::SetLocalScale, scale);
const float scale = 2.0f;
AZ::TransformBus::Event(editorEntityId, &AZ::TransformInterface::SetLocalUniformScale, scale);
const AZ::Vector3 translation(10.0f, 20.0f, 30.0f);
AZ::TransformBus::Event(editorEntityId, &AZ::TransformInterface::SetWorldTranslation, translation);
@ -527,10 +526,8 @@ namespace PhysXEditorTests
editorParentEntity->Activate();
// set some scale to parent entity
const AZ::Vector3 parentScale(2.0f);
AZ::TransformBus::Event(editorParentEntity->GetId(),
&AZ::TransformInterface::SetLocalScale,
parentScale);
const float parentScale = 2.0f;
AZ::TransformBus::Event(editorParentEntity->GetId(), &AZ::TransformInterface::SetLocalUniformScale, parentScale);
// create an editor child entity with a shape collider component and a box shape component
EntityPtr editorChildEntity = CreateInactiveEditorEntity("ChildEntity");

@ -47,21 +47,10 @@ namespace ScriptCanvas
AZ::Transform currentTransform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(currentTransform, targetEntity, &AZ::TransformInterface::GetWorldTM);
AZ::Vector3 position = currentTransform.GetTranslation();
AZ::Quaternion currentRotation = currentTransform.GetRotation();
currentTransform.SetRotation((rotation * currentTransform.GetRotation().GetNormalized()));
AZ::Quaternion newRotation = (rotation * currentRotation);
newRotation.Normalize();
AZ::Transform newTransform = AZ::Transform::CreateIdentity();
newTransform.SetScale(currentTransform.GetScale());
newTransform.SetRotation(newRotation);
newTransform.SetTranslation(position);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, newTransform);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, currentTransform);
}
}

@ -44,22 +44,12 @@ namespace ScriptCanvas
{
AZ::Quaternion rotation = AZ::ConvertEulerDegreesToQuaternion(angles);
AZ::Transform currentTransform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(currentTransform, targetEntity, &AZ::TransformInterface::GetWorldTM);
AZ::Transform transform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(transform, targetEntity, &AZ::TransformInterface::GetWorldTM);
AZ::Vector3 position = currentTransform.GetTranslation();
AZ::Quaternion currentRotation = currentTransform.GetRotation();
transform.SetRotation((rotation * transform.GetRotation()).GetNormalized());
AZ::Quaternion newRotation = (rotation * currentRotation);
newRotation.Normalize();
AZ::Transform newTransform = AZ::Transform::CreateIdentity();
newTransform.CreateScale(currentTransform.ExtractScale());
newTransform.SetRotation(newRotation);
newTransform.SetTranslation(position);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, newTransform);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, transform);
}
}
}

@ -58,19 +58,9 @@ namespace Camera
float axisPolarity = m_shouldInvertAxis ? -1.0f : 1.0f;
float rotationAmount = axisPolarity * m_rotationAmount;
// remove translation and scale
AZ::Vector3 translation = outLookAtTargetTransform.GetTranslation();
outLookAtTargetTransform.SetTranslation(AZ::Vector3::CreateZero());
AZ::Vector3 transformScale = outLookAtTargetTransform.ExtractScale();
// perform our rotation
AZ::Transform desiredRotationTransform = AZ::Transform::CreateFromQuaternion(AZ::Quaternion::CreateFromAxisAngle(outLookAtTargetTransform.GetBasis(m_axisOfRotation), rotationAmount));
outLookAtTargetTransform = desiredRotationTransform * outLookAtTargetTransform;
// return scale and translate
outLookAtTargetTransform.SetScale(transformScale);
outLookAtTargetTransform.SetTranslation(translation);
AZ::Quaternion desiredRotation = AZ::Quaternion::CreateFromAxisAngle(
outLookAtTargetTransform.GetBasis(m_axisOfRotation), rotationAmount);
outLookAtTargetTransform.SetRotation(desiredRotation * outLookAtTargetTransform.GetRotation());
}
void RotateCameraLookAt::Activate(AZ::EntityId entityId)

@ -4,23 +4,57 @@
Welcome to the Project Spectra Private Preview. This is a confidential pre-release project; your use is subject to the nondisclosure agreement between you (or your organization) and Amazon. Do not disclose the existence of this project, your participation in it, or any of the materials provided, to any unauthorized third party. To request access for a third party, please contact [Royal O'Brien, obriroya@amazon.com](mailto:obriroya@amazon.com).
## Full instructions can be found here:
### https://docs.o3de.org/docs/welcome-guide/setup/setup-from-github/
(Note: Contact Royal or [Doug Erickson, dougeric@amazon.com](mailto:dougeric@amazon.com) for access)
## Updates to this readme
May 14, 2021
- Removed instructions for the 3rdParty zip file and downloader URL. This is no longer a requirement.
- Updated instructions for dependencies
- Links to full documentation
April 7-13, 2021
- Updates to the 3rdParty zip file
March 25, 2021
- Initial commit for instructions
## Download and Install
This repository uses Git LFS for storing large binary files. You will need to create a Github personal access token to authenticate with the LFS service.
To install Git LFS, download the binary here: https://git-lfs.github.com/.
After installation, you will need to install the necessary git hooks with this command
```
git lfs install
```
### Create a Git Personal Access Token
You will need your personal access token credentials to authenticate when you clone the repository.
You will need your personal access token credentials to authenticate when you clone the repository and when downloading objects from Git LFS
[Create a personal access token with the 'repo' scope.](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
During the clone operation, you will be prompted to enter a password. Your token will be used as the password. You will also be prompted a second time for Git LFS.
### (Recommended) Verify you have a credential manager installed to store your credentials
Recent versions of Git install a credential manager to store your credentials so you don't have to put in the credentials for every request.
Recent versions of Git install a credential manager to store your credentials so you don't have to put in the credentials for every request.
It is highly recommended you check that you have a [credential manager installed and configured](https://github.com/microsoft/Git-Credential-Manager-Core)
For Linux and Mac, use the following commands to store credentials
Linux:
```
git config --global credential.helper cache
```
Mac:
```
git config --global credential.helper osxkeychain
```
### Clone the repository
@ -43,67 +77,96 @@ Filtering content: 100% (3853/3853), 621.43 MiB | 881.00 KiB/s, done.
```
If you have the Git credential manager core installed, you should not be prompted for your credentials anymore.
If you have the Git credential manager core or other credential helpers installed, you should not be prompted for your credentials anymore.
## Building the Engine
### Build Requirements and redistributables
#### Windows
* Visual Studio 2019 16.9.2 (All versions supported, including Community): [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/)
* Visual Studio 2019 16.9.2 minimum (All versions supported, including Community): [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/)
* Install the following workloads:
* Game Development with C++
* MSVC v142 - VS 2019 C++ x64/x86
* Visual C++ redistributable: [https://visualstudio.microsoft.com/downloads/#other-family](https://visualstudio.microsoft.com/downloads/#other-family)
* FBXSDK for VS2015: [https://www.autodesk.com/developer-network/platform-technologies/fbx-sdk-2016-1-2](https://www.autodesk.com/developer-network/platform-technologies/fbx-sdk-2016-1-2)
* WWise - 2019.2.8.7432: [https://www.audiokinetic.com/download/](https://www.audiokinetic.com/download/)
* CMake 3.19.1: [https://cmake.org/files/LatestRelease/cmake-3.19.1-win64-x64.msi](https://cmake.org/files/LatestRelease/cmake-3.19.1-win64-x64.msi)
* C++ 2019 redistributable update
* CMake 3.19.1 minimum: [https://cmake.org/files/LatestRelease/cmake-3.19.1-win64-x64.msi](https://cmake.org/files/LatestRelease/cmake-3.19.1-win64-x64.msi)
#### Optional
### Build Steps
* WWise - 2019.2.8.7432 minimum: [https://www.audiokinetic.com/download/](https://www.audiokinetic.com/download/)
* Note: This requires registration and installation of a client to download
* You will also need to set a environment variable: `set LY_WWISE_INSTALL_PATH=<path to WWise version>`
* For example: `set LY_WWISE_INSTALL_PATH="C:\Program Files (x86)\Audiokinetic\Wwise 2019.2.8.7432"`
1. Download the 3rdParty zip file from here: **[https://d2c171ws20a1rv.cloudfront.net/3rdParty-windows-no-symbols-rev13.zip](https://d2c171ws20a1rv.cloudfront.net/3rdParty-windows-no-symbols-rev13.zip)**
2. Unzip this file into a writable folder. This will also act as a cache location for the 3rdParty downloader by default (configurable with the `LY_PACKAGE_DOWNLOAD_CACHE_LOCATION` environment variable)
3. Install the following redistributables to the following:
### Quick Start Build Steps
1. Create a writable folder to cache 3rd Party dependencies. You can also use this to store other redistributable SDKs.
> For the 0.5 branch - Create an empty text file named `3rdParty.txt` in this folder, to allow a legacy CMake validator to pass
1. Install the following redistributables to the following:
- Visual Studio and VC++ redistributable can be installed to any location
- FBXSDK should be installed to `<3rdParty path>\FbxSdk\2016.1.2-az.1`. See the README in this folder for details
- WWise should be installed to: `<3rdParty Path>\Wwise\2019.2.8.7432`
- CMake should be installed to: `<3rdParty Path>\CMake\3.19.1`
4. Add the following environment variables through the command line
- CMake can be installed to any location, as long as it's available in the system path, otherwise it can be installed to: `<3rdParty Path>\CMake\3.19.1`
- WWise can be installed anywhere, but you will need to set an environment variable for CMake to detect it: `set LY_WWISE_INSTALL_PATH=<path to WWise>`
1. Navigate into the repo folder, then download the python runtime with this command
> For the 0.5 branch - Set this environment variable prior to the `get_python` command below:
> ```
> set LY_PACKAGE_SERVER_URLS=https://d2c171ws20a1rv.cloudfront.net
> ```
```
set LY_3RDPARTY_PATH=<Location of the unzipped 3rdParty zip>
set LY_PACKAGE_SERVER_URLS="https://d2c171ws20a1rv.cloudfront.net"
python\get_python.bat
```
5. Configure the source into a solution using this command line, replacing <your build location> to a path you've created
1. While still within the repo folder, register the engine with this command:
```
cmake -B <your build location> -S <source-dir> -G "Visual Studio 16 2019" -DLY_3RDPARTY_PATH=%LY_3RDPARTY_PATH% -DLY_UNITY_BUILD=ON -DLY_PROJECTS=AutomatedTesting
scripts\o3de.bat register --this-engine
```
6. Alternatively, you can do this through the CMake GUI:
1. Configure the source into a solution using this command line, replacing <your build path> and <3rdParty cache path> to a path you've created:
```
cmake -B <your build path> -S <your source path> -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path> -DLY_UNITY_BUILD=ON -DLY_PROJECTS=AutomatedTesting
```
> Note: Do not use trailing slashes for the <3rdParty cache path>
1. Alternatively, you can do this through the CMake GUI:
1. Start `cmake-gui.exe`
2. Select the local path of the repo under "Where is the source code"
3. Select a path where to build binaries under "Where to build the binaries"
4. Click "Configure"
5. Wait for the key values to populate. Fill in the fields that are relevant, including `LY_3RDPARTY_PATH`, `LY_PACKAGE_SERVER_URLS`, and `LY_PROJECTS`
6. Click "Generate"
1. Select the local path of the repo under "Where is the source code"
1. Select a path where to build binaries under "Where to build the binaries"
1. Click "Configure"
1. Wait for the key values to populate. Fill in the fields that are relevant, including `LY_3RDPARTY_PATH` and `LY_PROJECTS`
1. Click "Generate"
7. The configuration of the solution is complete. To build the Editor and AssetProcessor to binaries, run this command inside your repo:
1. The configuration of the solution is complete. To build the Editor and AssetProcessor to binaries, run this command inside your repo:
```
cmake --build <your build location> --target AutomatedTesting.GameLauncher AssetProcessor Editor --config profile -- /m
cmake --build <your build path> --target AutomatedTesting.GameLauncher AssetProcessor Editor --config profile -- /m
```
8. This will compile after some time and binaries will be available in the build path you've specified
1. This will compile after some time and binaries will be available in the build path you've specified
### Setting up new projects
1. Setup new projects using this command
1. Setup new projects using the `o3de create-project` command. In the 0.5 branch, the project directory must be a subdirectory in the repo folder.
```
<Repo path>\scripts\o3de.bat create-project --project-path <New project path>
<Repo path>\scripts\o3de.bat create-project --project-path <your new project path>
```
2. Once you're ready to build the project, run the same set of commands to configure and build:
1. Register the engine to the project
```
cmake -B <your build location> -S <source-dir> -G "Visual Studio 16 2019" -DLY_3RDPARTY_PATH=%LY_3RDPARTY_PATH% -DLY_PROJECTS=<New project name> -DLY_MONOLITHIC_GAME=1
<Repo path>\scripts\o3de.bat register --project-path <New project path>
```
1. Once you're ready to build the project, run the same set of commands to configure and build:
```
cmake -B <your project build path> -S <your new project source path> -G "Visual Studio 16" -DLY_3RDPARTY_PATH=<3rdParty cache path>
cmake --build <your build location> --target <New Project Name> --config profile -- /m
// For the 0.5 branch, you must build a new Editor for each project:
cmake --build <your project build path> --target <New Project Name> Editor --config profile -- /m
// For all other branches, just build the project:
cmake --build <your project build path> --target <New Project Name> --config profile -- /m
```
For a tutorial on project configuration, see [Creating Projects Using the Command Line](https://docs.o3de.org/docs/welcome-guide/get-started/project-config/creating-projects-using-cli) in the documentation.
## License

@ -243,7 +243,7 @@ class Validator(object):
validations += 1
counter += 1
# Trim out whitelisted subdirectories in the current directory if allowed
# Trim out allowlisted subdirectories in the current directory if allowed
for name in bypassed_directories:
if name in dirnames:
dirnames.remove(name)

Loading…
Cancel
Save