1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-06 19:41:11 +00:00

Merge pull request #25680 from Chaosus/random_fix

Fix random generation, to not always retrieve 0 after seed()
This commit is contained in:
Rémi Verschelde
2019-02-16 23:24:02 +01:00
committed by GitHub

View File

@@ -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();