Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite loop in ballRand and diskRand #739

Closed
Zuzu-Typ opened this issue Mar 10, 2018 · 2 comments
Closed

infinite loop in ballRand and diskRand #739

Zuzu-Typ opened this issue Mar 10, 2018 · 2 comments
Assignees
Milestone

Comments

@Zuzu-Typ
Copy link

Zuzu-Typ commented Mar 10, 2018

(in glm/gtc/random.inl)
The functions
vec<3, T, defaultp> glm::ballRand(T Radius) and vec<2, T, defaultp> glm::diskRand(T Radius) can result in an infinite loop if called with a negative value for Radius.
The reason for this is that they compare the length of a computed vector (which is always positive or zero) to Radius.

One solution would be to throw an exception if a negative value is given (which shouldn't normally occur), or you could fabs() it.

@Zuzu-Typ Zuzu-Typ changed the title infinite loop in ballRand infinite loop in ballRand and diskRand Mar 10, 2018
@yuri-kilochek
Copy link

yuri-kilochek commented Mar 11, 2018

Why is it computing length (via expensive sqrt) in the first place instead of squared length (and comparing it with squared radius)?

Groovounet pushed a commit that referenced this issue Jul 29, 2018
@Groovounet Groovounet self-assigned this Jul 29, 2018
@Groovounet Groovounet added this to the GLM 0.9.9 milestone Jul 29, 2018
@Groovounet
Copy link
Member

This issue is fixed in master branch for GLM 0.9.9.1 release.

Now the functions checks that the parameters are positive values using an assert.

Thanks for reporting,
Christophe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants