From 84e6d82051749ead43d2fcb82efca7c4234b1015 Mon Sep 17 00:00:00 2001 From: Sergey Kosarevsky Date: Mon, 11 Dec 2017 18:09:07 +0100 Subject: [PATCH 1/9] Fixed #692: sphericalRand() is doing correct distribution on a sphere --- glm/gtc/random.inl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl index 68f38742..e0e7a93f 100644 --- a/glm/gtc/random.inl +++ b/glm/gtc/random.inl @@ -340,13 +340,12 @@ namespace detail template GLM_FUNC_QUALIFIER vec<3, T, defaultp> sphericalRand(T Radius) { - T z = linearRand(T(-1), T(1)); - T a = linearRand(T(0), T(6.283185307179586476925286766559f)); + T theta = linearRand(T(0), T(6.283185307179586476925286766559f)); + T phi = std::acos(linearRand(T(-1.0f), T(1.0f))); - T r = sqrt(T(1) - z * z); - - T x = r * std::cos(a); - T y = r * std::sin(a); + T x = std::sin(phi) * std::cos(theta); + T y = std::sin(phi) * std::sin(theta); + T z = std::cos(phi); return vec<3, T, defaultp>(x, y, z) * Radius; } From 5d0fa00c3976c7268533a87603c265cdb300e217 Mon Sep 17 00:00:00 2001 From: Giuseppe Barbieri Date: Tue, 19 Dec 2017 14:47:02 +0100 Subject: [PATCH 2/9] Update gtx_matrix_interpolation.cpp --- test/gtx/gtx_matrix_interpolation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gtx/gtx_matrix_interpolation.cpp b/test/gtx/gtx_matrix_interpolation.cpp index b380ba15..6d965f87 100644 --- a/test/gtx/gtx_matrix_interpolation.cpp +++ b/test/gtx/gtx_matrix_interpolation.cpp @@ -24,7 +24,7 @@ int test_axisAngle() float dltAngle = 0.0f; glm::axisAngle(dltRotation, dltAxis, dltAngle); - std::cout << "dltAngle: (" << dltAxis.x << ", " << dltAxis.y << ", " << dltAxis.z << "), dltAngle: " << dltAngle << std::endl; + std::cout << "dltAxis: (" << dltAxis.x << ", " << dltAxis.y << ", " << dltAxis.z << "), dltAngle: " << dltAngle << std::endl; glm::fquat q = glm::quat_cast(dltRotation); std::cout << "q: (" << q.x << ", " << q.y << ", " << q.z << ", " << q.w << ")" << std::endl; From 83697febeb6752f9aa7a3bd3dae61e8666c851be Mon Sep 17 00:00:00 2001 From: Giuseppe Barbieri Date: Tue, 19 Dec 2017 16:18:10 +0100 Subject: [PATCH 3/9] Update intersect.hpp --- glm/gtx/intersect.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glm/gtx/intersect.hpp b/glm/gtx/intersect.hpp index 851efa23..61e2226a 100644 --- a/glm/gtx/intersect.hpp +++ b/glm/gtx/intersect.hpp @@ -44,13 +44,13 @@ namespace glm typename genType::value_type & intersectionDistance); //! Compute the intersection of a ray and a triangle. - /// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/ + /// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/ //! From GLM_GTX_intersect extension. template GLM_FUNC_DECL bool intersectRayTriangle( vec<3, T, Q> const& orig, vec<3, T, Q> const& dir, vec<3, T, Q> const& v0, vec<3, T, Q> const& v1, vec<3, T, Q> const& v2, - vec<3, T, Q>& baryPosition, T& distance); + vec<2, T, Q>& baryPosition, T& distance); //! Compute the intersection of a line and a triangle. //! From GLM_GTX_intersect extension. From 43179a4bc1c93f113fc41847823bf857b7fe721d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 4 Jan 2018 15:33:17 +0100 Subject: [PATCH 4/9] Fixed typo --- glm/gtx/matrix_interpolation.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/gtx/matrix_interpolation.hpp b/glm/gtx/matrix_interpolation.hpp index 69473d35..89c4596c 100644 --- a/glm/gtx/matrix_interpolation.hpp +++ b/glm/gtx/matrix_interpolation.hpp @@ -9,7 +9,7 @@ /// /// Include to use the features of this extension. /// -/// Allows to directly interpolate two exiciting matrices. +/// Allows to directly interpolate two matrices. #pragma once From 85811f3860a5165fca755893b45b861a123cda5e Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 4 Jan 2018 15:54:49 +0100 Subject: [PATCH 5/9] Fixed test --- test/core/core_type_mat4x4.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/core/core_type_mat4x4.cpp b/test/core/core_type_mat4x4.cpp index 29e8536d..8cd83a58 100644 --- a/test/core/core_type_mat4x4.cpp +++ b/test/core/core_type_mat4x4.cpp @@ -227,7 +227,8 @@ int test_ctr() {0, 0, 1, 0}, {0, 0, 0, 1} }; - Error += glm::equal(m4[0][3], 1.0f, 0.0001f) ? 0 : 1; + Error += glm::equal(m4[0][0], 1.0f, 0.0001f) ? 0 : 1; + Error += glm::equal(m4[3][3], 1.0f, 0.0001f) ? 0 : 1; std::vector v1{ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, From 26c395c78b5b6bf0772bfe57e641d8b54d2595fb Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 4 Jan 2018 17:14:27 +0100 Subject: [PATCH 6/9] Fixed build --- test/core/core_type_vec4.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 9f40771d..24552f98 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -525,17 +525,17 @@ static int test_inheritance() { my_vec4() : glm::vec4(76.f, 75.f, 74.f, 73.f) - , data(82) + , member(82) {} - int data; + int member; }; int Error = 0; my_vec4 v; - Error += v.data == 82 ? 0 : 1; + Error += v.member == 82 ? 0 : 1; Error += glm::epsilonEqual(v.x, 76.f, glm::epsilon()) ? 0 : 1; Error += glm::epsilonEqual(v.y, 75.f, glm::epsilon()) ? 0 : 1; Error += glm::epsilonEqual(v.z, 74.f, glm::epsilon()) ? 0 : 1; From 6390805e6d420977a293d967c17cf1a7fd944cdb Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 5 Jan 2018 00:03:29 +0100 Subject: [PATCH 7/9] Fixed zero as null pointer constant --- glm/detail/setup.hpp | 16 ++++++++++++++++ glm/gtx/string_cast.inl | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index d3eb06e1..8969678c 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -508,6 +508,22 @@ # define GLM_HAS_OPENMP 0 #endif +/////////////////////////////////////////////////////////////////////////////////// +// nullptr + +// +#if GLM_LANG & GLM_LANG_CXX0X_FLAG +# define GLM_HAS_NULLPTR 1 +#else +# define GLM_HAS_NULLPTR 0 +#endif + +#if GLM_HAS_NULLPTR +# define GLM_NULLPTR nullptr +#else +# define GLM_NULLPTR 0 +#endif + /////////////////////////////////////////////////////////////////////////////////// // Static assert diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index 4ff9e671..42998005 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -25,7 +25,7 @@ namespace detail char text[STRING_BUFFER]; va_list list; - if(msg == 0) + if(msg == GLM_NULLPTR) return std::string(); va_start(list, msg); From 7725407b2d83a1b8fe70b49f2af5bc9da730427d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 6 Jan 2018 19:47:01 +0100 Subject: [PATCH 8/9] Added missing quat minus operator #703 --- glm/gtc/quaternion.hpp | 3 +++ glm/gtc/quaternion.inl | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index b43ec04d..507cf3d4 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -142,6 +142,9 @@ namespace glm template GLM_FUNC_DECL tquat operator+(tquat const& q, tquat const& p); + template + GLM_FUNC_DECL tquat operator-(tquat const& q, tquat const& p); + template GLM_FUNC_DECL tquat operator*(tquat const& q, tquat const& p); diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 56f943c8..9a9aa66d 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -200,7 +200,7 @@ namespace detail return mat3_cast(*this); } - template + template GLM_FUNC_QUALIFIER tquat::operator mat<4, 4, T, Q>() { return mat4_cast(*this); @@ -308,6 +308,12 @@ namespace detail return tquat(q) += p; } + template + GLM_FUNC_QUALIFIER tquat operator-(tquat const& q, tquat const& p) + { + return tquat(q) -= p; + } + template GLM_FUNC_QUALIFIER tquat operator*(tquat const& q, tquat const& p) { From c585cb9d6cd2bf8fba177d703a3b78086561d0d3 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 6 Jan 2018 19:58:39 +0100 Subject: [PATCH 9/9] Added quat left and right handed tests #703 --- test/gtx/gtx_quaternion.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/gtx/gtx_quaternion.cpp b/test/gtx/gtx_quaternion.cpp index 28e31095..c6346afa 100644 --- a/test/gtx/gtx_quaternion.cpp +++ b/test/gtx/gtx_quaternion.cpp @@ -107,6 +107,18 @@ int test_quat_lookAt() Error += static_cast(glm::abs(glm::length(test_quat) - 1.0f) > glm::epsilon()); Error += static_cast(glm::min(glm::length(test_quat + (-test_mat)), glm::length(test_quat + test_mat)) > glm::epsilon()); + // Test left-handed implementation + glm::quat test_quatLH = glm::quatLookAtLH(glm::normalize(center - eye), up); + glm::quat test_matLH = glm::conjugate(glm::quat_cast(glm::lookAtLH(eye, center, up))); + Error += static_cast(glm::abs(glm::length(test_quatLH) - 1.0f) > glm::epsilon()); + Error += static_cast(glm::min(glm::length(test_quatLH - test_matLH), glm::length(test_quatLH + test_matLH)) > glm::epsilon()); + + // Test right-handed implementation + glm::quat test_quatRH = glm::quatLookAtRH(glm::normalize(center - eye), up); + glm::quat test_matRH = glm::conjugate(glm::quat_cast(glm::lookAtRH(eye, center, up))); + Error += static_cast(glm::abs(glm::length(test_quatRH) - 1.0f) > glm::epsilon()); + Error += static_cast(glm::min(glm::length(test_quatRH - test_matRH), glm::length(test_quatRH + test_matRH)) > glm::epsilon()); + return Error; }