7 #include "../BlockArea.h"
8 #include "../LinearUpscale.h"
9 #include "../BlockInfo.h"
26 for (
int x = 0; x <= 2; x++)
28 int BaseX = ChunkX + x - 1;
29 for (
int z = 0; z <= 2; z++)
31 int BaseZ = ChunkZ + z - 1;
35 if ((x != 1) || (z != 1))
45 WorkerDesc.SetHeightFromShape (workerShape);
70 for (
int i = 0; i < NumTrees; i++)
81 IgnoredOverflow.reserve(OutsideOther.size());
82 ApplyTreeImage(ChunkX, ChunkZ, a_ChunkDesc, OutsideOther, IgnoredOverflow);
83 IgnoredOverflow.clear();
84 IgnoredOverflow.reserve(OutsideLogs.size());
85 ApplyTreeImage(ChunkX, ChunkZ, a_ChunkDesc, OutsideLogs, IgnoredOverflow);
97 int a_ChunkX,
int a_ChunkZ,
int a_Seq,
104 if ((a_Pos.
y <= 0) || (a_Pos.
y >= 230))
125 for (sSetBlockVector::const_iterator itr = TreeLogs.begin(); itr != TreeLogs.end(); ++itr)
127 if ((itr->m_ChunkX != a_ChunkX) || (itr->m_ChunkZ != a_ChunkZ))
153 ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeOther, a_OutsideOther);
154 ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs);
162 int a_ChunkX,
int a_ChunkZ,
169 for (sSetBlockVector::const_iterator itr = a_Image.begin(), end = a_Image.end(); itr != end; ++itr)
171 if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkZ == a_ChunkZ) && (itr->m_RelY <
cChunkDef::Height))
174 switch (a_ChunkDesc.
GetBlockType(itr->m_RelX, itr->m_RelY, itr->m_RelZ))
189 a_ChunkDesc.
SetBlockTypeMeta(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta);
207 a_Overflow.push_back(*itr);
216 int a_ChunkX,
int a_ChunkZ,
233 case biEnd:
return 0.0;
298 double NumTrees = 0.0;
299 for (
auto Biome : a_Biomes)
301 NumTrees += BiomeTrees(Biome);
319 for (
int z = -1; z < 2; z++)
for (
int x = -1; x < 2; x++)
347 int MinHeight = std::max(a_MaxLakeHeight - 6, 2);
350 int OffsetX = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
353 int OffsetZ = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
356 int HeightY = 1 + (((Rnd & 0x1ff) % MinHeight) + (((Rnd >> 9) & 0x1ff) % MinHeight)) / 2;
358 a_Lake.
SetOrigin(OffsetX, HeightY, OffsetZ);
361 int NumBubbles = 4 + ((Rnd >> 18) & 0x03);
363 for (
int i = 0; i < NumBubbles; i++)
366 const int BubbleR = 2 + (BubbleRnd & 0x03);
367 const int Range = 16 - 2 * BubbleR;
368 const int BubbleX = BubbleR + (BubbleRnd % Range);
370 const int BubbleY = 4 + (BubbleRnd & 0x01);
372 const int BubbleZ = BubbleR + (BubbleRnd % Range);
373 const int HalfR = BubbleR / 2;
374 const int RSquared = BubbleR * BubbleR;
375 for (
int y = -HalfR; y <= HalfR; y++)
378 int DistY = 4 * y * y / 3;
379 int IdxY = (BubbleY + y) * 16 * 16;
380 for (
int z = -BubbleR; z <= BubbleR; z++)
382 int DistYZ = DistY + z * z;
383 if (DistYZ >= RSquared)
387 int IdxYZ = BubbleX + IdxY + (BubbleZ + z) * 16;
388 for (
int x = -BubbleR; x <= BubbleR; x++)
390 if (x * x + DistYZ < RSquared)
400 for (
int y = 0; y < 4; y++)
402 for (
int z = 0; z < 16; z++)
for (
int x = 0; x < 16; x++)
404 if (BlockTypes[x + z * 16 + y * 16 * 16] ==
E_BLOCK_AIR)
406 BlockTypes[x + z * 16 + y * 16 * 16] =
m_Fluid;
425 m_Noise2(a_Seed + 1000)
443 const int SEGMENT_HEIGHT = 8;
450 int FloorBuf1[17 * 17];
451 int FloorBuf2[17 * 17];
452 int * FloorHi = FloorBuf1;
453 int * FloorLo = FloorBuf2;
466 LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorLo);
469 for (
int Segment = BaseY; Segment < MaxHeight; Segment += SEGMENT_HEIGHT)
479 LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorHi);
482 for (
int z = 0; z < 16; z++)
for (
int x = 0; x < 16; x++)
488 int Lo = FloorLo[x + 17 * z] / 256;
489 int Hi = FloorHi[x + 17 * z] / 256;
490 for (
int y = 0; y < SEGMENT_HEIGHT; y++)
492 int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT;
503 std::swap(FloorLo, FloorHi);
514 for (
size_t i = 0; i <
ARRAYCOUNT(Biomes); i++)
540 m_NoiseX(a_Seed + 1000),
541 m_NoiseY(a_Seed + 2000),
542 m_NoiseZ(a_Seed + 3000),
543 m_NoiseH(a_Seed + 4000)
555 for (
int y = 50; y < 128; y++)
569 int MembraneHeight = 96 -
static_cast<int>((DistortY +
m_NoiseH.
CubicNoise2D(NoiseX + DistortX, NoiseZ + DistortZ)) * 30);
570 if (MembraneHeight < y)
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
@ E_BLOCK_HUGE_BROWN_MUSHROOM
@ E_BLOCK_HUGE_RED_MUSHROOM
@ E_BLOCK_STATIONARY_WATER
std::vector< sSetBlock > sSetBlockVector
unsigned char HEIGHTTYPE
The type used by the heightmap.
unsigned char BLOCKTYPE
The datatype used by blockdata.
void GetTreeImageByBiome(Vector3i a_BlockPos, cNoise &a_Noise, int a_Seq, EMCSBiome a_Biome, sSetBlockVector &a_LogBlocks, sSetBlockVector &a_OtherBlocks)
Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a tree at the sp...
#define CASE_TREE_OVERWRITTEN_BLOCKS
#define CASE_TREE_ALLOWED_BLOCKS
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
float NOISE_DATATYPE
The datatype used by all the noise generators.
void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes=baTypes|baMetas|baBlockEntities)
Creates a new area of the specified size and contents.
void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ)
Resets the origin.
int GetOriginZ(void) const
int GetOriginY(void) const
BLOCKTYPE * GetBlockTypes(void) const
Returns the internal pointer to the block types.
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta=0, NIBBLETYPE a_BlockLight=0, NIBBLETYPE a_BlockSkyLight=0x0f)
Fills the entire block area with the specified data.
int GetOriginX(void) const
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
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.
void SetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
void SetChunkCoords(cChunkCoords a_Coords)
HEIGHTTYPE GetMinHeight(void) const
Returns the minimum height value in the heightmap.
BLOCKTYPE GetBlockType(int a_RelX, int a_RelY, int a_RelZ) const
void WriteBlockArea(const cBlockArea &a_BlockArea, int a_RelX, int a_RelY, int a_RelZ, cBlockArea::eMergeStrategy a_MergeStrategy=cBlockArea::msOverwrite)
Writes the block area into the chunk, with its origin set at the specified relative coords.
cChunkDef::BiomeMap & GetBiomeMap(void)
void UpdateHeightmap(void)
Updates the heightmap to match the current contents.
HEIGHTTYPE GetMaxHeight(void) const
Returns the maximum height value in the heightmap.
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap)=0
Generates biomes for the given chunk.
virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape &a_Shape)=0
Generates the shape for the given chunk.
virtual void ComposeTerrain(cChunkDesc &a_ChunkDesc, const cChunkDesc::Shape &a_Shape)=0
Generates the chunk's composition into a_ChunkDesc, using the terrain shape provided in a_Shape.
double GetNumTrees(int a_ChunkX, int a_ChunkZ, const cChunkDef::BiomeMap &a_Biomes)
Get the the number of trees to generate in a_Chunk If the value is between 0 and 1,...
virtual void GenFinish(cChunkDesc &a_ChunkDesc) override
void ApplyTreeImage(int a_ChunkX, int a_ChunkZ, cChunkDesc &a_ChunkDesc, const sSetBlockVector &a_Image, sSetBlockVector &a_Overflow)
Applies an image into chunk blockdata; all blocks outside the chunk will be appended to a_Overflow.
cTerrainCompositionGen & m_CompositionGen
cTerrainShapeGen & m_ShapeGen
void GenerateSingleTree(int a_ChunkX, int a_ChunkZ, int a_Seq, Vector3i a_Pos, cChunkDesc &a_ChunkDesc, sSetBlockVector &a_OutsideLogs, sSetBlockVector &a_OutsideOther)
Generates and applies an image of a single tree.
int m_Probability
Chance, [0 .
void CreateLakeImage(int a_ChunkX, int a_ChunkZ, int a_MaxLakeHeight, cBlockArea &a_Lake)
Creates a lake image for the specified chunk into a_Lake.
virtual void GenFinish(cChunkDesc &a_ChunkDesc) override
bool HasWantedBiome(cChunkDesc &a_ChunkDesc) const
virtual void GenFinish(cChunkDesc &a_ChunkDesc) override
cStructGenDirectOverhangs(int a_Seed)
cStructGenDistortedMembraneOverhangs(int a_Seed)
virtual void GenFinish(cChunkDesc &a_ChunkDesc) override
NOISE_DATATYPE CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const
NOISE_DATATYPE CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z) const
int IntNoise3DInt(int a_X, int a_Y, int a_Z) const
int IntNoise2DInt(int a_X, int a_Y) const
NOISE_DATATYPE IntNoise3D(int a_X, int a_Y, int a_Z) const