diff options
author | Jacques Lucke <jacques@blender.org> | 2022-03-17 14:48:41 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-03-17 14:48:41 +0300 |
commit | d0968a9c52019b817c001562adbb875780d94786 (patch) | |
tree | 4f5548adcd757cb75443bde77b082487fbf81839 /source/blender/blenlib/BLI_rand.hh | |
parent | 8f68cff01b85bfde18c9442e6a638eda181ee159 (diff) |
BLI: add probabilistic rounding utility
Diffstat (limited to 'source/blender/blenlib/BLI_rand.hh')
-rw-r--r-- | source/blender/blenlib/BLI_rand.hh | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_rand.hh b/source/blender/blenlib/BLI_rand.hh index 069a81bb84b..2c4484bd63f 100644 --- a/source/blender/blenlib/BLI_rand.hh +++ b/source/blender/blenlib/BLI_rand.hh @@ -103,6 +103,12 @@ class RandomNumberGenerator { return float3(rand1, rand2, 1.0f - rand1 - rand2); } + /** + * Round value to the next integer randomly. + * 4.9f is more likely to round to 5 than 4.6f. + */ + int round_probabilistic(float x); + float2 get_unit_float2(); float3 get_unit_float3(); /** |