aboutsummaryrefslogtreecommitdiff
path: root/src/util/numeric.cpp
diff options
context:
space:
mode:
authorLexi Hale <5723574+velartrill@users.noreply.github.com>2022-07-13 11:57:12 +0200
committerGitHub <noreply@github.com>2022-07-13 11:57:12 +0200
commit20bd6bdb685af11548c35d3a48e5aa33f4222397 (patch)
tree6f60bad900cdb0ea28606bfe3f860b4948eeb277 /src/util/numeric.cpp
parent8724fe6e3fc2b6c0b78123f1f95fd8c6c6817dd5 (diff)
downloadhax-minetest-server-20bd6bdb685af11548c35d3a48e5aa33f4222397.tar.gz
hax-minetest-server-20bd6bdb685af11548c35d3a48e5aa33f4222397.zip
Animated particlespawners and more (#11545)
Co-authored-by: Lars Mueller <appgurulars@gmx.de> Co-authored-by: sfan5 <sfan5@live.de> Co-authored-by: Dmitry Kostenko <codeforsmile@gmail.com>
Diffstat (limited to 'src/util/numeric.cpp')
-rw-r--r--src/util/numeric.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/numeric.cpp b/src/util/numeric.cpp
index 702ddce95..aa3bb843d 100644
--- a/src/util/numeric.cpp
+++ b/src/util/numeric.cpp
@@ -46,11 +46,22 @@ void myrand_bytes(void *out, size_t len)
g_pcgrand.bytes(out, len);
}
+float myrand_float()
+{
+ u32 uv = g_pcgrand.next();
+ return (float)uv / (float)U32_MAX;
+}
+
int myrand_range(int min, int max)
{
return g_pcgrand.range(min, max);
}
+float myrand_range(float min, float max)
+{
+ return (max-min) * myrand_float() + min;
+}
+
/*
64-bit unaligned version of MurmurHash