From d08618c0731da9f47c0a4e025166f279c8e82873 Mon Sep 17 00:00:00 2001 From: Patrik Huber Date: Wed, 17 Aug 2016 23:24:44 +0100 Subject: [PATCH 1/3] Convert integers to type T in quaternion mat3_cast() This fixes issues when the type T is not explicitly convertible to T, and for example only has an operator* defined that takes two Ts but not a T and an int. All the other functions in that file already use this syntax, so the missing ones here are most likely an oversight. --- glm/gtc/quaternion.inl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index ff610980..f062b0a6 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -603,17 +603,17 @@ namespace detail T qwy(q.w * q.y); T qwz(q.w * q.z); - Result[0][0] = 1 - 2 * (qyy + qzz); - Result[0][1] = 2 * (qxy + qwz); - Result[0][2] = 2 * (qxz - qwy); + Result[0][0] = T(1) - T(2) * (qyy + qzz); + Result[0][1] = T(2) * (qxy + qwz); + Result[0][2] = T(2) * (qxz - qwy); - Result[1][0] = 2 * (qxy - qwz); - Result[1][1] = 1 - 2 * (qxx + qzz); - Result[1][2] = 2 * (qyz + qwx); + Result[1][0] = T(2) * (qxy - qwz); + Result[1][1] = T(1) - T(2) * (qxx + qzz); + Result[1][2] = T(2) * (qyz + qwx); - Result[2][0] = 2 * (qxz + qwy); - Result[2][1] = 2 * (qyz - qwx); - Result[2][2] = 1 - 2 * (qxx + qyy); + Result[2][0] = T(2) * (qxz + qwy); + Result[2][1] = T(2) * (qyz - qwx); + Result[2][2] = T(1) - T(2) * (qxx + qyy); return Result; } From 3b4856cf581a27d6cdede28c6d107e22186deeb7 Mon Sep 17 00:00:00 2001 From: Patrik Huber Date: Wed, 17 Aug 2016 23:24:44 +0100 Subject: [PATCH 2/3] Convert integers to type T in quaternion mat3_cast() This fixes issues when the type T is not explicitly convertible to T, and for example only has an operator* defined that takes two Ts but not a T and an int. All the other functions in that file already use this syntax, so the missing ones here are most likely an oversight. --- glm/gtc/quaternion.inl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index ff610980..f062b0a6 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -603,17 +603,17 @@ namespace detail T qwy(q.w * q.y); T qwz(q.w * q.z); - Result[0][0] = 1 - 2 * (qyy + qzz); - Result[0][1] = 2 * (qxy + qwz); - Result[0][2] = 2 * (qxz - qwy); + Result[0][0] = T(1) - T(2) * (qyy + qzz); + Result[0][1] = T(2) * (qxy + qwz); + Result[0][2] = T(2) * (qxz - qwy); - Result[1][0] = 2 * (qxy - qwz); - Result[1][1] = 1 - 2 * (qxx + qzz); - Result[1][2] = 2 * (qyz + qwx); + Result[1][0] = T(2) * (qxy - qwz); + Result[1][1] = T(1) - T(2) * (qxx + qzz); + Result[1][2] = T(2) * (qyz + qwx); - Result[2][0] = 2 * (qxz + qwy); - Result[2][1] = 2 * (qyz - qwx); - Result[2][2] = 1 - 2 * (qxx + qyy); + Result[2][0] = T(2) * (qxz + qwy); + Result[2][1] = T(2) * (qyz - qwx); + Result[2][2] = T(1) - T(2) * (qxx + qyy); return Result; } From ad262c359212ee85aa61391e4af18e1f51d899ba Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 18 Aug 2016 00:58:58 +0200 Subject: [PATCH 3/3] Udpated readme with fixed mat3_cast #542 --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index e83ed772..920b1f25 100644 --- a/readme.md +++ b/readme.md @@ -92,6 +92,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Fixed strict aliasing warnings #473 - Fixed missing vec1 overload to length2 and distance2 functions #431 - Fixed GLM test '/fp:fast' and '/Za' command-line options are incompatible +- Fixed quaterion to mat3 cast function mat3_cast from GTC_quaternion #542 ##### Deprecation: - Removed GLM_FORCE_SIZE_FUNC define