diff options
Diffstat (limited to 'core/math/random_pcg.h')
-rw-r--r-- | core/math/random_pcg.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/math/random_pcg.h b/core/math/random_pcg.h index cc22b23b70..fd0934b24a 100644 --- a/core/math/random_pcg.h +++ b/core/math/random_pcg.h @@ -59,6 +59,9 @@ static int __bsr_clz32(uint32_t x) { #define LDEXPF(s, e) ldexp(s, e) #endif +template <class T> +class Vector; + class RandomPCG { pcg32_random_t pcg; uint64_t current_seed = 0; // The seed the current generator state started from. @@ -87,6 +90,8 @@ public: return pcg32_boundedrand_r(&pcg, bounds); } + int64_t rand_weighted(const Vector<float> &p_weights); + // 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, // with some tricks applied to reduce ops and branching: |