- Fixed infinite loop in random functions when using negative radius values using an assert #739

This commit is contained in:
Groove 2018-07-29 23:30:35 +02:00
parent 58255c8603
commit cd58024e40
2 changed files with 9 additions and 0 deletions

View File

@ -243,6 +243,8 @@ namespace detail
template<typename T>
GLM_FUNC_QUALIFIER vec<2, T, defaultp> diskRand(T Radius)
{
assert(Radius > static_cast<T>(0));
vec<2, T, defaultp> Result(T(0));
T LenRadius(T(0));
@ -261,6 +263,8 @@ namespace detail
template<typename T>
GLM_FUNC_QUALIFIER vec<3, T, defaultp> ballRand(T Radius)
{
assert(Radius > static_cast<T>(0));
vec<3, T, defaultp> Result(T(0));
T LenRadius(T(0));
@ -279,6 +283,8 @@ namespace detail
template<typename T>
GLM_FUNC_QUALIFIER vec<2, T, defaultp> circularRand(T Radius)
{
assert(Radius > static_cast<T>(0));
T a = linearRand(T(0), static_cast<T>(6.283185307179586476925286766559));
return vec<2, T, defaultp>(glm::cos(a), glm::sin(a)) * Radius;
}
@ -286,6 +292,8 @@ namespace detail
template<typename T>
GLM_FUNC_QUALIFIER vec<3, T, defaultp> sphericalRand(T Radius)
{
assert(Radius > static_cast<T>(0));
T theta = linearRand(T(0), T(6.283185307179586476925286766559f));
T phi = std::acos(linearRand(T(-1.0f), T(1.0f)));

View File

@ -75,6 +75,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
- Fixed ICC build errors with constexpr #704
- Fixed defaulted operator= and constructors #791
- Fixed invalid conversion from int scalar with vec4 constructor when using SSE instruction
- Fixed infinite loop in random functions when using negative radius values using an assert #739
### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22
#### Features: