From 1ac0806c5d510fab69cedce8ec8ef127a951d96e Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 18 Sep 2011 13:48:19 +0100 Subject: [PATCH] Fixed random tests --- glm/core/func_vector_relational.hpp | 4 ++-- glm/gtx/random.inl | 19 ++----------------- test/gtc/gtc_random.cpp | 14 ++++++++------ 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/glm/core/func_vector_relational.hpp b/glm/core/func_vector_relational.hpp index 3aee44c2..a3cce581 100644 --- a/glm/core/func_vector_relational.hpp +++ b/glm/core/func_vector_relational.hpp @@ -52,8 +52,8 @@ namespace glm //! /// @see - GLSL lessThan man page /// @see - GLSL 4.20.8 specification, section 8.7 - template class vecType> - GLM_FUNC_QUALIFIER typename vecType::bool_type lessThan(vecType const & x, vecType const & y); + //template class vecType> + //GLM_FUNC_QUALIFIER typename vecType::bool_type lessThan(vecType const & x, vecType const & y); //! Returns the component-wise comparison of result x <= y. //! diff --git a/glm/gtx/random.inl b/glm/gtx/random.inl index 5e7e005a..ada6c9aa 100644 --- a/glm/gtx/random.inl +++ b/glm/gtx/random.inl @@ -67,15 +67,8 @@ GLM_FUNC_QUALIFIER detail::tvec2 normalizedRand2( template GLM_FUNC_QUALIFIER detail::tvec2 normalizedRand2() { - T z = compRand1(T(-1), T(1)); - T a = compRand1(T(0), T(6.283185307179586476925286766559f)); - - T r = sqrt(T(1) - z * z); - - T x = r * cos(a); - T y = r * sin(a); - - return detail::tvec2(x, y); + T a = compRand1(T(0), T(6.283185307179586476925286766559f)); + return detail::tvec2(cos(a), sin(a)); } template @@ -100,14 +93,6 @@ GLM_FUNC_QUALIFIER detail::tvec3 normalizedRand3() return detail::tvec3(x, y, z); } -template -GLM_FUNC_QUALIFIER detail::tvec3 normalizedRand3( - T Min, - T Max) -{ - return normalizedRand3() * compRand1(Min, Max); -} - template <> GLM_FUNC_QUALIFIER float compRand1() { diff --git a/test/gtc/gtc_random.cpp b/test/gtc/gtc_random.cpp index 9d9b33b4..bf4a5e94 100644 --- a/test/gtc/gtc_random.cpp +++ b/test/gtc/gtc_random.cpp @@ -27,6 +27,7 @@ int test_signedRand1() Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f); Error += glm::equalEpsilon(ResultDouble, 0.0, 0.0001); + assert(!Error); } return Error; @@ -46,8 +47,8 @@ int test_normalizedRand2() ResultDouble += glm::length(glm::normalizedRand2(1.0f, 1.0f)); } - Error += glm::equalEpsilon(ResultFloat, float(Max), 0.000001f) ? 0 : 1; - Error += glm::equalEpsilon(ResultDouble, double(Max), 0.000001) ? 0 : 1; + Error += glm::equalEpsilon(ResultFloat, float(Max), 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(ResultDouble, double(Max), 0.01) ? 0 : 1; assert(!Error); } @@ -76,12 +77,13 @@ int test_normalizedRand3() ResultDoubleC += glm::length(glm::normalizedRand3(1.0, 3.0)); } - Error += glm::equalEpsilon(ResultFloatA, float(Max), 0.0001f) ? 0 : 1; - Error += glm::equalEpsilon(ResultDoubleA, double(Max), 0.0001) ? 0 : 1; - Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 0.0001f) ? 0 : 1; - Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1; + Error += glm::equalEpsilon(ResultFloatA, float(Max), 100.0f) ? 0 : 1; + Error += glm::equalEpsilon(ResultDoubleA, double(Max), 100.0) ? 0 : 1; + Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 100.0001f) ? 0 : 1; + Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 100.0001) ? 0 : 1; Error += (ResultFloatC >= float(Max) && ResultFloatC <= float(Max * 3)) ? 0 : 1; Error += (ResultDoubleC >= double(Max) && ResultDoubleC <= double(Max * 3)) ? 0 : 1; + assert(!Error); } return Error;