]> git.localhorst.tv Git - blank.git/blobdiff - src/rand/SimplexNoise.hpp
some code reorganization
[blank.git] / src / rand / SimplexNoise.hpp
diff --git a/src/rand/SimplexNoise.hpp b/src/rand/SimplexNoise.hpp
new file mode 100644 (file)
index 0000000..7a7242b
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef BLANK_RAND_SIMPLEXNOISE_HPP_
+#define BLANK_RAND_SIMPLEXNOISE_HPP_
+
+#include <glm/glm.hpp>
+
+
+namespace blank {
+
+/// (3D only) adaptation of Stefan Gustavson's SimplexNoise java class
+class SimplexNoise {
+
+public:
+       explicit SimplexNoise(unsigned int seed) noexcept;
+
+       float operator ()(const glm::vec3 &) const noexcept;
+
+private:
+       int Perm(int idx) const noexcept;
+       int Perm12(int idx) const noexcept;
+       const glm::vec3 &Grad(int idx) const noexcept;
+
+private:
+       int perm[512];
+       int perm12[512];
+       glm::vec3 grad[12];
+
+};
+
+}
+
+#endif