diff options
author | MidZik <matt.idzik1@gmail.com> | 2019-03-06 21:25:51 -0600 |
---|---|---|
committer | MidZik <matt.idzik1@gmail.com> | 2019-03-07 02:45:18 -0600 |
commit | 4eccb58bc57ac66f929192066b65282a56d46545 (patch) | |
tree | 6d65a7e420ae79e3c20db9606ade09b4489740ee /core/math/random_pcg.cpp | |
parent | 38b12d25e90ea342dfdb123eafa47146af5ba6b1 (diff) | |
download | redot-engine-4eccb58bc57ac66f929192066b65282a56d46545.tar.gz |
Fixed get_seed() not returning the correct seed.
Diffstat (limited to 'core/math/random_pcg.cpp')
-rw-r--r-- | core/math/random_pcg.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/math/random_pcg.cpp b/core/math/random_pcg.cpp index 8bbcca88fe..8c324414e6 100644 --- a/core/math/random_pcg.cpp +++ b/core/math/random_pcg.cpp @@ -32,24 +32,24 @@ #include "core/os/os.h" -RandomPCG::RandomPCG(uint64_t seed, uint64_t inc) : +RandomPCG::RandomPCG(uint64_t p_seed, uint64_t p_inc) : pcg() { - pcg.state = seed; - pcg.inc = inc; + pcg.inc = p_inc; + seed(p_seed); } void RandomPCG::randomize() { seed(OS::get_singleton()->get_ticks_usec() * pcg.state + PCG_DEFAULT_INC_64); } -double RandomPCG::random(double from, double to) { +double RandomPCG::random(double p_from, double p_to) { unsigned int r = rand(); double ret = (double)r / (double)RANDOM_MAX; - return (ret) * (to - from) + from; + return (ret) * (p_to - p_from) + p_from; } -float RandomPCG::random(float from, float to) { +float RandomPCG::random(float p_from, float p_to) { unsigned int r = rand(); float ret = (float)r / (float)RANDOM_MAX; - return (ret) * (to - from) + from; + return (ret) * (p_to - p_from) + p_from; } |