diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl index 105d2f66..9310a205 100644 --- a/glm/gtc/random.inl +++ b/glm/gtc/random.inl @@ -141,7 +141,7 @@ GLM_FUNC_QUALIFIER detail::tvec4 gaussRand } template -GLM_FUNC_QUALIFIER detail::tvec3 diskRand +GLM_FUNC_QUALIFIER detail::tvec2 diskRand ( T const & Radius ) @@ -151,7 +151,7 @@ GLM_FUNC_QUALIFIER detail::tvec3 diskRand do { - Result = compRand2(-Radius, Radius); + Result = linearRand(detail::tvec2(-Radius), detail::tvec2(Radius)); LenRadius = length(Result); } while(LenRadius > Radius); @@ -170,7 +170,7 @@ GLM_FUNC_QUALIFIER detail::tvec3 ballRand do { - Result = compRand3(-Radius, Radius); + Result = linearRand(detail::tvec3(-Radius), detail::tvec3(Radius)); LenRadius = length(Result); } while(LenRadius > Radius); diff --git a/test/gtc/gtc_random.cpp b/test/gtc/gtc_random.cpp index 2dd1a142..e1690b69 100644 --- a/test/gtc/gtc_random.cpp +++ b/test/gtc/gtc_random.cpp @@ -91,6 +91,36 @@ int test_sphericalRand() return Error; } +int test_diskRand() +{ + int Error = 0; + + { + float ResultFloat = 0.0f; + double ResultDouble = 0.0f; + for(std::size_t i = 0; i < 100000; ++i) + { + ResultFloat += glm::length(glm::diskRand(2.0f)); + ResultDouble += glm::length(glm::diskRand(2.0)); + } + + Error += ResultFloat < 200000.f ? 0 : 1; + Error += ResultDouble < 200000.0 ? 0 : 1; + assert(!Error); + } + + return Error; +} + +int test_ballRand() +{ + int Error = 0; + + + + return Error; +} + int main() { int Error = 0; @@ -98,6 +128,8 @@ int main() Error += test_linearRand(); Error += test_circularRand(); Error += test_sphericalRand(); + Error += test_diskRand(); + Error += test_ballRand(); return Error; }