summaryrefslogtreecommitdiffstats
path: root/source/cNoise.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-29 22:15:03 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-29 22:15:03 +0200
commite49313202c759f70f6cf1113c8b53471122eb7da (patch)
treebf2016820ab3715c7a7dfcf06f1e99bc93c48cac /source/cNoise.cpp
parentChunk generator outputs its performance in chunks per second (diff)
downloadcuberite-e49313202c759f70f6cf1113c8b53471122eb7da.tar
cuberite-e49313202c759f70f6cf1113c8b53471122eb7da.tar.gz
cuberite-e49313202c759f70f6cf1113c8b53471122eb7da.tar.bz2
cuberite-e49313202c759f70f6cf1113c8b53471122eb7da.tar.lz
cuberite-e49313202c759f70f6cf1113c8b53471122eb7da.tar.xz
cuberite-e49313202c759f70f6cf1113c8b53471122eb7da.tar.zst
cuberite-e49313202c759f70f6cf1113c8b53471122eb7da.zip
Diffstat (limited to '')
-rw-r--r--source/cNoise.cpp74
1 files changed, 73 insertions, 1 deletions
diff --git a/source/cNoise.cpp b/source/cNoise.cpp
index 2dd26e5aa..b4e7a5752 100644
--- a/source/cNoise.cpp
+++ b/source/cNoise.cpp
@@ -183,6 +183,10 @@ float cNoise::SSE_CubicNoise2D( float a_X, float a_Y ) const
}
#endif
+
+
+
+
/******************
* Interpolated (and 1 smoothed) noise in 3-dimensions
**/
@@ -216,6 +220,10 @@ float cNoise::CosineNoise3D( float a_X, float a_Y, float a_Z ) const
return CosineInterpolate( interp1, interp2, FracZ );
}
+
+
+
+
float cNoise::CubicNoise3D( float a_X, float a_Y, float a_Z ) const
{
const int BaseX = FAST_FLOOR( a_X );
@@ -281,6 +289,10 @@ float cNoise::CubicNoise3D( float a_X, float a_Y, float a_Z ) const
return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ );
}
+
+
+
+
/******************
* Private
**/
@@ -300,6 +312,66 @@ __m128 cNoise::CubicInterpolate4( const __m128 & a_A, const __m128 & a_B, const
}
#endif
+
+
+
+
+void IntArrayLinearInterpolate2D(
+ int * a_Array,
+ int a_SizeX, int a_SizeY, // Dimensions of the array
+ int a_AnchorStepX, int a_AnchorStepY // Distances between the anchor points in each direction
+)
+{
+ // First interpolate columns where the anchor points are:
+ int LastYCell = a_SizeY - a_AnchorStepY;
+ for (int y = 0; y < LastYCell; y += a_AnchorStepY)
+ {
+ int Idx = a_SizeX * y;
+ for (int x = 0; x < a_SizeX; x += a_AnchorStepX)
+ {
+ int StartValue = a_Array[Idx];
+ int EndValue = a_Array[Idx + a_SizeX * a_AnchorStepY];
+ int Diff = EndValue - StartValue;
+ for (int CellY = 1; CellY < a_AnchorStepY; CellY++)
+ {
+ a_Array[Idx + a_SizeX * CellY] = StartValue + CellY * Diff / a_AnchorStepY;
+ } // for CellY
+ Idx += a_AnchorStepX;
+ } // for x
+ } // for y
+
+ // Now interpolate in rows, each row has values in the anchor columns
+ int LastXCell = a_SizeX - a_AnchorStepX;
+ for (int y = 0; y < a_SizeY; y++)
+ {
+ int Idx = a_SizeX * y;
+ for (int x = 0; x < LastXCell; x += a_AnchorStepX)
+ {
+ int StartValue = a_Array[Idx];
+ int EndValue = a_Array[Idx + a_AnchorStepX];
+ int Diff = EndValue - StartValue;
+ for (int CellX = 1; CellX < a_AnchorStepX; CellX++)
+ {
+ a_Array[Idx + CellX] = StartValue + CellX * Diff / a_AnchorStepX;
+ } // for CellY
+ Idx += a_AnchorStepX;
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
#if NOISE_USE_INLINE
# include "cNoise.inc"
-#endif \ No newline at end of file
+#endif
+
+
+
+