13 #include "../LinearUpscale.h"
14 #include "../IniFile.h"
41 for (
int y = a_ChunkDesc.
GetHeight(x, z); y >= Start; y--)
103 for (
int y = a_ChunkDesc.
GetHeight(x, z); y >= 0; y--)
152 static int PatternLength =
ARRAYCOUNT(PatternGround);
160 int Height = a_ChunkDesc.
GetHeight(x, z);
164 Pattern = PatternGround;
168 Pattern = PatternBeach;
172 Pattern = PatternOcean;
182 for (
int y = Height; y >= 1; y--)
218 m_Noise1(a_Seed + 10),
219 m_Noise2(a_Seed * a_Seed * 10 + a_Seed * 1000 + 6000),
220 m_MaxThreshold(25000)
232 const int SEGMENT_HEIGHT = 8;
239 int FloorBuf1[17 * 17];
240 int FloorBuf2[17 * 17];
241 int * FloorHi = FloorBuf1;
242 int * FloorLo = FloorBuf2;
251 volatile int intermediate =
256 LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorLo);
259 for (
int Segment = 0; Segment < MaxHeight; Segment += SEGMENT_HEIGHT)
266 volatile int intermediate =
271 LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorHi);
274 for (
int z = 0; z < 16; z++)
for (
int x = 0; x < 16; x++)
277 int Lo = FloorLo[x + 17 * z] / 256;
278 int Hi = FloorHi[x + 17 * z] / 256;
279 for (
int y = 0; y < SEGMENT_HEIGHT; y++)
281 int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT;
290 std::swap(FloorLo, FloorHi);
294 for (
int z = 0; z < 16; z++)
for (
int x = 0; x < 16; x++)
298 int Height = a_ChunkDesc.
GetHeight(x, z);
302 if (CeilingDisguise < 0)
304 CeilingDisguise = -CeilingDisguise;
307 int CeilingDisguiseHeight = Height - 2 -
FloorC(CeilingDisguise * 3);
309 for (
int y = Height - 1; y > CeilingDisguiseHeight; y--)
333 m_Underlying(
std::move(a_Underlying)),
334 m_CacheSize(a_CacheSize),
335 m_CacheOrder(new int[
ToUnsigned(a_CacheSize)]),
391 for (
int j = i; j > 0; j--)
cItem GetIniItemSet(cIniFile &a_IniFile, const char *a_Section, const char *a_Key, const char *a_Default)
Returns a cItem representing the item described in an IniFile's value; if the value doesn't exist,...
@ E_BLOCK_MOSSY_COBBLESTONE
@ E_BLOCK_STATIONARY_WATER
unsigned char HEIGHTTYPE
The type used by the heightmap.
unsigned char BLOCKTYPE
The datatype used by blockdata.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default).
float NOISE_DATATYPE
The datatype used by all the noise generators.
HEIGHTTYPE GetHeight(int a_RelX, int a_RelZ) const
EMCSBiome GetBiome(int a_RelX, int a_RelZ) const
void SetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
cChunkDef::BlockTypes & GetBlockTypes(void)
cChunkDef::HeightMap & GetHeightMap(void)
BlockNibbleBytes & GetBlockMetasUncompressed(void)
void FillBlocks(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
void SetHeightFromShape(const Shape &a_Shape)
Sets the heightmap to match the given shape data.
HEIGHTTYPE GetMaxHeight(void) const
Returns the maximum height value in the heightmap.
virtual void ComposeTerrain(cChunkDesc &a_ChunkDesc, const cChunkDesc::Shape &a_Shape) override
Generates the chunk's composition into a_ChunkDesc, using the terrain shape provided in a_Shape.
virtual void InitializeCompoGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
virtual void ComposeTerrain(cChunkDesc &a_ChunkDesc, const cChunkDesc::Shape &a_Shape) override
Generates the chunk's composition into a_ChunkDesc, using the terrain shape provided in a_Shape.
virtual void ComposeTerrain(cChunkDesc &a_ChunkDesc, const cChunkDesc::Shape &a_Shape) override
Generates the chunk's composition into a_ChunkDesc, using the terrain shape provided in a_Shape.
BLOCKTYPE m_BlockBeachBottom
virtual void InitializeCompoGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
cCompoGenNether(int a_Seed)
virtual void ComposeTerrain(cChunkDesc &a_ChunkDesc, const cChunkDesc::Shape &a_Shape) override
Generates the chunk's composition into a_ChunkDesc, using the terrain shape provided in a_Shape.
virtual void InitializeCompoGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
virtual ~cCompoGenCache() override
virtual void InitializeCompoGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
virtual void ComposeTerrain(cChunkDesc &a_ChunkDesc, const cChunkDesc::Shape &a_Shape) override
Generates the chunk's composition into a_ChunkDesc, using the terrain shape provided in a_Shape.
cCompoGenCache(std::unique_ptr< cTerrainCompositionGen > a_Underlying, int a_CacheSize)
std::unique_ptr< cTerrainCompositionGen > m_Underlying
cChunkDef::BlockTypes m_BlockTypes
cChunkDesc::BlockNibbleBytes m_BlockMetas
cChunkDef::HeightMap m_HeightMap
int GetValueSetI(const AString &keyname, const AString &valuename, const int defValue=0) override
double GetValueSetF(const AString &keyname, const AString &valuename, const double defValue=0.0)
NOISE_DATATYPE CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const
int IntNoise3DInt(int a_X, int a_Y, int a_Z) const