summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorChaosus <chaosus89@gmail.com>2019-02-09 11:49:25 +0300
committerChaosus <chaosus89@gmail.com>2019-02-10 14:16:02 +0300
commitf946b28f752998e8cf43a20f2458537e7c5fd120 (patch)
tree28d93a3b9c4fa670362aab6ab9d99d87edee2ce1 /core
parent3736a65f24d5e2d015f951fd8b93d9f0514f4d6a (diff)
Fix random generation, to not retrieve 0 after seed()
Diffstat (limited to 'core')
-rw-r--r--core/math/random_pcg.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/math/random_pcg.h b/core/math/random_pcg.h
index ef69bf7120..2a69d43904 100644
--- a/core/math/random_pcg.h
+++ b/core/math/random_pcg.h
@@ -45,7 +45,10 @@ public:
RandomPCG(uint64_t seed = DEFAULT_SEED, uint64_t inc = PCG_DEFAULT_INC_64);
- _FORCE_INLINE_ void seed(uint64_t seed) { pcg.state = seed; }
+ _FORCE_INLINE_ void seed(uint64_t seed) {
+ pcg.state = seed;
+ pcg32_random_r(&pcg); // Force changing internal state to avoid initial 0
+ }
_FORCE_INLINE_ uint64_t get_seed() { return pcg.state; }
void randomize();