summaryrefslogtreecommitdiff
path: root/thirdparty/misc/pcg.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-04-01 17:17:30 +0200
committerGitHub <noreply@github.com>2019-04-01 17:17:30 +0200
commit29a1202d39b0efb617a8ff4ee9764612f3e0124f (patch)
treeae139220628ef18ce35a14d47a5aaefab3cceae1 /thirdparty/misc/pcg.cpp
parent18ee888541de80307da68808f3996ae2b0a807ab (diff)
parent6280be46a6fb62b8833a9d55bff590fb209b0fc6 (diff)
Merge pull request #27171 from Chaosus/randfix
Properly setup seed in RNG
Diffstat (limited to 'thirdparty/misc/pcg.cpp')
-rw-r--r--thirdparty/misc/pcg.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/thirdparty/misc/pcg.cpp b/thirdparty/misc/pcg.cpp
index eac3b36d36..c421e16f89 100644
--- a/thirdparty/misc/pcg.cpp
+++ b/thirdparty/misc/pcg.cpp
@@ -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);
+}