]> git.localhorst.tv Git - blank.git/blobdiff - src/noise.hpp
be smart about other stuff ^^
[blank.git] / src / noise.hpp
index 26e37668b00f609fdfd2747a2ed6a3e044031729..cbfd48ee441ad62722490a8f51e4c4150a58484a 100644 (file)
@@ -12,20 +12,20 @@ class GaloisLFSR {
 
 public:
        // seed should be non-zero
-       explicit GaloisLFSR(std::uint64_t seed);
+       explicit GaloisLFSR(std::uint64_t seed) noexcept;
 
        // get the next bit
-       bool operator ()();
+       bool operator ()() noexcept;
 
        template<class T>
-       void operator ()(T &out) {
+       T operator ()(T &out) noexcept {
                constexpr int num_bits =
                        std::numeric_limits<T>::digits +
                        std::numeric_limits<T>::is_signed;
                for (int i = 0; i < num_bits; ++i) {
                        operator ()();
                }
-               out = static_cast<T>(state);
+               return out = static_cast<T>(state);
        }
 
 private:
@@ -40,16 +40,18 @@ private:
 class SimplexNoise {
 
 public:
-       explicit SimplexNoise(unsigned int seed);
+       explicit SimplexNoise(unsigned int seed) noexcept;
 
-       float operator ()(const glm::vec3 &) const;
+       float operator ()(const glm::vec3 &) const noexcept;
 
 private:
-       unsigned char Perm(size_t idx) const;
-       const glm::vec3 &Grad(size_t idx) const;
+       int Perm(int idx) const noexcept;
+       int Perm12(int idx) const noexcept;
+       const glm::vec3 &Grad(int idx) const noexcept;
 
 private:
-       unsigned char perm[512];
+       int perm[512];
+       int perm12[512];
        glm::vec3 grad[12];
 
 };
@@ -59,9 +61,9 @@ private:
 class WorleyNoise {
 
 public:
-       explicit WorleyNoise(unsigned int seed);
+       explicit WorleyNoise(unsigned int seed) noexcept;
 
-       float operator ()(const glm::vec3 &) const;
+       float operator ()(const glm::vec3 &) const noexcept;
 
 private:
        const unsigned int seed;