Added love.math.noise(x, [y, z, w]). Calculates the 1D, 2D, 3D or 4D Simplex noise value at a particular coordinate

This commit is contained in:
Alex Szpakowski
2013-05-01 18:26:40 -07:00
parent 1edfbb766f
commit 9ccf013570
6 changed files with 618 additions and 0 deletions
+34
View File
@@ -27,6 +27,10 @@
#include "common/Module.h"
#include "common/math.h"
#include "common/int.h"
#include "common/StringMap.h"
// Noise
#include "libraries/noise1234/simplexnoise1234.h"
// STL
#include <limits>
@@ -106,6 +110,16 @@ public:
**/
std::vector<Triangle> triangulate(const std::vector<vertex> &polygon);
/**
* Calculate Simplex noise for the specified coordinate(s).
*
* @return Noise value in the range of [0,1].
**/
float simplexNoise1(float x) const;
float simplexNoise2(float x, float y) const;
float simplexNoise3(float x, float y, float z) const;
float simplexNoise4(float x, float y, float z, float w) const;
static Math instance;
private:
@@ -114,6 +128,26 @@ private:
}; // Math
inline float Math::simplexNoise1(float x) const
{
return SimplexNoise1234::noise(x);
}
inline float Math::simplexNoise2(float x, float y) const
{
return SimplexNoise1234::noise(x, y);
}
inline float Math::simplexNoise3(float x, float y, float z) const
{
return SimplexNoise1234::noise(x, y, z);
}
inline float Math::simplexNoise4(float x, float y, float z, float w) const
{
return SimplexNoise1234::noise(x, y, z, w);
}
} // math
} // love