From 6ae92d5056915c28ddf3eb76a7bb473b97896a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 8 Jul 2012 00:50:03 +0200 Subject: [PATCH] Matrix4 code cleanup * Don't assume the values are float, use T(0) instead of 0.0f. * Explicitly specify templated type. --- src/Math/Matrix4.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 87e585f92..af1f7486f 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -37,11 +37,11 @@ template class Matrix4: public Matrix<4, T> { * @param vec Translation vector */ inline constexpr static Matrix4 translation(const Vector3& vec) { - return Matrix4( /* Column-major! */ - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - vec.x(), vec.y(), vec.z(), 1.0f + return Matrix4( /* Column-major! */ + T(1), T(0), T(0), T(0), + T(0), T(1), T(0), T(0), + T(0), T(0), T(1), T(0), + vec.x(), vec.y(), vec.z(), T(1) ); } @@ -49,12 +49,12 @@ template class Matrix4: public Matrix<4, T> { * @brief Scaling matrix * @param vec Scaling vector */ - inline constexpr static Matrix4 scaling(const Vector3& vec) { - return Matrix4( /* Column-major! */ - vec.x(), 0.0f, 0.0f, 0.0f, - 0.0f, vec.y(), 0.0f, 0.0f, - 0.0f, 0.0f, vec.z(), 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f + inline constexpr static Matrix4 scaling(const Vector3& vec) { + return Matrix4( /* Column-major! */ + vec.x(), T(0), T(0), T(0), + T(0), vec.y(), T(0), T(0), + T(0), T(0), vec.z(), T(0), + T(0), T(0), T(0), T(1) ); } @@ -63,7 +63,7 @@ template class Matrix4: public Matrix<4, T> { * @param angle Rotation angle (counterclockwise, in radians) * @param vec Rotation vector */ - static Matrix4 rotation(T angle, const Vector3& vec) { + static Matrix4 rotation(T angle, const Vector3& vec) { Vector3 vn = vec.normalized(); T sine = sin(angle); @@ -77,7 +77,7 @@ template class Matrix4: public Matrix<4, T> { T yz = vn.y()*vn.z(); T zz = vn.z()*vn.z(); - return Matrix4( /* Column-major! */ + return Matrix4( /* Column-major! */ cosine + xx*oneMinusCosine, xy*oneMinusCosine + vn.z()*sine, xz*oneMinusCosine - vn.y()*sine, @@ -99,10 +99,10 @@ template class Matrix4: public Matrix<4, T> { /** @copydoc Matrix::Matrix(IdentityType, T) */ inline constexpr explicit Matrix4(typename Matrix<4, T>::IdentityType = (Matrix<4, T>::Identity), T value = T(1)): Matrix<4, T>( - value, 0.0f, 0.0f, 0.0f, - 0.0f, value, 0.0f, 0.0f, - 0.0f, 0.0f, value, 0.0f, - 0.0f, 0.0f, 0.0f, value + value, T(0), T(0), T(0), + T(0), value, T(0), T(0), + T(0), T(0), value, T(0), + T(0), T(0), T(0), value ) {} /** @copydoc Matrix::Matrix(T, U...) */