diff options
Diffstat (limited to 'src/Math/Random.hpp')
| -rw-r--r-- | src/Math/Random.hpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Math/Random.hpp b/src/Math/Random.hpp index ab94871..d363694 100644 --- a/src/Math/Random.hpp +++ b/src/Math/Random.hpp @@ -1,27 +1,27 @@ #pragma once -#include "array" +#include <array> #include "Common.hpp" namespace Math::Random { -std::array<uint8_t, 4> break_float(float f); -float to_float(uint8_t u); +std::array<U8, 4> break_float(F32 f); +F32 to_float(U8 u); -uint8_t hash(uint8_t x); +U8 hash(U8 x); -float random(); +Real random(); -template <size_t D> +template <USize D> struct Noise { - float at(Vector<D> pos) const { - uint8_t to_hash[D * 4]; - for (int i = 0; i < D; i++) { + Real at(Vector<D> pos) const { + U8 to_hash[D * 4]; + for (Int i = 0; i < D; i++) { auto b = break_float(pos[i]); to_hash[i*4] = b[0]; to_hash[i*4+1] = b[1]; to_hash[i*4+2] = b[2]; to_hash[i*4+3] = b[3]; } - uint8_t h = 0; - for (int i = 0; i < D * 4; i++) { + U8 h = 0; + for (Int i = 0; i < D * 4; i++) { h = hash(h) + to_hash[i]; } return to_float(h); |
