summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 23:11:25 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 23:11:25 +0200
commit0a08ae14f69f5179c5d8990c41d1d8dbb63be346 (patch)
tree52a80f3a7b77f1bb0fdf6bcd225c9d1e68270383
parentTemporarily set all pickups to spawn in the middle of the block from which they fall. (diff)
downloadcuberite-0a08ae14f69f5179c5d8990c41d1d8dbb63be346.tar
cuberite-0a08ae14f69f5179c5d8990c41d1d8dbb63be346.tar.gz
cuberite-0a08ae14f69f5179c5d8990c41d1d8dbb63be346.tar.bz2
cuberite-0a08ae14f69f5179c5d8990c41d1d8dbb63be346.tar.lz
cuberite-0a08ae14f69f5179c5d8990c41d1d8dbb63be346.tar.xz
cuberite-0a08ae14f69f5179c5d8990c41d1d8dbb63be346.tar.zst
cuberite-0a08ae14f69f5179c5d8990c41d1d8dbb63be346.zip
-rw-r--r--source/Generating/BioGen.cpp12
-rw-r--r--source/Generating/CompoGen.cpp4
-rw-r--r--source/Generating/DistortedHeightmap.cpp6
-rw-r--r--source/Generating/HeiGen.cpp2
-rw-r--r--source/Generating/Noise3DGenerator.cpp2
-rw-r--r--source/Generating/StructGen.cpp4
-rw-r--r--source/LinearUpscale.h8
7 files changed, 22 insertions, 16 deletions
diff --git a/source/Generating/BioGen.cpp b/source/Generating/BioGen.cpp
index 13e7c88ae..1afa93e07 100644
--- a/source/Generating/BioGen.cpp
+++ b/source/Generating/BioGen.cpp
@@ -340,8 +340,8 @@ void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::B
Distort(BaseX + x * 4, BaseZ + z * 4, DistortX[4 * x][4 * z], DistortZ[4 * x][4 * z]);
}
- ArrayLinearUpscale2D(&DistortX[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
- ArrayLinearUpscale2D(&DistortZ[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
+ ArrayLinearUpscale2DInPlace(&DistortX[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
+ ArrayLinearUpscale2DInPlace(&DistortZ[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
for (int z = 0; z < cChunkDef::Width; z++)
{
@@ -447,8 +447,8 @@ void cBioGenMultiStepMap::DecideOceanLandMushroom(int a_ChunkX, int a_ChunkZ, cC
{
Distort(BaseX + x * 4, BaseZ + z * 4, DistortX[4 * x][4 * z], DistortZ[4 * x][4 * z], DistortSize);
}
- ArrayLinearUpscale2D(&DistortX[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
- ArrayLinearUpscale2D(&DistortZ[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
+ ArrayLinearUpscale2DInPlace(&DistortX[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
+ ArrayLinearUpscale2DInPlace(&DistortZ[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
// Prepare a 9x9 area of neighboring cell seeds
// (assuming that 7x7 cell area is larger than a chunk being generated)
@@ -621,8 +621,8 @@ void cBioGenMultiStepMap::BuildTemperatureHumidityMaps(int a_ChunkX, int a_Chunk
HumidityMap[x + 17 * z] = NoiseH;
} // for x
} // for z
- ArrayLinearUpscale2D(TemperatureMap, 17, 17, 8, 8);
- ArrayLinearUpscale2D(HumidityMap, 17, 17, 8, 8);
+ ArrayLinearUpscale2DInPlace(TemperatureMap, 17, 17, 8, 8);
+ ArrayLinearUpscale2DInPlace(HumidityMap, 17, 17, 8, 8);
// Re-map into integral values in [0 .. 255] range:
for (int idx = 0; idx < ARRAYCOUNT(a_TemperatureMap); idx++)
diff --git a/source/Generating/CompoGen.cpp b/source/Generating/CompoGen.cpp
index c8f8ac069..432616a36 100644
--- a/source/Generating/CompoGen.cpp
+++ b/source/Generating/CompoGen.cpp
@@ -442,7 +442,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc)
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) /
256;
} // for x, z - FloorLo[]
- ArrayLinearUpscale2D(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z);
+ ArrayLinearUpscale2DInPlace(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z);
// Interpolate segments:
for (int Segment = 0; Segment < MaxHeight; Segment += SEGMENT_HEIGHT)
@@ -455,7 +455,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc)
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) /
256;
} // for x, z - FloorLo[]
- ArrayLinearUpscale2D(FloorHi, 17, 17, INTERPOL_X, INTERPOL_Z);
+ ArrayLinearUpscale2DInPlace(FloorHi, 17, 17, INTERPOL_X, INTERPOL_Z);
// Interpolate between FloorLo and FloorHi:
for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)
diff --git a/source/Generating/DistortedHeightmap.cpp b/source/Generating/DistortedHeightmap.cpp
index f1b74e70d..b90a30e45 100644
--- a/source/Generating/DistortedHeightmap.cpp
+++ b/source/Generating/DistortedHeightmap.cpp
@@ -158,7 +158,7 @@ void cDistortedHeightmap::GenerateHeightArray(void)
CurFloor[idx + x * INTERPOL_X] = (NOISE_DATATYPE)GetHeightmapAt(DistX, DistZ) + (NOISE_DATATYPE)0.5;
} // for x
} // for z
- ArrayLinearUpscale2D(CurFloor, 17, 17, INTERPOL_X, INTERPOL_Z);
+ ArrayLinearUpscale2DInPlace(CurFloor, 17, 17, INTERPOL_X, INTERPOL_Z);
} // for y
// Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis
@@ -381,8 +381,8 @@ void cDistortedHeightmap::UpdateDistortAmps(void)
GetDistortAmpsAt(Biomes, x, z, m_DistortAmpX[x + 17 * z], m_DistortAmpZ[x + 17 * z]);
}
}
- ArrayLinearUpscale2D(m_DistortAmpX, 17, 17, STEPX, STEPZ);
- ArrayLinearUpscale2D(m_DistortAmpZ, 17, 17, STEPX, STEPZ);
+ ArrayLinearUpscale2DInPlace(m_DistortAmpX, 17, 17, STEPX, STEPZ);
+ ArrayLinearUpscale2DInPlace(m_DistortAmpZ, 17, 17, STEPX, STEPZ);
}
diff --git a/source/Generating/HeiGen.cpp b/source/Generating/HeiGen.cpp
index 055ef87e2..61f8b4cd7 100644
--- a/source/Generating/HeiGen.cpp
+++ b/source/Generating/HeiGen.cpp
@@ -266,7 +266,7 @@ void cHeiGenBiomal::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMa
Height[x + 17 * z] = GetHeightAt(x, z, a_ChunkX, a_ChunkZ, Biomes);
}
}
- ArrayLinearUpscale2D(Height, 17, 17, STEPX, STEPZ);
+ ArrayLinearUpscale2DInPlace(Height, 17, 17, STEPX, STEPZ);
// Copy into the heightmap
for (int z = 0; z < cChunkDef::Width; z++)
diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp
index 5aff9d5ec..dbb577827 100644
--- a/source/Generating/Noise3DGenerator.cpp
+++ b/source/Generating/Noise3DGenerator.cpp
@@ -444,7 +444,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
}
}
// Linear-interpolate this XZ floor:
- ArrayLinearUpscale2D(CurFloor, 17, 17, UPSCALE_X, UPSCALE_Z);
+ ArrayLinearUpscale2DInPlace(CurFloor, 17, 17, UPSCALE_X, UPSCALE_Z);
}
// Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis
diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp
index e5ac03b49..505b4fa7a 100644
--- a/source/Generating/StructGen.cpp
+++ b/source/Generating/StructGen.cpp
@@ -559,7 +559,7 @@ void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc)
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) /
256;
} // for x, z - FloorLo[]
- ArrayLinearUpscale2D(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z);
+ ArrayLinearUpscale2DInPlace(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z);
// Interpolate segments:
for (int Segment = BaseY; Segment < MaxHeight; Segment += SEGMENT_HEIGHT)
@@ -572,7 +572,7 @@ void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc)
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) /
256;
} // for x, z - FloorLo[]
- ArrayLinearUpscale2D(FloorHi, 17, 17, INTERPOL_X, INTERPOL_Z);
+ ArrayLinearUpscale2DInPlace(FloorHi, 17, 17, INTERPOL_X, INTERPOL_Z);
// Interpolate between FloorLo and FloorHi:
for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)
diff --git a/source/LinearUpscale.h b/source/LinearUpscale.h
index c20e3d3bb..f8ba45350 100644
--- a/source/LinearUpscale.h
+++ b/source/LinearUpscale.h
@@ -15,13 +15,19 @@ However, upscaling usually requires generating the "1 +" in each direction.
Upscaling is implemented in templates, so that it's compatible with multiple datatypes.
Therefore, there is no cpp file.
+
+InPlace upscaling works on a single array and assumes that the values to work on have already
+been interspersed into the array to the cell boundaries.
+Specifically, a_Array[x * a_AnchorStepX + y * a_AnchorStepY] contains the anchor value.
+
+Regular upscaling takes two arrays and "moves" the input from src to dst; src is expected packed.
*/
/// Linearly interpolates values in the array between the equidistant anchor points; universal data type
-template<typename TYPE> void ArrayLinearUpscale2D(
+template<typename TYPE> void ArrayLinearUpscale2DInPlace(
TYPE * a_Array,
int a_SizeX, int a_SizeY, // Dimensions of the array
int a_AnchorStepX, int a_AnchorStepY // Distances between the anchor points in each direction