diff options
Diffstat (limited to 'core/math/random_pcg.cpp')
-rw-r--r-- | core/math/random_pcg.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/core/math/random_pcg.cpp b/core/math/random_pcg.cpp index e0768b9403..c39037747a 100644 --- a/core/math/random_pcg.cpp +++ b/core/math/random_pcg.cpp @@ -51,16 +51,8 @@ float RandomPCG::random(float p_from, float p_to) { } int RandomPCG::random(int p_from, int p_to) { - int range; - int min; - if (p_to > p_from) { - range = p_to - p_from + 1; - min = p_from; - } else if (p_to < p_from) { - range = p_from - p_to + 1; - min = p_to; - } else { // from == to + if (p_from == p_to) { return p_from; } - return rand(range) + min; + return rand(abs(p_from - p_to) + 1) + MIN(p_from, p_to); } |