From fe2baedc760c2f29e2c720f6b1132a2de33c5430 Mon Sep 17 00:00:00 2001 From: Mel Date: Sat, 8 Jul 2023 03:25:44 +0200 Subject: Use own size types --- src/Math/Random.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Math/Random.hpp') 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 #include "Common.hpp" namespace Math::Random { -std::array break_float(float f); -float to_float(uint8_t u); +std::array break_float(F32 f); +F32 to_float(U8 u); -uint8_t hash(uint8_t x); +U8 hash(U8 x); -float random(); +Real random(); -template +template struct Noise { - float at(Vector pos) const { - uint8_t to_hash[D * 4]; - for (int i = 0; i < D; i++) { + Real at(Vector 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); -- cgit 1.4.1