summaryrefslogtreecommitdiffstats
path: root/src
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
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/CMakeLists.txt13
-rw-r--r--src/Chunk.cpp2
-rw-r--r--src/Enchantments.cpp2
-rw-r--r--src/Generating/BioGen.h2
-rw-r--r--src/Generating/Caves.h1
-rw-r--r--src/Generating/ChunkDesc.cpp2
-rw-r--r--src/Generating/CompoGen.h2
-rw-r--r--src/Generating/DistortedHeightmap.h1
-rw-r--r--src/Generating/EndGen.h2
-rw-r--r--src/Generating/FinishGen.cpp1
-rw-r--r--src/Generating/FinishGen.h2
-rw-r--r--src/Generating/GridStructGen.h2
-rw-r--r--src/Generating/HeiGen.h2
-rw-r--r--src/Generating/MineShafts.h1
-rw-r--r--src/Generating/Noise3DGenerator.h2
-rw-r--r--src/Generating/PieceGenerator.h2
-rw-r--r--src/Generating/Ravines.h1
-rw-r--r--src/Generating/StructGen.h2
-rw-r--r--src/Generating/Trees.h2
-rw-r--r--src/ItemGrid.cpp2
-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
-rw-r--r--src/VoronoiMap.h2
26 files changed, 56 insertions, 80 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a8dfc394c..9720c9941 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,6 +9,7 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include
set(FOLDERS
OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ Bindings
WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs
+ Noise
)
SET (SRCS
@@ -50,7 +51,6 @@ SET (SRCS
MobProximityCounter.cpp
MobSpawner.cpp
MonsterConfig.cpp
- Noise.cpp
ProbabDistrib.cpp
RankManager.cpp
RCONServer.cpp
@@ -65,7 +65,8 @@ SET (SRCS
VoronoiMap.cpp
WebAdmin.cpp
World.cpp
- main.cpp)
+ main.cpp
+)
SET (HDRS
AllocationPool.h
@@ -120,11 +121,8 @@ SET (HDRS
MobProximityCounter.h
MobSpawner.h
MonsterConfig.h
- Noise.h
- OctavedNoise.h
ProbabDistrib.h
RankManager.h
- RidgedNoise.h
RCONServer.h
Root.h
Scoreboard.h
@@ -139,7 +137,8 @@ SET (HDRS
VoronoiMap.h
WebAdmin.h
World.h
- XMLParser.h)
+ XMLParser.h
+)
include_directories(".")
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/sqlite")
@@ -316,7 +315,7 @@ endif ()
if (NOT MSVC)
target_link_libraries(${EXECUTABLE}
- OSSupport HTTPServer Bindings Items Blocks
+ OSSupport HTTPServer Bindings Items Blocks Noise
Protocol Generating Generating_Prefabs WorldStorage
Mobs Entities Simulator UI BlockEntities PolarSSL++
)
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index a0224322a..d9333afc7 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -25,7 +25,7 @@
#include "BlockEntities/FlowerPotEntity.h"
#include "Entities/Pickup.h"
#include "Item.h"
-#include "Noise.h"
+#include "Noise/Noise.h"
#include "Root.h"
#include "MersenneTwister.h"
#include "Entities/Player.h"
diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp
index 80a9810b6..36c451b81 100644
--- a/src/Enchantments.cpp
+++ b/src/Enchantments.cpp
@@ -6,7 +6,7 @@
#include "Enchantments.h"
#include "WorldStorage/FastNBT.h"
#include "FastRandom.h"
-#include "Noise.h"
+#include "Noise/Noise.h"
diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h
index 5fd0844d9..13fb40c5f 100644
--- a/src/Generating/BioGen.h
+++ b/src/Generating/BioGen.h
@@ -15,7 +15,7 @@ Interfaces to the various biome generators:
#pragma once
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
#include "../VoronoiMap.h"
diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h
index 0e17acf9e..691ef3e62 100644
--- a/src/Generating/Caves.h
+++ b/src/Generating/Caves.h
@@ -13,7 +13,6 @@
#pragma once
#include "GridStructGen.h"
-#include "../Noise.h"
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 020d3bd0f..042b688b7 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -7,7 +7,7 @@
#include "ChunkDesc.h"
#include "../BlockArea.h"
#include "../Cuboid.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
#include "../BlockEntities/BlockEntity.h"
diff --git a/src/Generating/CompoGen.h b/src/Generating/CompoGen.h
index b145b6ba3..c65a07fe8 100644
--- a/src/Generating/CompoGen.h
+++ b/src/Generating/CompoGen.h
@@ -17,7 +17,7 @@
#pragma once
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/Generating/DistortedHeightmap.h b/src/Generating/DistortedHeightmap.h
index d073f29e4..955e57a1e 100644
--- a/src/Generating/DistortedHeightmap.h
+++ b/src/Generating/DistortedHeightmap.h
@@ -11,7 +11,6 @@
#include "ComposableGenerator.h"
#include "HeiGen.h"
-#include "../Noise.h"
diff --git a/src/Generating/EndGen.h b/src/Generating/EndGen.h
index 322061810..c2278c1e1 100644
--- a/src/Generating/EndGen.h
+++ b/src/Generating/EndGen.h
@@ -10,7 +10,7 @@
#pragma once
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index b8afac09a..42ecdf8a8 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -10,7 +10,6 @@
#include "Globals.h"
#include "FinishGen.h"
-#include "../Noise.h"
#include "../BlockID.h"
#include "../Simulator/FluidSimulator.h" // for cFluidSimulator::CanWashAway()
#include "../Simulator/FireSimulator.h"
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index 4a08d70c8..991a85787 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -16,7 +16,7 @@
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
#include "../ProbabDistrib.h"
diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h
index 03131fce9..b92fb2e9d 100644
--- a/src/Generating/GridStructGen.h
+++ b/src/Generating/GridStructGen.h
@@ -10,7 +10,7 @@
#pragma once
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h
index 6ae5ba362..b3c9483fb 100644
--- a/src/Generating/HeiGen.h
+++ b/src/Generating/HeiGen.h
@@ -15,7 +15,7 @@ Interfaces to the various height generators:
#pragma once
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/Generating/MineShafts.h b/src/Generating/MineShafts.h
index 2850db571..efb11cfee 100644
--- a/src/Generating/MineShafts.h
+++ b/src/Generating/MineShafts.h
@@ -10,7 +10,6 @@
#pragma once
#include "GridStructGen.h"
-#include "../Noise.h"
diff --git a/src/Generating/Noise3DGenerator.h b/src/Generating/Noise3DGenerator.h
index 92cfc32b7..8a6e97e1c 100644
--- a/src/Generating/Noise3DGenerator.h
+++ b/src/Generating/Noise3DGenerator.h
@@ -13,7 +13,7 @@
#pragma once
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h
index f06029280..43ffed7a2 100644
--- a/src/Generating/PieceGenerator.h
+++ b/src/Generating/PieceGenerator.h
@@ -20,7 +20,7 @@ Each uses a slightly different approach to generating:
#include "../Defines.h"
#include "../Cuboid.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/Generating/Ravines.h b/src/Generating/Ravines.h
index 3e41c5ce6..b11037433 100644
--- a/src/Generating/Ravines.h
+++ b/src/Generating/Ravines.h
@@ -10,7 +10,6 @@
#pragma once
#include "GridStructGen.h"
-#include "../Noise.h"
diff --git a/src/Generating/StructGen.h b/src/Generating/StructGen.h
index 906fdd722..d3b0b5544 100644
--- a/src/Generating/StructGen.h
+++ b/src/Generating/StructGen.h
@@ -14,7 +14,7 @@
#pragma once
#include "ComposableGenerator.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/Generating/Trees.h b/src/Generating/Trees.h
index c9eb7de80..cc0fa87d9 100644
--- a/src/Generating/Trees.h
+++ b/src/Generating/Trees.h
@@ -18,7 +18,7 @@ logs can overwrite others(leaves), but others shouldn't overwrite logs. This is
#pragma once
#include "../ChunkDef.h"
-#include "../Noise.h"
+#include "../Noise/Noise.h"
diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp
index 55fb36a17..d49ea9df1 100644
--- a/src/ItemGrid.cpp
+++ b/src/ItemGrid.cpp
@@ -6,7 +6,7 @@
#include "Globals.h"
#include "ItemGrid.h"
#include "Items/ItemHandler.h"
-#include "Noise.h"
+#include "Noise/Noise.h"
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
diff --git a/src/VoronoiMap.h b/src/VoronoiMap.h
index dfb11e9ce..56022849e 100644
--- a/src/VoronoiMap.h
+++ b/src/VoronoiMap.h
@@ -9,7 +9,7 @@
#pragma once
-#include "Noise.h"
+#include "Noise/Noise.h"