From 04819ecaae45d77dbb33c433fdf56c62c99dc294 Mon Sep 17 00:00:00 2001 From: akaltar Date: Fri, 20 Oct 2017 18:42:46 +0200 Subject: [PATCH 1/4] Fix #679 Fixes warning C4309 on VS2015 --- glm/gtc/bitfield.inl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/glm/gtc/bitfield.inl b/glm/gtc/bitfield.inl index 0646665c..68e3742f 100644 --- a/glm/gtc/bitfield.inl +++ b/glm/gtc/bitfield.inl @@ -85,21 +85,21 @@ namespace detail glm::uint32 REG2(y); glm::uint32 REG3(z); - REG1 = ((REG1 << 16) | REG1) & static_cast(0x00FF0000FF0000FF); - REG2 = ((REG2 << 16) | REG2) & static_cast(0x00FF0000FF0000FF); - REG3 = ((REG3 << 16) | REG3) & static_cast(0x00FF0000FF0000FF); + REG1 = ((REG1 << 16) | REG1) & static_cast(0xFF0000FFu); + REG2 = ((REG2 << 16) | REG2) & static_cast(0xFF0000FFu); + REG3 = ((REG3 << 16) | REG3) & static_cast(0xFF0000FFu); - REG1 = ((REG1 << 8) | REG1) & static_cast(0xF00F00F00F00F00F); - REG2 = ((REG2 << 8) | REG2) & static_cast(0xF00F00F00F00F00F); - REG3 = ((REG3 << 8) | REG3) & static_cast(0xF00F00F00F00F00F); + REG1 = ((REG1 << 8) | REG1) & static_cast(0x0F00F00Fu); + REG2 = ((REG2 << 8) | REG2) & static_cast(0x0F00F00Fu); + REG3 = ((REG3 << 8) | REG3) & static_cast(0x0F00F00Fu); - REG1 = ((REG1 << 4) | REG1) & static_cast(0x30C30C30C30C30C3); - REG2 = ((REG2 << 4) | REG2) & static_cast(0x30C30C30C30C30C3); - REG3 = ((REG3 << 4) | REG3) & static_cast(0x30C30C30C30C30C3); + REG1 = ((REG1 << 4) | REG1) & static_cast(0xC30C30C3u); + REG2 = ((REG2 << 4) | REG2) & static_cast(0xC30C30C3u); + REG3 = ((REG3 << 4) | REG3) & static_cast(0xC30C30C3u); - REG1 = ((REG1 << 2) | REG1) & static_cast(0x9249249249249249); - REG2 = ((REG2 << 2) | REG2) & static_cast(0x9249249249249249); - REG3 = ((REG3 << 2) | REG3) & static_cast(0x9249249249249249); + REG1 = ((REG1 << 2) | REG1) & static_cast(0x49249249u); + REG2 = ((REG2 << 2) | REG2) & static_cast(0x49249249u); + REG3 = ((REG3 << 2) | REG3) & static_cast(0x49249249u); return REG1 | (REG2 << 1) | (REG3 << 2); } From 6f61bb4d2edbbb6b79fcb11596e91ceae48cae8c Mon Sep 17 00:00:00 2001 From: Olivier Sohn Date: Sat, 21 Oct 2017 21:17:55 +0200 Subject: [PATCH 2/4] Fix rotation when vectors are in the same direction #690 --- glm/gtx/quaternion.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index 5595ec38..f57082fa 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -184,8 +184,10 @@ namespace glm T cosTheta = dot(orig, dest); vec<3, T, Q> rotationAxis; - if(cosTheta >= static_cast(1) - epsilon()) - return quat(); + if(cosTheta >= static_cast(1) - epsilon()) { + // orig and dest point in the same direction : return identity quaternion. + return quat(1, 0, 0, 0); + } if(cosTheta < static_cast(-1) + epsilon()) { From 6bd81b8fbc1038d1c8c7f6fb2c582a89673e9891 Mon Sep 17 00:00:00 2001 From: Olivier Sohn Date: Sat, 21 Oct 2017 21:43:47 +0200 Subject: [PATCH 3/4] use quat_identity --- glm/gtx/quaternion.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index f57082fa..b99b869f 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -185,8 +185,8 @@ namespace glm vec<3, T, Q> rotationAxis; if(cosTheta >= static_cast(1) - epsilon()) { - // orig and dest point in the same direction : return identity quaternion. - return quat(1, 0, 0, 0); + // orig and dest point in the same direction + return quat_identity(); } if(cosTheta < static_cast(-1) + epsilon()) From ddb93dcdc2b4af4b5bac7f4905c3108fad7fc78b Mon Sep 17 00:00:00 2001 From: Olivier Sohn Date: Sat, 21 Oct 2017 21:50:36 +0200 Subject: [PATCH 4/4] fix build --- glm/gtx/quaternion.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index b99b869f..b29b53d8 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -186,7 +186,7 @@ namespace glm if(cosTheta >= static_cast(1) - epsilon()) { // orig and dest point in the same direction - return quat_identity(); + return quat_identity(); } if(cosTheta < static_cast(-1) + epsilon())