summaryrefslogtreecommitdiff
path: root/core/math/random_pcg.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-10-30 15:00:44 +0100
committerGitHub <noreply@github.com>2020-10-30 15:00:44 +0100
commitf98db723b91feb5ffc54460813be2c712e0b8ff8 (patch)
tree0f35f28b6a3f7cd2578cd8af320122a952030fe5 /core/math/random_pcg.h
parentb1ed10da1b5452486cd745964672f8017404eaeb (diff)
parent31faa1f22626b8745ed4a1541497832b6f595df2 (diff)
Merge pull request #43184 from Chaosus/fix_randi_range_biased
Fix biased output of randi_range
Diffstat (limited to 'core/math/random_pcg.h')
-rw-r--r--core/math/random_pcg.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/math/random_pcg.h b/core/math/random_pcg.h
index 09b13ab74d..dfdae53eed 100644
--- a/core/math/random_pcg.h
+++ b/core/math/random_pcg.h
@@ -81,6 +81,10 @@ public:
current_seed = pcg.state;
return pcg32_random_r(&pcg);
}
+ _FORCE_INLINE_ uint32_t rand(uint32_t bounds) {
+ current_seed = pcg.state;
+ return pcg32_boundedrand_r(&pcg, bounds);
+ }
// Obtaining floating point numbers in [0, 1] range with "good enough" uniformity.
// These functions sample the output of rand() as the fraction part of an infinite binary number,