summaryrefslogtreecommitdiffstats
path: root/src/Noise
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-11-18 12:07:08 +0100
committerMattes D <github@xoft.cz>2014-11-18 12:07:08 +0100
commit2467d29a4ec63936d0af20ae4d5cfb8e897e75be (patch)
treec144dc21b6c297edc011c8dcaf5f5b13d49aee65 /src/Noise
parentRefactored cRidgedNoise into a separate template. (diff)
downloadcuberite-2467d29a4ec63936d0af20ae4d5cfb8e897e75be.tar
cuberite-2467d29a4ec63936d0af20ae4d5cfb8e897e75be.tar.gz
cuberite-2467d29a4ec63936d0af20ae4d5cfb8e897e75be.tar.bz2
cuberite-2467d29a4ec63936d0af20ae4d5cfb8e897e75be.tar.lz
cuberite-2467d29a4ec63936d0af20ae4d5cfb8e897e75be.tar.xz
cuberite-2467d29a4ec63936d0af20ae4d5cfb8e897e75be.tar.zst
cuberite-2467d29a4ec63936d0af20ae4d5cfb8e897e75be.zip
Diffstat (limited to '')
-rw-r--r--src/Noise/CMakeLists.txt21
-rw-r--r--src/Noise/Noise.cpp (renamed from src/Noise.cpp)24
-rw-r--r--src/Noise/Noise.h (renamed from src/Noise.h)43
-rw-r--r--src/Noise/OctavedNoise.h (renamed from src/OctavedNoise.h)0
-rw-r--r--src/Noise/RidgedNoise.h (renamed from src/RidgedNoise.h)0
5 files changed, 35 insertions, 53 deletions
diff --git a/src/Noise/CMakeLists.txt b/src/Noise/CMakeLists.txt
new file mode 100644
index 000000000..e1837500f
--- /dev/null
+++ b/src/Noise/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+cmake_minimum_required (VERSION 2.6)
+project (MCServer)
+
+include_directories ("${PROJECT_SOURCE_DIR}/../")
+
+SET (SRCS
+ Noise.cpp
+)
+
+SET (HDRS
+ Noise.h
+ OctavedNoise.h
+ RidgedNoise.h
+)
+
+if(NOT MSVC)
+ add_library(Noise ${SRCS} ${HDRS})
+
+ target_link_libraries(Noise OSSupport)
+endif()
diff --git a/src/Noise.cpp b/src/Noise/Noise.cpp
index c4a7e2d5f..509be7d6c 100644
--- a/src/Noise.cpp
+++ b/src/Noise/Noise.cpp
@@ -695,13 +695,6 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
////////////////////////////////////////////////////////////////////////////////
// cCubicNoise:
-#ifdef _DEBUG
- int cCubicNoise::m_NumSingleX = 0;
- int cCubicNoise::m_NumSingleXY = 0;
- int cCubicNoise::m_NumSingleY = 0;
- int cCubicNoise::m_NumCalls = 0;
-#endif // _DEBUG
-
cCubicNoise::cCubicNoise(int a_Seed) :
m_Noise(a_Seed)
{
@@ -740,23 +733,6 @@ void cCubicNoise::Generate2D(
Cell.InitWorkRnds(FloorX[0], FloorY[0]);
- #ifdef _DEBUG
- // Statistics on the noise-space coords:
- if (NumSameX == 1)
- {
- m_NumSingleX++;
- if (NumSameY == 1)
- {
- m_NumSingleXY++;
- }
- }
- if (NumSameY == 1)
- {
- m_NumSingleY++;
- }
- m_NumCalls++;
- #endif // _DEBUG
-
// Calculate query values using Cell:
int FromY = 0;
for (int y = 0; y < NumSameY; y++)
diff --git a/src/Noise.h b/src/Noise/Noise.h
index e616155d5..323194bfd 100644
--- a/src/Noise.h
+++ b/src/Noise/Noise.h
@@ -65,19 +65,15 @@ private:
class cCubicNoise
{
public:
- static const int MAX_SIZE = 512; ///< Maximum size of each dimension of the query arrays.
+ /** Maximum size of each dimension of the query arrays. */
+ static const int MAX_SIZE = 512;
+ /** Creates a new instance with the specified seed. */
cCubicNoise(int a_Seed);
- void Generate1D(
- NOISE_DATATYPE * a_Array, ///< Array to generate into
- int a_SizeX, ///< Count of the array
- NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX ///< Noise-space coords of the array
- ) const;
-
-
+ /** Fills a 2D array with the values of the noise. */
void Generate2D(
NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y]
int a_SizeX, int a_SizeY, ///< Count of the array, in each direction
@@ -86,6 +82,7 @@ public:
) const;
+ /** Fills a 3D array with the values of the noise. */
void Generate3D(
NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z]
int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction
@@ -95,34 +92,22 @@ public:
) const;
protected:
- typedef NOISE_DATATYPE Workspace1D[4];
- typedef NOISE_DATATYPE Workspace2D[4][4];
- cNoise m_Noise; // Used for integral rnd values
-
- #ifdef _DEBUG
- // Statistics on the noise-space coords:
- static int m_NumSingleX;
- static int m_NumSingleXY;
- static int m_NumSingleY;
- static int m_NumCalls;
- #endif // _DEBUG
-
- /// Calculates the integral and fractional parts along one axis.
+ /** Noise used for integral random values. */
+ cNoise m_Noise;
+
+
+ /** Calculates the integral and fractional parts along one axis.
+ a_Floor will receive the integral parts (array of a_Size ints).
+ a_Frac will receive the fractional parts (array of a_Size floats).
+ a_Same will receive the counts of items that have the same integral parts (array of up to a_Size ints).
+ a_NumSame will receive the count of a_Same elements (total count of different integral parts). */
void CalcFloorFrac(
int a_Size,
NOISE_DATATYPE a_Start, NOISE_DATATYPE a_End,
int * a_Floor, NOISE_DATATYPE * a_Frac,
int * a_Same, int & a_NumSame
) const;
-
- void UpdateWorkRnds2DX(
- Workspace2D & a_WorkRnds,
- Workspace1D & a_Interps,
- int a_LastFloorX, int a_NewFloorX,
- int a_FloorY,
- NOISE_DATATYPE a_FractionY
- ) const;
} ;
diff --git a/src/OctavedNoise.h b/src/Noise/OctavedNoise.h
index 166d2c205..166d2c205 100644
--- a/src/OctavedNoise.h
+++ b/src/Noise/OctavedNoise.h
diff --git a/src/RidgedNoise.h b/src/Noise/RidgedNoise.h
index 69b480f60..69b480f60 100644
--- a/src/RidgedNoise.h
+++ b/src/Noise/RidgedNoise.h