Update return type for viewport screen functions (#5803)

* update return type for viewport screen functions

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* add tests for AZ::Matrix3x4::CreateFromMatrix4x4 and add TransformPoint to Matrix3x4

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update NDC -> Ndc

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* updates following review feedback

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* updates and improvements following PR feedback

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* add forward declaration of Matrix3x4 type

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update where forward declarations are defined for Matrix3x4

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
This commit is contained in:
Tom Hulton-Harrop
2021-11-24 09:17:43 +00:00
committed by GitHub
parent b196473465
commit 5bd751531d
20 changed files with 146 additions and 74 deletions
@@ -351,7 +351,8 @@ namespace AZ
->Method("CreateFromMatrix3x3AndTranslation", &Matrix3x4::CreateFromMatrix3x3AndTranslation)
->Method("CreateScale", &Matrix3x4::CreateScale)
->Method("CreateDiagonal", &Matrix3x4::CreateDiagonal)
->Method("CreateTranslation", &Matrix3x4::CreateTranslation);
->Method("CreateTranslation", &Matrix3x4::CreateTranslation)
->Method("UnsafeCreateFromMatrix4x4", &Matrix3x4::UnsafeCreateFromMatrix4x4);
}
}
@@ -90,6 +90,9 @@ namespace AZ
//! Constructs from a Matrix3x3 and a translation.
static Matrix3x4 CreateFromMatrix3x3AndTranslation(const Matrix3x3& matrix3x3, const Vector3& translation);
//! Constructs from a Matrix4x4.
static Matrix3x4 UnsafeCreateFromMatrix4x4(const Matrix4x4& matrix4x4);
//! Constructs from a Transform.
static Matrix3x4 CreateFromTransform(const Transform& transform);
@@ -227,7 +230,7 @@ namespace AZ
Matrix3x4& operator+=(const Matrix3x4& rhs);
//! @}
//! Operator for matrix-matrix substraction.
//! Operator for matrix-matrix subtraction.
//! @{
[[nodiscard]] Matrix3x4 operator-(const Matrix3x4& rhs) const;
Matrix3x4& operator-=(const Matrix3x4& rhs);
@@ -266,6 +269,9 @@ namespace AZ
//! Post-multiplies the matrix by a vector, using only the 3x3 part of the matrix.
[[nodiscard]] Vector3 TransformVector(const Vector3& rhs) const;
//! Post-multiplies the matrix by a point, using the rotation and translation part of the matrix.
[[nodiscard]] Vector3 TransformPoint(const Vector3& rhs) const;
//! Gets the result of transposing the 3x3 part of the matrix, setting the translation part to zero.
[[nodiscard]] Matrix3x4 GetTranspose() const;
@@ -203,6 +203,16 @@ namespace AZ
}
AZ_MATH_INLINE Matrix3x4 Matrix3x4::UnsafeCreateFromMatrix4x4(const Matrix4x4& matrix4x4)
{
Matrix3x4 result;
result.SetRow(0, matrix4x4.GetRow(0));
result.SetRow(1, matrix4x4.GetRow(1));
result.SetRow(2, matrix4x4.GetRow(2));
return result;
}
AZ_MATH_INLINE Matrix3x4 Matrix3x4::CreateScale(const Vector3& scale)
{
return CreateDiagonal(scale);
@@ -609,6 +619,12 @@ namespace AZ
}
AZ_MATH_INLINE Vector3 Matrix3x4::TransformPoint(const Vector3& rhs) const
{
return Multiply3x3(rhs) + GetTranslation();
}
AZ_MATH_INLINE Matrix3x4 Matrix3x4::GetTranspose() const
{
Matrix3x4 result;