From 20bd6bdb685af11548c35d3a48e5aa33f4222397 Mon Sep 17 00:00:00 2001 From: Lexi Hale <5723574+velartrill@users.noreply.github.com> Date: Wed, 13 Jul 2022 11:57:12 +0200 Subject: Animated particlespawners and more (#11545) Co-authored-by: Lars Mueller Co-authored-by: sfan5 Co-authored-by: Dmitry Kostenko --- src/util/numeric.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/util/numeric.cpp') 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 -- cgit v1.2.3