diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl index 9310a205..0d9f4e60 100644 --- a/glm/gtc/random.inl +++ b/glm/gtc/random.inl @@ -92,8 +92,8 @@ GLM_FUNC_QUALIFIER genType gaussRand do { - x1 = compRand1(genType(-1), genType(1)); - x2 = compRand1(genType(-1), genType(1)); + x1 = linearRand(genType(-1), genType(1)); + x2 = linearRand(genType(-1), genType(1)); w = x1 * x1 + x2 * x2; } while(w > genType(1)); diff --git a/test/gtc/gtc_random.cpp b/test/gtc/gtc_random.cpp index e1690b69..08f3cec2 100644 --- a/test/gtc/gtc_random.cpp +++ b/test/gtc/gtc_random.cpp @@ -69,6 +69,7 @@ int test_sphericalRand() double ResultDoubleA = 0.0f; double ResultDoubleB = 0.0f; double ResultDoubleC = 0.0f; + for(std::size_t i = 0; i < Max; ++i) { ResultFloatA += glm::length(glm::sphericalRand(1.0f)); @@ -98,6 +99,7 @@ int test_diskRand() { float ResultFloat = 0.0f; double ResultDouble = 0.0f; + for(std::size_t i = 0; i < 100000; ++i) { ResultFloat += glm::length(glm::diskRand(2.0f)); @@ -116,7 +118,20 @@ int test_ballRand() { int Error = 0; + { + float ResultFloat = 0.0f; + double ResultDouble = 0.0f; + for(std::size_t i = 0; i < 100000; ++i) + { + ResultFloat += glm::length(glm::ballRand(2.0f)); + ResultDouble += glm::length(glm::ballRand(2.0)); + } + + Error += ResultFloat < 200000.f ? 0 : 1; + Error += ResultDouble < 200000.0 ? 0 : 1; + assert(!Error); + } return Error; }