Removed leftover MCore::Quaternion usages and fixes some include issues

Signed-off-by: Benjamin Jillich <jillich@amazon.com>
monroegm-disable-blank-issue-2
Benjamin Jillich 4 years ago
parent 5bb8a17d79
commit aa98be18b7

@ -8,7 +8,7 @@
#include "RotateManipulator.h"
#include <MCore/Source/AzCoreConversions.h>
#include <MCore/Source/PlaneEq.h>
namespace MCommon
{

@ -10,6 +10,7 @@
#define __EMSTUDIO_LOGWINDOWPLUGIN_H
#if !defined(Q_MOC_RUN)
#include <MCore/Source/LogManager.h>
#include "../StandardPluginsConfig.h"
#include "../../../../EMStudioSDK/Source/DockWidgetPlugin.h"
#endif

@ -17,6 +17,7 @@
#include <AzCore/Math/PackedVector3.h>
#include <MCore/Source/Algorithms.h>
#include <MCore/Source/Color.h>
#include <MCore/Source/Vector.h>
#include <MCore/Source/Quaternion.h>
#include <EMotionFX/Source/Transform.h>
@ -37,18 +38,6 @@ namespace MCore
return RGBAColor(static_cast<float>(azColor.GetR()), static_cast<float>(azColor.GetG()), static_cast<float>(azColor.GetB()), static_cast<float>(azColor.GetA()));
}
// Deprecated
AZ_FORCE_INLINE AZ::Quaternion EmfxQuatToAzQuat(const MCore::Quaternion& emfxQuat)
{
return AZ::Quaternion(emfxQuat.x, emfxQuat.y, emfxQuat.z, emfxQuat.w);
}
// Deprecated
AZ_FORCE_INLINE MCore::Quaternion AzQuatToEmfxQuat(const AZ::Quaternion& azQuat)
{
return MCore::Quaternion(azQuat.GetX(), azQuat.GetY(), azQuat.GetZ(), azQuat.GetW());
}
AZ_FORCE_INLINE AZ::Transform EmfxTransformToAzTransform(const EMotionFX::Transform& emfxTransform)
{
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(emfxTransform.mRotation, emfxTransform.mPosition);
@ -530,91 +519,4 @@ namespace MCore
AZ::Vector3ToVector4(m33.GetRow(2), translation.GetZ()),
mat.GetRow(3));
}
// Deprecated. Please use AZ::Transform instead of MCore::Matrix.
MCORE_INLINE AZ::Quaternion MCoreMatrixToQuaternion(const MCore::Matrix& m)
{
const float trace = MMAT(m, 0, 0) + MMAT(m, 1, 1) + MMAT(m, 2, 2);
if (trace > 0.0f /*Math::epsilon*/)
{
const float s = 0.5f / Math::Sqrt(trace + 1.0f);
return AZ::Quaternion((MMAT(m, 1, 2) - MMAT(m, 2, 1)) * s,
(MMAT(m, 2, 0) - MMAT(m, 0, 2)) * s,
(MMAT(m, 0, 1) - MMAT(m, 1, 0)) * s,
0.25f / s);
}
else
{
if (MMAT(m, 0, 0) > MMAT(m, 1, 1) && MMAT(m, 0, 0) > MMAT(m, 2, 2))
{
const float s = 2.0f * Math::Sqrt(1.0f + MMAT(m, 0, 0) - MMAT(m, 1, 1) - MMAT(m, 2, 2));
const float oneOverS = 1.0f / s;
return AZ::Quaternion(0.25f * s,
(MMAT(m, 1, 0) + MMAT(m, 0, 1)) * oneOverS,
(MMAT(m, 2, 0) + MMAT(m, 0, 2)) * oneOverS,
(MMAT(m, 1, 2) - MMAT(m, 2, 1)) * oneOverS);
}
else if (MMAT(m, 1, 1) > MMAT(m, 2, 2))
{
const float s = 2.0f * Math::Sqrt(1.0f + MMAT(m, 1, 1) - MMAT(m, 0, 0) - MMAT(m, 2, 2));
const float oneOverS = 1.0f / s;
return AZ::Quaternion((MMAT(m, 1, 0) + MMAT(m, 0, 1)) * oneOverS,
0.25f * s,
(MMAT(m, 2, 1) + MMAT(m, 1, 2)) * oneOverS,
(MMAT(m, 2, 0) - MMAT(m, 0, 2)) * oneOverS);
}
else
{
const float s = 2.0f * Math::Sqrt(1.0f + MMAT(m, 2, 2) - MMAT(m, 0, 0) - MMAT(m, 1, 1));
const float oneOverS = 1.0f / s;
return AZ::Quaternion((MMAT(m, 2, 0) + MMAT(m, 0, 2)) * oneOverS,
(MMAT(m, 2, 1) + MMAT(m, 1, 2)) * oneOverS,
0.25f * s,
(MMAT(m, 0, 1) - MMAT(m, 1, 0)) * oneOverS);
}
}
/*
const float trace = MMAT(m,0,0) + MMAT(m,1,1) + MMAT(m,2,2) + 1.0f;
if (trace > Math::epsilon)
{
const float s = 0.5f / Math::Sqrt(trace);
result.w = 0.25f / s;
result.x = ( MMAT(m,1,2) - MMAT(m,2,1) ) * s;
result.y = ( MMAT(m,2,0) - MMAT(m,0,2) ) * s;
result.z = ( MMAT(m,0,1) - MMAT(m,1,0) ) * s;
}
else
{
if (MMAT(m,0,0) > MMAT(m,1,1) && MMAT(m,0,0) > MMAT(m,2,2))
{
const float s = 2.0f * Math::Sqrt( 1.0f + MMAT(m,0,0) - MMAT(m,1,1) - MMAT(m,2,2));
const float oneOverS = 1.0f / s;
result.x = 0.25f * s;
result.y = (MMAT(m,1,0) + MMAT(m,0,1) ) * oneOverS;
result.z = (MMAT(m,2,0) + MMAT(m,0,2) ) * oneOverS;
result.w = (MMAT(m,2,1) - MMAT(m,1,2) ) * oneOverS;
}
else
if (MMAT(m,1,1) > MMAT(m,2,2))
{
const float s = 2.0f * Math::Sqrt( 1.0f + MMAT(m,1,1) - MMAT(m,0,0) - MMAT(m,2,2));
const float oneOverS = 1.0f / s;
result.x = (MMAT(m,1,0) + MMAT(m,0,1) ) * oneOverS;
result.y = 0.25f * s;
result.z = (MMAT(m,2,1) + MMAT(m,1,2) ) * oneOverS;
result.w = (MMAT(m,2,0) - MMAT(m,0,2) ) * oneOverS;
}
else
{
const float s = 2.0f * Math::Sqrt( 1.0f + MMAT(m,2,2) - MMAT(m,0,0) - MMAT(m,1,1) );
const float oneOverS = 1.0f / s;
result.x = (MMAT(m,2,0) + MMAT(m,0,2) ) * oneOverS;
result.y = (MMAT(m,2,1) + MMAT(m,1,2) ) * oneOverS;
result.z = 0.25f * s;
result.w = (MMAT(m,1,0) - MMAT(m,0,1) ) * oneOverS;
}
}
*/
}
} // namespace MCore

@ -2248,27 +2248,6 @@ namespace MCore
}
// simple decompose a matrix into translation and rotation
void Matrix::Decompose(AZ::Vector3* outTranslation, AZ::Quaternion* outRotation) const
{
// make a copy of the matrix
Matrix mat(*this);
// normalize the basis vectors
mat.SetRight(SafeNormalize(mat.GetRight()));
mat.SetUp(SafeNormalize(mat.GetUp()));
mat.SetForward(SafeNormalize(mat.GetForward()));
// extract the translation from the matrix
*outTranslation = mat.GetTranslation();
// convert the normalized 3x3 rotation part into a AZ::Quaternion
*outRotation = MCore::MCoreMatrixToQuaternion(*this);
}
// calculate a rotation matrix from two vectors
void Matrix::SetRotationMatrixTwoVectors(const AZ::Vector3& from, const AZ::Vector3& to)
{
@ -2365,30 +2344,6 @@ namespace MCore
}
//
void Matrix::DecomposeQRGramSchmidt(AZ::Vector3& translation, AZ::Quaternion& rot, AZ::Vector3& scale, AZ::Vector3& shear) const
{
Matrix rotMatrix;
DecomposeQRGramSchmidt(translation, rotMatrix, scale, shear);
rot = MCore::MCoreMatrixToQuaternion(*this);
}
//
void Matrix::DecomposeQRGramSchmidt(AZ::Vector3& translation, AZ::Quaternion& rot, AZ::Vector3& scale) const
{
Matrix rotMatrix;
DecomposeQRGramSchmidt(translation, rotMatrix, scale);
rot = MCore::MCoreMatrixToQuaternion(rotMatrix);
}
//
void Matrix::DecomposeQRGramSchmidt(AZ::Vector3& translation, AZ::Quaternion& rot) const
{
Matrix rotMatrix;
DecomposeQRGramSchmidt(translation, rotMatrix);
rot = MCore::MCoreMatrixToQuaternion(rotMatrix);
}
//

@ -685,26 +685,11 @@ namespace MCore
*/
void Frustum(float left, float right, float top, float bottom, float znear, float zfar);
/**
* Decompose a transformation matrix into translation and rotation components.
* The translation part is just the translation part of the matrix.
* The rotation AZ::Quaternion is calculated by normalizing the basis vectors and converting the
* 3x3 rotation part of the matrix to a AZ::Quaternion.
* It is allowed for the matrix to contain scaling.
* The matrix where you call Decompose on remains unchanged.
* @param outTranslation A pointer to a vector where the translation will be written to.
* @param outRotation A pointer to a AZ::Quaternion where the rotation will be written to.
* @note Please keep in mind that nullptr values for the parameters are NOT allowed.
*/
void Decompose(AZ::Vector3* outTranslation, AZ::Quaternion* outRotation) const;
// QR Gram-Schmidt decomposition
void DecomposeQRGramSchmidt(AZ::Vector3& translation, AZ::Quaternion& rot) const;
void DecomposeQRGramSchmidt(AZ::Vector3& translation, Matrix& rot) const;
void DecomposeQRGramSchmidt(AZ::Vector3& translation, Matrix& rot, AZ::Vector3& scale) const;
void DecomposeQRGramSchmidt(AZ::Vector3& translation, Matrix& rot, AZ::Vector3& scale, AZ::Vector3& shear) const;
void DecomposeQRGramSchmidt(AZ::Vector3& translation, AZ::Quaternion& rot, AZ::Vector3& scale, AZ::Vector3& shear) const;
void DecomposeQRGramSchmidt(AZ::Vector3& translation, AZ::Quaternion& rot, AZ::Vector3& scale) const;
static Matrix OuterProduct(const AZ::Vector4& column, const AZ::Vector4& row);

Loading…
Cancel
Save