diff options
author | Lexi Hale <5723574+velartrill@users.noreply.github.com> | 2022-07-13 11:57:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 11:57:12 +0200 |
commit | 20bd6bdb685af11548c35d3a48e5aa33f4222397 (patch) | |
tree | 6f60bad900cdb0ea28606bfe3f860b4948eeb277 /src/util/numeric.h | |
parent | 8724fe6e3fc2b6c0b78123f1f95fd8c6c6817dd5 (diff) | |
download | minetest-20bd6bdb685af11548c35d3a48e5aa33f4222397.tar.gz minetest-20bd6bdb685af11548c35d3a48e5aa33f4222397.tar.bz2 minetest-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.h')
-rw-r--r-- | src/util/numeric.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h index 32a6f4312..265046a63 100644 --- a/src/util/numeric.h +++ b/src/util/numeric.h @@ -223,6 +223,8 @@ u32 myrand(); void mysrand(unsigned int seed); void myrand_bytes(void *out, size_t len); int myrand_range(int min, int max); +float myrand_range(float min, float max); +float myrand_float(); /* Miscellaneous functions @@ -446,3 +448,24 @@ inline irr::video::SColor multiplyColorValue(const irr::video::SColor &color, fl core::clamp<u32>(color.getGreen() * mod, 0, 255), core::clamp<u32>(color.getBlue() * mod, 0, 255)); } + +template <typename T> inline T numericAbsolute(T v) { return v < 0 ? T(-v) : v; } +template <typename T> inline T numericSign(T v) { return T(v < 0 ? -1 : (v == 0 ? 0 : 1)); } + +inline v3f vecAbsolute(v3f v) +{ + return v3f( + numericAbsolute(v.X), + numericAbsolute(v.Y), + numericAbsolute(v.Z) + ); +} + +inline v3f vecSign(v3f v) +{ + return v3f( + numericSign(v.X), + numericSign(v.Y), + numericSign(v.Z) + ); +} |