summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 22:45:29 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 22:45:29 +0200
commit2038da8681b41665a39657545d44930934557f68 (patch)
tree6758f1f7e1e195e2ca0e2ab879c730b3bf8df13b /source
parentDistortedHeightmap: Deserts are now covered with sand and mushroom islands with mycelium (patch contributed by STR_Warrior) (diff)
downloadcuberite-2038da8681b41665a39657545d44930934557f68.tar
cuberite-2038da8681b41665a39657545d44930934557f68.tar.gz
cuberite-2038da8681b41665a39657545d44930934557f68.tar.bz2
cuberite-2038da8681b41665a39657545d44930934557f68.tar.lz
cuberite-2038da8681b41665a39657545d44930934557f68.tar.xz
cuberite-2038da8681b41665a39657545d44930934557f68.tar.zst
cuberite-2038da8681b41665a39657545d44930934557f68.zip
Diffstat (limited to 'source')
-rw-r--r--source/Generating/Noise3DGenerator.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp
index cebb982fd..5aff9d5ec 100644
--- a/source/Generating/Noise3DGenerator.cpp
+++ b/source/Generating/Noise3DGenerator.cpp
@@ -401,17 +401,21 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
m_LastChunkX = a_ChunkX;
m_LastChunkZ = a_ChunkZ;
- // Parameters:
- const int INTERPOL_X = 8;
- const int INTERPOL_Y = 4;
- const int INTERPOL_Z = 8;
+ // Upscaling parameters:
+ const int UPSCALE_X = 8;
+ const int UPSCALE_Y = 4;
+ const int UPSCALE_Z = 8;
+
+ const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X;
+ const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
+ const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
// Precalculate a "height" array:
NOISE_DATATYPE Height[17 * 17]; // x + 17 * z
- for (int z = 0; z < 17; z += INTERPOL_Z)
+ for (int z = 0; z < 17; z += UPSCALE_Z)
{
NOISE_DATATYPE NoiseZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + z)) / m_FrequencyZ;
- for (int x = 0; x < 17; x += INTERPOL_X)
+ for (int x = 0; x < 17; x += UPSCALE_X)
{
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
NOISE_DATATYPE val = abs(m_Noise1.CubicNoise2D(NoiseX / 5, NoiseZ / 5)) * m_HeightAmplification + 1;
@@ -420,16 +424,16 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
}
int idx = 0;
- for (int y = 0; y < 257; y += INTERPOL_Y)
+ for (int y = 0; y < 257; y += UPSCALE_Y)
{
NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)y) / m_FrequencyY;
NOISE_DATATYPE AddHeight = (y - m_MidPoint) / 20;
AddHeight *= AddHeight * AddHeight;
NOISE_DATATYPE * CurFloor = &(m_NoiseArray[y * 17 * 17]);
- for (int z = 0; z < 17; z += INTERPOL_Z)
+ for (int z = 0; z < 17; z += UPSCALE_Z)
{
NOISE_DATATYPE NoiseZ = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + z)) / m_FrequencyZ;
- for (int x = 0; x < 17; x += INTERPOL_X)
+ for (int x = 0; x < 17; x += UPSCALE_X)
{
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
CurFloor[x + 17 * z] =
@@ -440,23 +444,23 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
}
}
// Linear-interpolate this XZ floor:
- ArrayLinearUpscale2D(CurFloor, 17, 17, INTERPOL_X, INTERPOL_Z);
+ ArrayLinearUpscale2D(CurFloor, 17, 17, UPSCALE_X, UPSCALE_Z);
}
// Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis
for (int y = 1; y < cChunkDef::Height; y++)
{
- if ((y % INTERPOL_Y) == 0)
+ if ((y % UPSCALE_Y) == 0)
{
// This is the interpolation source floor, already calculated
continue;
}
- int LoFloorY = (y / INTERPOL_Y) * INTERPOL_Y;
- int HiFloorY = LoFloorY + INTERPOL_Y;
+ int LoFloorY = (y / UPSCALE_Y) * UPSCALE_Y;
+ int HiFloorY = LoFloorY + UPSCALE_Y;
NOISE_DATATYPE * LoFloor = &(m_NoiseArray[LoFloorY * 17 * 17]);
NOISE_DATATYPE * HiFloor = &(m_NoiseArray[HiFloorY * 17 * 17]);
NOISE_DATATYPE * CurFloor = &(m_NoiseArray[y * 17 * 17]);
- NOISE_DATATYPE Ratio = ((NOISE_DATATYPE)(y % INTERPOL_Y)) / INTERPOL_Y;
+ NOISE_DATATYPE Ratio = ((NOISE_DATATYPE)(y % UPSCALE_Y)) / UPSCALE_Y;
int idx = 0;
for (int z = 0; z < cChunkDef::Width; z++)
{