diff --git a/glm/gtx/matrix_interpolation.hpp b/glm/gtx/matrix_interpolation.hpp index d842986f..29ed6ec2 100644 --- a/glm/gtx/matrix_interpolation.hpp +++ b/glm/gtx/matrix_interpolation.hpp @@ -65,6 +65,12 @@ namespace glm detail::tvec3 const & axis, T const angle); + //! Extracts the rotation part of a matrix. + //! From GLM_GTX_matrix_interpolation extension. + template + detail::tmat4x4 extractMatrixRotation( + detail::tmat4x4 const & mat); + //! Build a interpolation of 4 * 4 matrixes. //! From GLM_GTX_matrix_interpolation extension. //! Warning! works only with rotation and/or translation matrixes, scale will generate unexpected results. diff --git a/glm/gtx/matrix_interpolation.inl b/glm/gtx/matrix_interpolation.inl index 92deb2e3..ffd15096 100644 --- a/glm/gtx/matrix_interpolation.inl +++ b/glm/gtx/matrix_interpolation.inl @@ -97,6 +97,18 @@ namespace glm ); } + template + GLM_FUNC_QUALIFIER detail::tmat4x4 extractMatrixRotation( + detail::tmat4x4 const & mat) + { + return detail::tmat4x4( + mat[0][0], mat[0][1], mat[0][2], 0.0, + mat[1][0], mat[1][1], mat[1][2], 0.0, + mat[2][0], mat[2][1], mat[2][2], 0.0, + 0.0, 0.0, 0.0, 1.0 + ); + } + template GLM_FUNC_QUALIFIER detail::tmat4x4 interpolate ( @@ -109,7 +121,7 @@ namespace glm detail::tvec3 dltAxis; T dltAngle; axisAngle(dltRotation, dltAxis, dltAngle); - detail::tmat4x4 out = axisAngleMatrix(dltAxis, dltAngle * delta) * rotationMatrix(m1); + detail::tmat4x4 out = axisAngleMatrix(dltAxis, dltAngle * delta) * extractMatrixRotation(m1); out[3][0] = m1[3][0] + delta * (m2[3][0] - m1[3][0]); out[3][1] = m1[3][1] + delta * (m2[3][1] - m1[3][1]); out[3][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]);