Skip to content
Snippets Groups Projects
Commit 415167b2 authored by kwolekr's avatar kwolekr
Browse files

Noise: Fix PcgRandom::randNormalDist() when range contains negative numbers

This fixes an issue with erroneous float-to-int rounding that resulted in
truncation toward 0, causing a biased distribution.
parent cd1d625a
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,7 @@ s32 PcgRandom::randNormalDist(s32 min, s32 max, int num_trials)
s32 accum = 0;
for (int i = 0; i != num_trials; i++)
accum += range(min, max);
return ((float)accum / num_trials) + 0.5f;
return round((float)accum / num_trials);
}
///////////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment