summaryrefslogtreecommitdiffstats
path: root/core/math/random_pcg.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-06-12 15:21:58 +0200
committerGitHub <noreply@github.com>2019-06-12 15:21:58 +0200
commit73960e585bc9aae058abc590a784a8dd19af5a34 (patch)
tree7f1be48c37890f894fc4223cbef0ce5247089e8f /core/math/random_pcg.cpp
parent704f2c5d857cd057e65eef0627ed3dbff348f178 (diff)
parent5f1b9a23132408160cf0b99e1e162413ab0e382b (diff)
downloadredot-engine-73960e585bc9aae058abc590a784a8dd19af5a34.tar.gz
Merge pull request #27193 from toasteater/fix/pcg-randf
Improved uniformity of RandomPCG::randf.
Diffstat (limited to 'core/math/random_pcg.cpp')
-rw-r--r--core/math/random_pcg.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/core/math/random_pcg.cpp b/core/math/random_pcg.cpp
index 8351bd138e..00c0af515d 100644
--- a/core/math/random_pcg.cpp
+++ b/core/math/random_pcg.cpp
@@ -43,13 +43,9 @@ void RandomPCG::randomize() {
}
double RandomPCG::random(double p_from, double p_to) {
- unsigned int r = rand();
- double ret = (double)r / (double)RANDOM_MAX;
- return (ret) * (p_to - p_from) + p_from;
+ return randd() * (p_to - p_from) + p_from;
}
float RandomPCG::random(float p_from, float p_to) {
- unsigned int r = rand();
- float ret = (float)r / (float)RANDOM_MAX;
- return (ret) * (p_to - p_from) + p_from;
+ return randf() * (p_to - p_from) + p_from;
}