fix physx editor tests

This commit is contained in:
greerdv
2021-05-24 21:38:53 +01:00
parent 047000862d
commit adb37b4a76
6 changed files with 64 additions and 41 deletions
@@ -130,7 +130,7 @@ namespace AZ
const Transform* transform = reinterpret_cast<const Transform*>(classPtr);
float data[NumFloats];
transform->GetRotation().StoreToFloat4(data);
Vector3(transform->GetScale()).StoreToFloat3(&data[4]);
transform->GetScale().StoreToFloat3(&data[4]);
transform->GetTranslation().StoreToFloat3(&data[7]);
for (int i = 0; i < NumFloats; i++)
@@ -220,7 +220,7 @@ namespace AZ
Vector3 translation = Vector3::CreateFromFloat3(&data[7]);
*reinterpret_cast<Transform*>(classPtr) =
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateUniformScale(scale.GetMaxElement());
Transform::CreateFromQuaternionAndTranslation(rotation, translation) * Transform::CreateScale(scale);
return true;
}
@@ -321,7 +321,7 @@ namespace AZ
{
Transform result;
Matrix3x3 tmp = value;
result.m_scale = tmp.ExtractScale().GetMaxElement();
result.m_scale = tmp.ExtractScale();
result.m_rotation = Quaternion::CreateFromMatrix3x3(tmp);
result.m_translation = Vector3::CreateZero();
return result;
@@ -331,7 +331,7 @@ namespace AZ
{
Transform result;
Matrix3x3 tmp = value;
result.m_scale = tmp.ExtractScale().GetMaxElement();
result.m_scale = tmp.ExtractScale();
result.m_rotation = Quaternion::CreateFromMatrix3x3(tmp);
result.m_translation = p;
return result;
@@ -341,7 +341,7 @@ namespace AZ
{
Transform result;
Matrix3x4 tmp = value;
result.m_scale = tmp.ExtractScale().GetMaxElement();
result.m_scale = tmp.ExtractScale();
result.m_rotation = Quaternion::CreateFromMatrix3x4(tmp);
result.m_translation = value.GetTranslation();
return result;
@@ -168,7 +168,7 @@ namespace AZ
private:
Quaternion m_rotation;
float m_scale;
Vector3 m_scale;
Vector3 m_translation;
};
+29 -29
View File
@@ -25,7 +25,7 @@ namespace AZ
{
Transform result;
result.m_rotation = Quaternion::CreateIdentity();
result.m_scale = 1.0f;
result.m_scale = Vector3::CreateOne();
result.m_translation = Vector3::CreateZero();
return result;
}
@@ -49,7 +49,7 @@ namespace AZ
{
Transform result;
result.m_rotation = q;
result.m_scale = 1.0f;
result.m_scale = Vector3::CreateOne();
result.m_translation = Vector3::CreateZero();
return result;
}
@@ -58,17 +58,17 @@ namespace AZ
{
Transform result;
result.m_rotation = q;
result.m_scale = 1.0f;
result.m_scale = Vector3::CreateOne();
result.m_translation = p;
return result;
}
AZ_MATH_INLINE Transform Transform::CreateScale(const AZ::Vector3& scale)
AZ_MATH_INLINE Transform Transform::CreateScale(const Vector3& scale)
{
AZ_Warning("Transform", false, "CreateScale is deprecated, please use CreateUniformScale instead.");
Transform result;
result.m_rotation = Quaternion::CreateIdentity();
result.m_scale = scale.GetMaxElement();
result.m_scale = scale;
result.m_translation = Vector3::CreateZero();
return result;
}
@@ -77,7 +77,7 @@ namespace AZ
{
Transform result;
result.m_rotation = Quaternion::CreateIdentity();
result.m_scale = scale;
result.m_scale = Vector3(scale);
result.m_translation = Vector3::CreateZero();
return result;
}
@@ -86,7 +86,7 @@ namespace AZ
{
Transform result;
result.m_rotation = Quaternion::CreateIdentity();
result.m_scale = 1.0f;
result.m_scale = Vector3::CreateOne();
result.m_translation = translation;
return result;
}
@@ -114,17 +114,17 @@ namespace AZ
AZ_MATH_INLINE Vector3 Transform::GetBasisX() const
{
return m_rotation.TransformVector(Vector3::CreateAxisX(m_scale));
return m_rotation.TransformVector(Vector3::CreateAxisX(m_scale.GetX()));
}
AZ_MATH_INLINE Vector3 Transform::GetBasisY() const
{
return m_rotation.TransformVector(Vector3::CreateAxisY(m_scale));
return m_rotation.TransformVector(Vector3::CreateAxisY(m_scale.GetY()));
}
AZ_MATH_INLINE Vector3 Transform::GetBasisZ() const
{
return m_rotation.TransformVector(Vector3::CreateAxisZ(m_scale));
return m_rotation.TransformVector(Vector3::CreateAxisZ(m_scale.GetZ()));
}
AZ_MATH_INLINE void Transform::GetBasisAndTranslation(Vector3* basisX, Vector3* basisY, Vector3* basisZ, Vector3* pos) const
@@ -163,44 +163,44 @@ namespace AZ
AZ_MATH_INLINE Vector3 Transform::GetScale() const
{
AZ_Warning("Transform", false, "GetScale is deprecated, please use GetUniformScale instead.");
return Vector3(m_scale);
return m_scale;
}
AZ_MATH_INLINE float Transform::GetUniformScale() const
{
return m_scale;
return m_scale.GetMaxElement();
}
AZ_MATH_INLINE void Transform::SetScale(const Vector3& scale)
{
AZ_Warning("Transform", false, "SetScale is deprecated, please use SetUniformScale instead.");
m_scale = scale.GetMaxElement();
m_scale = scale;
}
AZ_MATH_INLINE void Transform::SetUniformScale(const float scale)
{
m_scale = scale;
m_scale = Vector3(scale);
}
AZ_MATH_INLINE Vector3 Transform::ExtractScale()
{
AZ_Warning("Transform", false, "ExtractScale is deprecated, please use ExtractUniformScale instead.");
const float scale = m_scale;
m_scale = 1.0f;
return Vector3(scale);
const Vector3 scale = m_scale;
m_scale = Vector3::CreateOne();
return scale;
}
AZ_MATH_INLINE float Transform::ExtractUniformScale()
{
const float scale = m_scale;
m_scale = 1.0f;
const float scale = m_scale.GetMaxElement();
m_scale = Vector3::CreateOne();
return scale;
}
AZ_MATH_INLINE void Transform::MultiplyByScale(const AZ::Vector3& scale)
AZ_MATH_INLINE void Transform::MultiplyByScale(const Vector3& scale)
{
AZ_Warning("Transform", false, "MultiplyByScale is deprecated, please use MultiplyByUniformScale instead.");
m_scale *= scale.GetMaxElement();
m_scale *= scale;
}
AZ_MATH_INLINE void Transform::MultiplyByUniformScale(float scale)
@@ -243,7 +243,7 @@ namespace AZ
// note - need to be careful about how to calculate inverse when there is non-uniform scale
Transform out;
out.m_rotation = m_rotation.GetConjugate();
out.m_scale = 1.0f / m_scale;
out.m_scale = m_scale.GetReciprocal();
out.m_translation = -out.m_scale * (out.m_rotation.TransformVector(m_translation));
return out;
}
@@ -255,27 +255,27 @@ namespace AZ
AZ_MATH_INLINE bool Transform::IsOrthogonal(float tolerance) const
{
return AZ::IsClose(m_scale, 1.0f, tolerance);
return m_scale.IsClose(Vector3::CreateOne(), tolerance);
}
AZ_MATH_INLINE Transform Transform::GetOrthogonalized() const
{
Transform result;
result.m_rotation = m_rotation;
result.m_scale = 1.0f;
result.m_scale = Vector3::CreateOne();
result.m_translation = m_translation;
return result;
}
AZ_MATH_INLINE void Transform::Orthogonalize()
{
m_scale = 1.0f;
m_scale = Vector3::CreateOne();
}
AZ_MATH_INLINE bool Transform::IsClose(const Transform& rhs, float tolerance) const
{
return m_rotation.IsClose(rhs.m_rotation, tolerance)
&& AZ::IsClose(m_scale, rhs.m_scale, tolerance)
&& m_scale.IsClose(rhs.m_scale, tolerance)
&& m_translation.IsClose(rhs.m_translation, tolerance);
}
@@ -304,21 +304,21 @@ namespace AZ
AZ_MATH_INLINE void Transform::SetFromEulerDegrees(const Vector3& eulerDegrees)
{
m_translation = Vector3::CreateZero();
m_scale = 1.0f;
m_scale = Vector3::CreateOne();
m_rotation.SetFromEulerDegrees(eulerDegrees);
}
AZ_MATH_INLINE void Transform::SetFromEulerRadians(const Vector3& eulerRadians)
{
m_translation = Vector3::CreateZero();
m_scale = 1.0f;
m_scale = Vector3::CreateOne();
m_rotation.SetFromEulerRadians(eulerRadians);
}
AZ_MATH_INLINE bool Transform::IsFinite() const
{
return m_rotation.IsFinite()
&& IsFiniteFloat(m_scale)
&& m_scale.IsFinite()
&& m_translation.IsFinite();
}
@@ -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;
};
}
@@ -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());