Browse Source

love.math.noise now returns values in the range of [0, 1] instead of [-1, 1]

Alex Szpakowski 12 years ago
parent
commit
5c0066332f
1 changed files with 5 additions and 5 deletions
  1. 5 5
      src/modules/math/MathModule.h

+ 5 - 5
src/modules/math/MathModule.h

@@ -139,7 +139,7 @@ public:
 	/**
 	/**
 	 * Calculate Simplex noise for the specified coordinate(s).
 	 * Calculate Simplex noise for the specified coordinate(s).
 	 *
 	 *
-	 * @return Noise value in the range of [-1,1].
+	 * @return Noise value in the range of [0, 1].
 	 **/
 	 **/
 	float noise(float x) const;
 	float noise(float x) const;
 	float noise(float x, float y) const;
 	float noise(float x, float y) const;
@@ -156,22 +156,22 @@ private:
 
 
 inline float Math::noise(float x) const
 inline float Math::noise(float x) const
 {
 {
-	return SimplexNoise1234::noise(x);
+	return SimplexNoise1234::noise(x) * 0.5f + 0.5f;
 }
 }
 
 
 inline float Math::noise(float x, float y) const
 inline float Math::noise(float x, float y) const
 {
 {
-	return SimplexNoise1234::noise(x, y);
+	return SimplexNoise1234::noise(x, y) * 0.5f + 0.5f;
 }
 }
 
 
 inline float Math::noise(float x, float y, float z) const
 inline float Math::noise(float x, float y, float z) const
 {
 {
-	return SimplexNoise1234::noise(x, y, z);
+	return SimplexNoise1234::noise(x, y, z) * 0.5f + 0.5f;
 }
 }
 
 
 inline float Math::noise(float x, float y, float z, float w) const
 inline float Math::noise(float x, float y, float z, float w) const
 {
 {
-	return SimplexNoise1234::noise(x, y, z, w);
+	return SimplexNoise1234::noise(x, y, z, w) * 0.5f + 0.5f;
 }
 }
 
 
 } // math
 } // math