Cuberite
A lightweight, fast and extensible game server for Minecraft
CompositedHeiGen.h
Go to the documentation of this file.
1 
2 // CompositedHeiGen.h
3 
4 // Declares the cCompositedHeiGen class representing a cTerrainHeightGen descendant that calculates heightmap of the composited terrain
5 // This is used to further cache heightmaps for chunks already generated for finishers that require only heightmap information
6 
7 
8 
9 
10 
11 #pragma once
12 
13 #include "ComposableGenerator.h"
14 
15 
16 
17 
18 
20  public cTerrainHeightGen
21 {
22 public:
23  cCompositedHeiGen(cBiomeGen & a_BiomeGen, cTerrainShapeGen & a_ShapeGen, cTerrainCompositionGen & a_CompositionGen):
24  m_BiomeGen(a_BiomeGen),
25  m_ShapeGen(a_ShapeGen),
26  m_CompositionGen(a_CompositionGen)
27  {
28  }
29 
30 
31 
32  // cTerrainHeightGen overrides:
33  virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap & a_HeightMap) override
34  {
35  cChunkDesc::Shape shape;
36  m_ShapeGen.GenShape(a_ChunkCoords, shape);
37  cChunkDesc desc(a_ChunkCoords);
38  m_BiomeGen.GenBiomes(a_ChunkCoords, desc.GetBiomeMap()); // Need to initialize biomes for the composition gen
39  desc.SetHeightFromShape(shape);
40  m_CompositionGen.ComposeTerrain(desc, shape);
41  memcpy(a_HeightMap, desc.GetHeightMap(), sizeof(a_HeightMap));
42  }
43 
44 protected:
48 };
Wraps the chunk coords into a single structure.
Definition: ChunkDef.h:57
HEIGHTTYPE HeightMap[Width *Width]
The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the hig...
Definition: ChunkDef.h:132
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
Definition: ChunkDesc.h:36
cChunkDef::HeightMap & GetHeightMap(void)
Definition: ChunkDesc.h:239
cChunkDef::BiomeMap & GetBiomeMap(void)
Definition: ChunkDesc.h:234
void SetHeightFromShape(const Shape &a_Shape)
Sets the heightmap to match the given shape data.
Definition: ChunkDesc.cpp:153
The interface that a biome generator must implement A biome generator takes chunk coords on input and...
virtual void GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap &a_BiomeMap)=0
Generates biomes for the given chunk.
The interface that a terrain shape generator must implement A terrain shape generator takes chunk coo...
virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape &a_Shape)=0
Generates the shape for the given chunk.
The interface that is used to query terrain height from the shape generator.
The interface that a terrain composition generator must implement Terrain composition takes chunk coo...
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.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
cBiomeGen & m_BiomeGen
cTerrainCompositionGen & m_CompositionGen
cTerrainShapeGen & m_ShapeGen
cCompositedHeiGen(cBiomeGen &a_BiomeGen, cTerrainShapeGen &a_ShapeGen, cTerrainCompositionGen &a_CompositionGen)