From 7086d902e2780e0774830573da7473938290ea73 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 5 Aug 2018 18:24:22 +0200 Subject: [PATCH] Fixed relational code, reduced header dependencies --- glm/ext/matrix_relational.inl | 38 +-- glm/ext/vector_relational.hpp | 18 -- glm/ext/vector_relational.inl | 55 ----- glm/gtc/packing.inl | 1 + test/core/core_cpp_defaulted_ctor.cpp | 1 + test/core/core_func_common.cpp | 1 + test/core/core_func_geometric.cpp | 1 + test/core/core_func_swizzle.cpp | 1 + test/core/core_type_mat2x2.cpp | 2 + test/core/core_type_mat2x3.cpp | 2 + test/core/core_type_mat2x4.cpp | 2 + test/core/core_type_mat3x2.cpp | 2 + test/core/core_type_mat3x3.cpp | 2 + test/core/core_type_mat3x4.cpp | 2 + test/core/core_type_mat4x2.cpp | 2 + test/core/core_type_mat4x3.cpp | 2 + test/core/core_type_mat4x4.cpp | 317 +++++++------------------- test/gtc/gtc_quaternion.cpp | 2 + test/gtx/gtx_extended_min_max.cpp | 1 + test/gtx/gtx_range.cpp | 1 + test/gtx/gtx_scalar_relational.cpp | 2 + 21 files changed, 115 insertions(+), 340 deletions(-) diff --git a/glm/ext/matrix_relational.inl b/glm/ext/matrix_relational.inl index 6758b8e8..efc2d6c5 100644 --- a/glm/ext/matrix_relational.inl +++ b/glm/ext/matrix_relational.inl @@ -2,29 +2,11 @@ /// @file glm/ext/vector_relational.inl // Dependency: -#include "../vector_relational.hpp" +#include "../ext/vector_relational.hpp" #include "../common.hpp" namespace glm { - template - GLM_FUNC_QUALIFIER bool equal(genType const& x, genType const& y, genType const& epsilon) - { - return abs(x - y) <= epsilon; - } - - template - GLM_FUNC_QUALIFIER vec equal(vec const& x, vec const& y, T epsilon) - { - return equal(x, y, vec(epsilon)); - } - - template - GLM_FUNC_QUALIFIER vec equal(vec const& x, vec const& y, vec const& epsilon) - { - return lessThanEqual(abs(x - y), epsilon); - } - template GLM_FUNC_QUALIFIER vec equal(mat const& a, mat const& b) { @@ -46,24 +28,6 @@ namespace glm return Result; } - template - GLM_FUNC_QUALIFIER bool notEqual(genType const& x, genType const& y, genType const& epsilon) - { - return abs(x - y) > epsilon; - } - - template - GLM_FUNC_QUALIFIER vec notEqual(vec const& x, vec const& y, T epsilon) - { - return notEqual(x, y, vec(epsilon)); - } - - template - GLM_FUNC_QUALIFIER vec notEqual(vec const& x, vec const& y, vec const& epsilon) - { - return greaterThan(abs(x - y), epsilon); - } - template GLM_FUNC_QUALIFIER vec notEqual(mat const& x, mat const& y) { diff --git a/glm/ext/vector_relational.hpp b/glm/ext/vector_relational.hpp index 16324771..1965ce1b 100644 --- a/glm/ext/vector_relational.hpp +++ b/glm/ext/vector_relational.hpp @@ -47,15 +47,6 @@ namespace glm template GLM_FUNC_DECL vec equal(vec const& x, vec const& y, vec const& epsilon); - /// Returns the component-wise comparison of |x - y| < epsilon. - /// True if this expression is satisfied. - /// - /// @tparam genType Floating-point or integer scalar types - /// - /// @see ext_vector_relational - template - GLM_FUNC_DECL bool equal(genType const& x, genType const& y, genType const& epsilon); - /// Returns the component-wise comparison of |x - y| >= epsilon. /// True if this expression is not satisfied. /// @@ -78,15 +69,6 @@ namespace glm template GLM_FUNC_DECL vec notEqual(vec const& x, vec const& y, vec const& epsilon); - /// Returns the component-wise comparison of |x - y| >= epsilon. - /// True if this expression is not satisfied. - /// - /// @tparam genType Floating-point or integer scalar types - /// - /// @see ext_vector_relational - template - GLM_FUNC_DECL bool notEqual(genType const& x, genType const& y, genType const& epsilon); - /// @} }//namespace glm diff --git a/glm/ext/vector_relational.inl b/glm/ext/vector_relational.inl index f5119a53..fcd17e8d 100644 --- a/glm/ext/vector_relational.inl +++ b/glm/ext/vector_relational.inl @@ -1,5 +1,4 @@ /// @ref ext_vector_relational -/// @file glm/ext/vector_relational.inl // Dependency: #include "../vector_relational.hpp" @@ -8,12 +7,6 @@ namespace glm { - template - GLM_FUNC_QUALIFIER bool equal(genType const& x, genType const& y, genType const& epsilon) - { - return abs(x - y) <= epsilon; - } - template GLM_FUNC_QUALIFIER vec equal(vec const& x, vec const& y, T epsilon) { @@ -26,33 +19,6 @@ namespace glm return lessThanEqual(abs(x - y), epsilon); } - template - GLM_FUNC_QUALIFIER vec equal(mat const& a, mat const& b) - { - return equal(a, b, static_cast(0)); - } - - template - GLM_FUNC_QUALIFIER vec equal(mat const& a, mat const& b, T epsilon) - { - return equal(a, b, vec(epsilon)); - } - - template - GLM_FUNC_QUALIFIER vec equal(mat const& a, mat const& b, vec const& epsilon) - { - vec Result; - for(length_t i = 0, n = C; i < n; ++i) - Result[i] = all(equal(a[i], b[i], epsilon[i])); - return Result; - } - - template - GLM_FUNC_QUALIFIER bool notEqual(genType const& x, genType const& y, genType const& epsilon) - { - return abs(x - y) > epsilon; - } - template GLM_FUNC_QUALIFIER vec notEqual(vec const& x, vec const& y, T epsilon) { @@ -64,25 +30,4 @@ namespace glm { return greaterThan(abs(x - y), epsilon); } - - template - GLM_FUNC_QUALIFIER vec notEqual(mat const& x, mat const& y) - { - return notEqual(x, y, static_cast(0)); - } - - template - GLM_FUNC_QUALIFIER vec notEqual(mat const& x, mat const& y, T epsilon) - { - return notEqual(x, y, vec(epsilon)); - } - - template - GLM_FUNC_QUALIFIER vec notEqual(mat const& a, mat const& b, vec const& epsilon) - { - vec Result; - for(length_t i = 0, n = C; i < n; ++i) - Result[i] = any(notEqual(a[i], b[i], epsilon[i])); - return Result; - } }//namespace glm diff --git a/glm/gtc/packing.inl b/glm/gtc/packing.inl index 23f4f5c6..8c906e16 100644 --- a/glm/gtc/packing.inl +++ b/glm/gtc/packing.inl @@ -1,5 +1,6 @@ /// @ref gtc_packing +#include "../ext/scalar_relational.hpp" #include "../ext/vector_relational.hpp" #include "../common.hpp" #include "../vec2.hpp" diff --git a/test/core/core_cpp_defaulted_ctor.cpp b/test/core/core_cpp_defaulted_ctor.cpp index a80d2eda..57899032 100644 --- a/test/core/core_cpp_defaulted_ctor.cpp +++ b/test/core/core_cpp_defaulted_ctor.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 221b8dd6..c6055e93 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -1,4 +1,5 @@ #define GLM_FORCE_EXPLICIT_CTOR +#include #include #include #include diff --git a/test/core/core_func_geometric.cpp b/test/core/core_func_geometric.cpp index 1ca0e4e2..c415b26d 100644 --- a/test/core/core_func_geometric.cpp +++ b/test/core/core_func_geometric.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/test/core/core_func_swizzle.cpp b/test/core/core_func_swizzle.cpp index 70272aca..9758533f 100644 --- a/test/core/core_func_swizzle.cpp +++ b/test/core/core_func_swizzle.cpp @@ -1,4 +1,5 @@ #define GLM_FORCE_SWIZZLE +#include #include #include diff --git a/test/core/core_type_mat2x2.cpp b/test/core/core_type_mat2x2.cpp index 338e1dbb..2f8b018f 100644 --- a/test/core/core_type_mat2x2.cpp +++ b/test/core/core_type_mat2x2.cpp @@ -1,4 +1,6 @@ +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat2x3.cpp b/test/core/core_type_mat2x3.cpp index aa934127..e3ad76bb 100644 --- a/test/core/core_type_mat2x3.cpp +++ b/test/core/core_type_mat2x3.cpp @@ -1,4 +1,6 @@ +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat2x4.cpp b/test/core/core_type_mat2x4.cpp index 0c276f07..ade3a444 100644 --- a/test/core/core_type_mat2x4.cpp +++ b/test/core/core_type_mat2x4.cpp @@ -1,6 +1,8 @@ #include #include +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat3x2.cpp b/test/core/core_type_mat3x2.cpp index 2b03a5c2..7a40f90f 100644 --- a/test/core/core_type_mat3x2.cpp +++ b/test/core/core_type_mat3x2.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat3x3.cpp b/test/core/core_type_mat3x3.cpp index effa0364..7d123a94 100644 --- a/test/core/core_type_mat3x3.cpp +++ b/test/core/core_type_mat3x3.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat3x4.cpp b/test/core/core_type_mat3x4.cpp index eea68d93..97d45746 100644 --- a/test/core/core_type_mat3x4.cpp +++ b/test/core/core_type_mat3x4.cpp @@ -1,6 +1,8 @@ #include #include +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat4x2.cpp b/test/core/core_type_mat4x2.cpp index 7bd1da97..7133edc8 100644 --- a/test/core/core_type_mat4x2.cpp +++ b/test/core/core_type_mat4x2.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat4x3.cpp b/test/core/core_type_mat4x3.cpp index 2ab0e891..1c65e7f3 100644 --- a/test/core/core_type_mat4x3.cpp +++ b/test/core/core_type_mat4x3.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include #include diff --git a/test/core/core_type_mat4x4.cpp b/test/core/core_type_mat4x4.cpp index ebdb73be..0ba9df0b 100644 --- a/test/core/core_type_mat4x4.cpp +++ b/test/core/core_type_mat4x4.cpp @@ -1,184 +1,69 @@ #include -#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include - -template -void print(genType const& Mat0) +template +static int test_operators() { - printf("mat4(\n"); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", static_cast(Mat0[0][0]), static_cast(Mat0[0][1]), static_cast(Mat0[0][2]), static_cast(Mat0[0][3])); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", static_cast(Mat0[1][0]), static_cast(Mat0[1][1]), static_cast(Mat0[1][2]), static_cast(Mat0[1][3])); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", static_cast(Mat0[2][0]), static_cast(Mat0[2][1]), static_cast(Mat0[2][2]), static_cast(Mat0[2][3])); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f))\n\n", static_cast(Mat0[3][0]), static_cast(Mat0[3][1]), static_cast(Mat0[3][2]), static_cast(Mat0[3][3])); -} - -int test_inverse_mat4x4() -{ - glm::mat4 Mat0( - glm::vec4(0.6f, 0.2f, 0.3f, 0.4f), - glm::vec4(0.2f, 0.7f, 0.5f, 0.3f), - glm::vec4(0.3f, 0.5f, 0.7f, 0.2f), - glm::vec4(0.4f, 0.3f, 0.2f, 0.6f)); - glm::mat4 Inv0 = glm::inverse(Mat0); - glm::mat4 Res0 = Mat0 * Inv0; - - print(Mat0); - print(Inv0); - print(Res0); - - return 0; -} - -int test_inverse_dmat4x4() -{ - glm::dmat4 Mat0( - glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f), - glm::dvec4(0.2f, 0.7f, 0.5f, 0.3f), - glm::dvec4(0.3f, 0.5f, 0.7f, 0.2f), - glm::dvec4(0.4f, 0.3f, 0.2f, 0.6f)); - glm::dmat4 Inv0 = glm::inverse(Mat0); - glm::dmat4 Res0 = Mat0 * Inv0; - - print(Mat0); - print(Inv0); - print(Res0); - - return 0; -} - -static bool test_operators() -{ - glm::mat4x4 l(1.0f); - glm::mat4x4 m(1.0f); - glm::vec4 u(1.0f); - glm::vec4 v(1.0f); - float x = 1.0f; - glm::vec4 a = m * u; - glm::vec4 b = v * m; - glm::mat4x4 n = x / m; - glm::mat4x4 o = m / x; - glm::mat4x4 p = x * m; - glm::mat4x4 q = m * x; - bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); - bool S = glm::all(glm::equal(m, l, glm::epsilon())); - - return (S && !R) ? 0 : 1; -} - -int test_inverse() -{ - int Error(0); + int Error = 0; + + float const Epsilon = 0.001f; + + glm::mat4x4 const M(2.0f); + glm::mat4x4 const N(1.0f); + glm::vec4 const U(2.0f); { - glm::mat4 const Matrix( - glm::vec4(0.6f, 0.2f, 0.3f, 0.4f), - glm::vec4(0.2f, 0.7f, 0.5f, 0.3f), - glm::vec4(0.3f, 0.5f, 0.7f, 0.2f), - glm::vec4(0.4f, 0.3f, 0.2f, 0.6f)); - glm::mat4 const Inverse = glm::inverse(Matrix); - glm::mat4 const Identity = Matrix * Inverse; - - print(Matrix); - print(Inverse); - print(Identity); - - Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1; + glm::mat4 const P = N * 2.0f; + Error += glm::all(glm::equal(P, M, Epsilon)) ? 0 : 1; + + glm::mat4 const Q = M / 2.0f; + Error += glm::all(glm::equal(Q, N, Epsilon)) ? 0 : 1; + } + + { + glm::vec4 const V = M * U; + Error += glm::all(glm::equal(V, glm::vec4(4.f), Epsilon)) ? 0 : 1; + + glm::vec4 const W = U / M; + Error += glm::all(glm::equal(V, W, Epsilon)) ? 0 : 1; } { - glm::highp_mat4 const Matrix( - glm::highp_vec4(0.6f, 0.2f, 0.3f, 0.4f), - glm::highp_vec4(0.2f, 0.7f, 0.5f, 0.3f), - glm::highp_vec4(0.3f, 0.5f, 0.7f, 0.2f), - glm::highp_vec4(0.4f, 0.3f, 0.2f, 0.6f)); - glm::highp_mat4 const Inverse = glm::inverse(Matrix); - glm::highp_mat4 const Identity = Matrix * Inverse; - - printf("highp_mat4 inverse\n"); - print(Matrix); - print(Inverse); - print(Identity); - - Error += glm::all(glm::epsilonEqual(Identity[0], glm::highp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[1], glm::highp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[2], glm::highp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[3], glm::highp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::highp_vec4(0.01f))) ? 0 : 1; - } - - { - glm::mediump_mat4 const Matrix( - glm::mediump_vec4(0.6f, 0.2f, 0.3f, 0.4f), - glm::mediump_vec4(0.2f, 0.7f, 0.5f, 0.3f), - glm::mediump_vec4(0.3f, 0.5f, 0.7f, 0.2f), - glm::mediump_vec4(0.4f, 0.3f, 0.2f, 0.6f)); - glm::mediump_mat4 const Inverse = glm::inverse(Matrix); - glm::mediump_mat4 const Identity = Matrix * Inverse; - - printf("mediump_mat4 inverse\n"); - print(Matrix); - print(Inverse); - print(Identity); - - Error += glm::all(glm::epsilonEqual(Identity[0], glm::mediump_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[1], glm::mediump_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[2], glm::mediump_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[3], glm::mediump_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::mediump_vec4(0.01f))) ? 0 : 1; - } - - { - glm::lowp_mat4 const Matrix( - glm::lowp_vec4(0.6f, 0.2f, 0.3f, 0.4f), - glm::lowp_vec4(0.2f, 0.7f, 0.5f, 0.3f), - glm::lowp_vec4(0.3f, 0.5f, 0.7f, 0.2f), - glm::lowp_vec4(0.4f, 0.3f, 0.2f, 0.6f)); - glm::lowp_mat4 const Inverse = glm::inverse(Matrix); - glm::lowp_mat4 const Identity = Matrix * Inverse; - - printf("lowp_mat4 inverse\n"); - print(Matrix); - print(Inverse); - print(Identity); - - Error += glm::all(glm::epsilonEqual(Identity[0], glm::lowp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[1], glm::lowp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[2], glm::lowp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[3], glm::lowp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::lowp_vec4(0.01f))) ? 0 : 1; - } - - { - glm::mat4 const Matrix( - glm::vec4(0.6f, 0.2f, 0.3f, 0.4f), - glm::vec4(0.2f, 0.7f, 0.5f, 0.3f), - glm::vec4(0.3f, 0.5f, 0.7f, 0.2f), - glm::vec4(0.4f, 0.3f, 0.2f, 0.6f)); - glm::mat4 const Identity = Matrix / Matrix; - - Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1; + glm::mat4 const O = M * N; + Error += glm::all(glm::equal(O, glm::mat4(4.f), Epsilon)) ? 0 : 1; } return Error; } -int test_ctr() +template +static int test_inverse() +{ + typedef typename matType::value_type value_type; + + int Error = 0; + + matType const Identity(1.0f); + matType const Matrix( + glm::vec4(0.6f, 0.2f, 0.3f, 0.4f), + glm::vec4(0.2f, 0.7f, 0.5f, 0.3f), + glm::vec4(0.3f, 0.5f, 0.7f, 0.2f), + glm::vec4(0.4f, 0.3f, 0.2f, 0.6f)); + matType const Inverse = Identity / Matrix; + matType const Result = Matrix * Inverse; + + value_type const Epsilon(0.001); + Error += glm::all(glm::equal(Identity, Result, Epsilon)) ? 0 : 1; + + return Error; +} + +static int test_ctr() { int Error = 0; @@ -191,7 +76,7 @@ int test_ctr() #endif #if GLM_HAS_INITIALIZER_LISTS - glm::mat4 m0( + glm::mat4 const m0( glm::vec4(0, 1, 2, 3), glm::vec4(4, 5, 6, 7), glm::vec4(8, 9, 10, 11), @@ -199,11 +84,11 @@ int test_ctr() assert(sizeof(m0) == 4 * 4 * 4); - glm::vec4 V{0, 1, 2, 3}; + glm::vec4 const V{0, 1, 2, 3}; - glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + glm::mat4 const m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; - glm::mat4 m2{ + glm::mat4 const m2{ {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, @@ -213,13 +98,13 @@ int test_ctr() Error += glm::all(glm::equal(m1, m2, glm::epsilon())) ? 0 : 1; - std::vector m3{ + std::vector const m3{ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}; - glm::mat4 m4{ + glm::mat4 const m4{ {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, @@ -228,11 +113,11 @@ int test_ctr() 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{ + std::vector const v1{ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}; - std::vector v2{ + std::vector const v2{ { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, @@ -251,58 +136,23 @@ int test_ctr() return Error; } -int perf_mul() +static int test_member_alloc_bug() { int Error = 0; - - - + + struct repro + { + repro(){ this->matrix = new glm::mat4(); } + ~repro(){delete this->matrix;} + + glm::mat4* matrix; + }; + + repro Repro; + return Error; } -namespace cast -{ - template - int entry() - { - int Error = 0; - - genType A(1.0f); - glm::mat4x4 B(A); - glm::mat4x4 Identity(1.0f); - - for(glm::length_t i = 0, length = B.length(); i < length; ++i) - Error += glm::all(glm::epsilonEqual(B[i], Identity[i], glm::epsilon())) ? 0 : 1; - - return Error; - } - - int test() - { - int Error = 0; - - Error += entry(); - Error += entry(); - Error += entry(); - Error += entry(); - Error += entry(); - Error += entry(); - Error += entry(); - Error += entry(); - Error += entry(); - - return Error; - } -}//namespace cast - -struct repro -{ - repro(){ this->matrix = new glm::mat4(); } - ~repro(){delete this->matrix;} - - glm::mat4* matrix; -}; - static int test_size() { int Error = 0; @@ -319,8 +169,6 @@ static int test_size() static int test_constexpr() { - glm::mat4 const I(1.0f); - #if GLM_HAS_CONSTEXPR static_assert(glm::mat4::length() == 4, "GLM: Failed constexpr"); #endif @@ -332,18 +180,27 @@ int main() { int Error = 0; - repro Repro; - - Error += cast::test(); + Error += test_member_alloc_bug(); + Error += test_ctr(); - Error += test_inverse_dmat4x4(); - Error += test_inverse_mat4x4(); - Error += test_operators(); - Error += test_inverse(); + + Error += test_operators(); + Error += test_operators(); + Error += test_operators(); + Error += test_operators(); + + Error += test_inverse(); + Error += test_inverse(); + Error += test_inverse(); + Error += test_inverse(); + + Error += test_inverse(); + Error += test_inverse(); + Error += test_inverse(); + Error += test_inverse(); + Error += test_size(); Error += test_constexpr(); - Error += perf_mul(); - return Error; } diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 208aba74..4c9bffc5 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include #include #include diff --git a/test/gtx/gtx_extended_min_max.cpp b/test/gtx/gtx_extended_min_max.cpp index 3e0bb001..3d20f10e 100644 --- a/test/gtx/gtx_extended_min_max.cpp +++ b/test/gtx/gtx_extended_min_max.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include // This file has divisions by zero to test isnan diff --git a/test/gtx/gtx_range.cpp b/test/gtx/gtx_range.cpp index 53fb87e6..434731b9 100644 --- a/test/gtx/gtx_range.cpp +++ b/test/gtx/gtx_range.cpp @@ -1,5 +1,6 @@ #define GLM_ENABLE_EXPERIMENTAL #include +#include #include #include diff --git a/test/gtx/gtx_scalar_relational.cpp b/test/gtx/gtx_scalar_relational.cpp index ba4793af..fc6a09ac 100644 --- a/test/gtx/gtx_scalar_relational.cpp +++ b/test/gtx/gtx_scalar_relational.cpp @@ -1,7 +1,9 @@ #define GLM_ENABLE_EXPERIMENTAL #include #include +#include #include +#include #include static int test_lessThan()