1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-26 15:46:23 +00:00

Properly setup seed in RNG

(cherry picked from commit 6280be46a6)
This commit is contained in:
Chaosus
2019-03-17 20:51:51 +03:00
committed by Rémi Verschelde
parent 29a6e7d306
commit 1dd72dca45
4 changed files with 15 additions and 5 deletions

View File

@@ -13,3 +13,13 @@ uint32_t pcg32_random_r(pcg32_random_t* rng)
uint32_t rot = oldstate >> 59u;
return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
}
// Source from http://www.pcg-random.org/downloads/pcg-c-basic-0.9.zip
void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate, uint64_t initseq)
{
rng->state = 0U;
rng->inc = (initseq << 1u) | 1u;
pcg32_random_r(rng);
rng->state += initstate;
pcg32_random_r(rng);
}