LinearUpscale: postfixed with InPlace to differentiate from a future src/dst version

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1479 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
madmaxoft@gmail.com 2013-05-12 21:11:25 +00:00
parent 59eb312291
commit 0a08ae14f6
7 changed files with 22 additions and 16 deletions

View File

@ -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]); 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); ArrayLinearUpscale2DInPlace(&DistortX[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
ArrayLinearUpscale2D(&DistortZ[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++) 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); 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); ArrayLinearUpscale2DInPlace(&DistortX[0][0], cChunkDef::Width + 1, cChunkDef::Width + 1, 4, 4);
ArrayLinearUpscale2D(&DistortZ[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 // Prepare a 9x9 area of neighboring cell seeds
// (assuming that 7x7 cell area is larger than a chunk being generated) // (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; HumidityMap[x + 17 * z] = NoiseH;
} // for x } // for x
} // for z } // for z
ArrayLinearUpscale2D(TemperatureMap, 17, 17, 8, 8); ArrayLinearUpscale2DInPlace(TemperatureMap, 17, 17, 8, 8);
ArrayLinearUpscale2D(HumidityMap, 17, 17, 8, 8); ArrayLinearUpscale2DInPlace(HumidityMap, 17, 17, 8, 8);
// Re-map into integral values in [0 .. 255] range: // Re-map into integral values in [0 .. 255] range:
for (int idx = 0; idx < ARRAYCOUNT(a_TemperatureMap); idx++) for (int idx = 0; idx < ARRAYCOUNT(a_TemperatureMap); idx++)

View File

@ -442,7 +442,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc)
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) /
256; 256;
} // for x, z - FloorLo[] } // for x, z - FloorLo[]
ArrayLinearUpscale2D(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z); ArrayLinearUpscale2DInPlace(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z);
// Interpolate segments: // Interpolate segments:
for (int Segment = 0; Segment < MaxHeight; Segment += SEGMENT_HEIGHT) 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) / m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) /
256; 256;
} // for x, z - FloorLo[] } // 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: // Interpolate between FloorLo and FloorHi:
for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)

View File

@ -158,7 +158,7 @@ void cDistortedHeightmap::GenerateHeightArray(void)
CurFloor[idx + x * INTERPOL_X] = (NOISE_DATATYPE)GetHeightmapAt(DistX, DistZ) + (NOISE_DATATYPE)0.5; CurFloor[idx + x * INTERPOL_X] = (NOISE_DATATYPE)GetHeightmapAt(DistX, DistZ) + (NOISE_DATATYPE)0.5;
} // for x } // for x
} // for z } // for z
ArrayLinearUpscale2D(CurFloor, 17, 17, INTERPOL_X, INTERPOL_Z); ArrayLinearUpscale2DInPlace(CurFloor, 17, 17, INTERPOL_X, INTERPOL_Z);
} // for y } // for y
// Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis // 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]); GetDistortAmpsAt(Biomes, x, z, m_DistortAmpX[x + 17 * z], m_DistortAmpZ[x + 17 * z]);
} }
} }
ArrayLinearUpscale2D(m_DistortAmpX, 17, 17, STEPX, STEPZ); ArrayLinearUpscale2DInPlace(m_DistortAmpX, 17, 17, STEPX, STEPZ);
ArrayLinearUpscale2D(m_DistortAmpZ, 17, 17, STEPX, STEPZ); ArrayLinearUpscale2DInPlace(m_DistortAmpZ, 17, 17, STEPX, STEPZ);
} }

View File

@ -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); 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 // Copy into the heightmap
for (int z = 0; z < cChunkDef::Width; z++) for (int z = 0; z < cChunkDef::Width; z++)

View File

@ -444,7 +444,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
} }
} }
// Linear-interpolate this XZ floor: // 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 // Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis

View File

@ -559,7 +559,7 @@ void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc)
m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) / m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) /
256; 256;
} // for x, z - FloorLo[] } // for x, z - FloorLo[]
ArrayLinearUpscale2D(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z); ArrayLinearUpscale2DInPlace(FloorLo, 17, 17, INTERPOL_X, INTERPOL_Z);
// Interpolate segments: // Interpolate segments:
for (int Segment = BaseY; Segment < MaxHeight; Segment += SEGMENT_HEIGHT) 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) / m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) /
256; 256;
} // for x, z - FloorLo[] } // 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: // Interpolate between FloorLo and FloorHi:
for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++)

View File

@ -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. Upscaling is implemented in templates, so that it's compatible with multiple datatypes.
Therefore, there is no cpp file. 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 /// 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, TYPE * a_Array,
int a_SizeX, int a_SizeY, // Dimensions of the 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 int a_AnchorStepX, int a_AnchorStepY // Distances between the anchor points in each direction