summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-11-18 23:21:57 +0100
committerMattes D <github@xoft.cz>2014-11-18 23:21:57 +0100
commitc048f2bd95bd74c54f32e37978da47d450ac567b (patch)
treec18233fbf4daaffcdd62b9f08b7ff6fb647dcbe0 /src/Generating
parentMoved all Noise-related files into a separate folder. (diff)
downloadcuberite-c048f2bd95bd74c54f32e37978da47d450ac567b.tar
cuberite-c048f2bd95bd74c54f32e37978da47d450ac567b.tar.gz
cuberite-c048f2bd95bd74c54f32e37978da47d450ac567b.tar.bz2
cuberite-c048f2bd95bd74c54f32e37978da47d450ac567b.tar.lz
cuberite-c048f2bd95bd74c54f32e37978da47d450ac567b.tar.xz
cuberite-c048f2bd95bd74c54f32e37978da47d450ac567b.tar.zst
cuberite-c048f2bd95bd74c54f32e37978da47d450ac567b.zip
Diffstat (limited to 'src/Generating')
-rw-r--r--src/Generating/Noise3DGenerator.cpp53
-rw-r--r--src/Generating/Noise3DGenerator.h5
2 files changed, 54 insertions, 4 deletions
diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp
index 654e9d01f..d051948c4 100644
--- a/src/Generating/Noise3DGenerator.cpp
+++ b/src/Generating/Noise3DGenerator.cpp
@@ -6,6 +6,7 @@
#include "Globals.h"
#include "Noise3DGenerator.h"
#include "../OSSupport/File.h"
+#include "../OSSupport/Timer.h"
#include "../IniFile.h"
#include "../LinearInterpolation.h"
#include "../LinearUpscale.h"
@@ -61,6 +62,50 @@ public:
+#if 0
+// Perform speed test of the cInterpolNoise class
+static class cInterpolNoiseSpeedTest
+{
+public:
+ cInterpolNoiseSpeedTest(void)
+ {
+ printf("Evaluating 3D noise performance...\n");
+ static const int SIZE_X = 128;
+ static const int SIZE_Y = 128;
+ static const int SIZE_Z = 128;
+ static const NOISE_DATATYPE MUL = 80;
+ std::unique_ptr<NOISE_DATATYPE[]> arr(new NOISE_DATATYPE[SIZE_X * SIZE_Y * SIZE_Z]);
+ cTimer timer;
+
+ // Test the cInterpolNoise:
+ cInterpolNoise<Interp5Deg> interpNoise(1);
+ long long start = timer.GetNowTime();
+ for (int i = 0; i < 30; i++)
+ {
+ interpNoise.Generate3D(arr.get(), SIZE_X, SIZE_Y, SIZE_Z, MUL * i, MUL * i + MUL, 0, MUL, 0, MUL);
+ }
+ long long end = timer.GetNowTime();
+ printf("InterpolNoise took %.02f sec\n", static_cast<float>(end - start) / 1000);
+
+ // Test the cCubicNoise:
+ cCubicNoise cubicNoise(1);
+ start = timer.GetNowTime();
+ for (int i = 0; i < 30; i++)
+ {
+ cubicNoise.Generate3D(arr.get(), SIZE_X, SIZE_Y, SIZE_Z, MUL * i, MUL * i + MUL, 0, MUL, 0, MUL);
+ }
+ end = timer.GetNowTime();
+ printf("CubicNoise took %.02f sec\n", static_cast<float>(end - start) / 1000);
+ printf("3D noise performance comparison finished.\n");
+ }
+
+} g_InterpolNoiseSpeedTest;
+#endif
+
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// cNoise3DGenerator:
@@ -69,9 +114,11 @@ cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) :
m_Perlin(1000),
m_Cubic(1000)
{
- m_Perlin.AddOctave(1, (NOISE_DATATYPE)0.5);
- m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 1);
- m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 2);
+ m_Perlin.AddOctave(1, 1);
+ m_Perlin.AddOctave(2, 0.5);
+ m_Perlin.AddOctave(4, 0.25);
+ m_Perlin.AddOctave(8, 0.125);
+ m_Perlin.AddOctave(16, 0.0625);
#if 0
// DEBUG: Test the noise generation:
diff --git a/src/Generating/Noise3DGenerator.h b/src/Generating/Noise3DGenerator.h
index 8a6e97e1c..d198c5498 100644
--- a/src/Generating/Noise3DGenerator.h
+++ b/src/Generating/Noise3DGenerator.h
@@ -14,6 +14,7 @@
#include "ComposableGenerator.h"
#include "../Noise/Noise.h"
+#include "../Noise/InterpolNoise.h"
@@ -43,7 +44,9 @@ protected:
static const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
static const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
- cPerlinNoise m_Perlin; // The base 3D noise source for the actual composition
+ /** The base 3D noise source for the actual composition */
+ cOctavedNoise<cInterp5DegNoise> m_Perlin;
+
cCubicNoise m_Cubic; // The noise used for heightmap directing
int m_SeaLevel;