fix aztoolsframework tests
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -84,7 +84,10 @@ 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);
|
||||
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;
|
||||
|
||||
@@ -432,17 +432,14 @@ 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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+8
-8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user