summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-15 19:09:38 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-15 19:09:38 +0200
commite7238456dbc9355fc6cfaba4632448c7d6055661 (patch)
treefbc383667dfbb40e2de02d67d1e44c06303eec2d /source
parentFixed 2D linear upscale to compile on Linux, added a test for it. (diff)
downloadcuberite-e7238456dbc9355fc6cfaba4632448c7d6055661.tar
cuberite-e7238456dbc9355fc6cfaba4632448c7d6055661.tar.gz
cuberite-e7238456dbc9355fc6cfaba4632448c7d6055661.tar.bz2
cuberite-e7238456dbc9355fc6cfaba4632448c7d6055661.tar.lz
cuberite-e7238456dbc9355fc6cfaba4632448c7d6055661.tar.xz
cuberite-e7238456dbc9355fc6cfaba4632448c7d6055661.tar.zst
cuberite-e7238456dbc9355fc6cfaba4632448c7d6055661.zip
Diffstat (limited to '')
-rw-r--r--source/Generating/Noise3DGenerator.cpp77
-rw-r--r--source/Noise.cpp83
-rw-r--r--source/Noise.h10
3 files changed, 93 insertions, 77 deletions
diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp
index 79138aa9f..dcf84abeb 100644
--- a/source/Generating/Noise3DGenerator.cpp
+++ b/source/Generating/Noise3DGenerator.cpp
@@ -14,83 +14,6 @@
-void Debug3DNoise(NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase)
-{
- const int BUF_SIZE = 512;
- ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed
-
- // Save in XY cuts:
- cFile f1;
- if (f1.Open(Printf("%s_XY (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
- {
- for (int z = 0; z < a_SizeZ; z++)
- {
- for (int y = 0; y < a_SizeY; y++)
- {
- int idx = y * a_SizeX + z * a_SizeX * a_SizeY;
- unsigned char buf[BUF_SIZE];
- for (int x = 0; x < a_SizeX; x++)
- {
- buf[x] = (unsigned char)(std::min(255, std::max(0, (int)(128 + 32 * a_Noise[idx++]))));
- }
- f1.Write(buf, a_SizeX);
- } // for y
- unsigned char buf[BUF_SIZE];
- memset(buf, 0, a_SizeX);
- f1.Write(buf, a_SizeX);
- } // for z
- } // if (XY file open)
-
- cFile f2;
- if (f2.Open(Printf("%s_XZ (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
- {
- for (int y = 0; y < a_SizeY; y++)
- {
- for (int z = 0; z < a_SizeZ; z++)
- {
- int idx = y * a_SizeX + z * a_SizeX * a_SizeY;
- unsigned char buf[BUF_SIZE];
- for (int x = 0; x < a_SizeX; x++)
- {
- buf[x] = (unsigned char)(std::min(255, std::max(0, (int)(128 + 32 * a_Noise[idx++]))));
- }
- f2.Write(buf, a_SizeX);
- } // for z
- unsigned char buf[BUF_SIZE];
- memset(buf, 0, a_SizeX);
- f2.Write(buf, a_SizeX);
- } // for y
- } // if (XZ file open)
-}
-
-
-
-
-
-void Debug2DNoise(NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase)
-{
- const int BUF_SIZE = 512;
- ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed
-
- cFile f1;
- if (f1.Open(Printf("%s (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
- {
- for (int y = 0; y < a_SizeY; y++)
- {
- int idx = y * a_SizeX;
- unsigned char buf[BUF_SIZE];
- for (int x = 0; x < a_SizeX; x++)
- {
- buf[x] = (unsigned char)(std::min(255, std::max(0, (int)(128 + 32 * a_Noise[idx++]))));
- }
- f1.Write(buf, a_SizeX);
- } // for y
- } // if (file open)
-}
-
-
-
-
/*
// Perform an automatic test of upscaling upon program start (use breakpoints to debug):
diff --git a/source/Noise.cpp b/source/Noise.cpp
index 333dc8333..729641961 100644
--- a/source/Noise.cpp
+++ b/source/Noise.cpp
@@ -18,6 +18,87 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Globals:
+
+void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase)
+{
+ const int BUF_SIZE = 512;
+ ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed
+
+ // Save in XY cuts:
+ cFile f1;
+ if (f1.Open(Printf("%s_XY (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
+ {
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ for (int y = 0; y < a_SizeY; y++)
+ {
+ int idx = y * a_SizeX + z * a_SizeX * a_SizeY;
+ unsigned char buf[BUF_SIZE];
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ buf[x] = (unsigned char)(std::min(255, std::max(0, (int)(128 + 32 * a_Noise[idx++]))));
+ }
+ f1.Write(buf, a_SizeX);
+ } // for y
+ unsigned char buf[BUF_SIZE];
+ memset(buf, 0, a_SizeX);
+ f1.Write(buf, a_SizeX);
+ } // for z
+ } // if (XY file open)
+
+ cFile f2;
+ if (f2.Open(Printf("%s_XZ (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
+ {
+ for (int y = 0; y < a_SizeY; y++)
+ {
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ int idx = y * a_SizeX + z * a_SizeX * a_SizeY;
+ unsigned char buf[BUF_SIZE];
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ buf[x] = (unsigned char)(std::min(255, std::max(0, (int)(128 + 32 * a_Noise[idx++]))));
+ }
+ f2.Write(buf, a_SizeX);
+ } // for z
+ unsigned char buf[BUF_SIZE];
+ memset(buf, 0, a_SizeX);
+ f2.Write(buf, a_SizeX);
+ } // for y
+ } // if (XZ file open)
+}
+
+
+
+
+
+void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase)
+{
+ const int BUF_SIZE = 512;
+ ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed
+
+ cFile f1;
+ if (f1.Open(Printf("%s (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
+ {
+ for (int y = 0; y < a_SizeY; y++)
+ {
+ int idx = y * a_SizeX;
+ unsigned char buf[BUF_SIZE];
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ buf[x] = (unsigned char)(std::min(255, std::max(0, (int)(128 + 32 * a_Noise[idx++]))));
+ }
+ f1.Write(buf, a_SizeX);
+ } // for y
+ } // if (file open)
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cCubicCell2D:
class cCubicCell2D
@@ -755,6 +836,7 @@ void cPerlinNoise::Generate2D(
if (m_Octaves.empty())
{
// No work to be done
+ ASSERT(!"Perlin: No octaves to generate!");
return;
}
@@ -816,6 +898,7 @@ void cPerlinNoise::Generate3D(
if (m_Octaves.empty())
{
// No work to be done
+ ASSERT(!"Perlin: No octaves to generate!");
return;
}
diff --git a/source/Noise.h b/source/Noise.h
index a38406937..ea72c64e9 100644
--- a/source/Noise.h
+++ b/source/Noise.h
@@ -296,3 +296,13 @@ NOISE_DATATYPE cNoise::LinearInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B,
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Global functions:
+
+extern void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase);
+extern void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase);
+
+
+
+