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/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) { 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; } 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. 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 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); 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}, 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; 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; 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; }