Cuberite
A lightweight, fast and extensible game server for Minecraft
DistortedHeightmap.h
Go to the documentation of this file.
1 
2 // DistortedHeightmap.h
3 
4 // Declares the cDistortedHeightmap class representing the height and composition generator capable of overhangs
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "ComposableGenerator.h"
13 #include "HeiGen.h"
14 
15 
16 
17 
18 
19 #define NOISE_SIZE_Y (257 + 32)
20 
21 
22 
23 
24 
26  public cTerrainShapeGen
27 {
28 public:
29  cDistortedHeightmap(int a_Seed, cBiomeGenPtr a_BiomeGen);
30 
31 protected:
33 
34  // Linear upscaling step sizes, must be divisors of cChunkDef::Width and cChunkDef::Height, respectively:
35  static const int INTERPOL_X = 8;
36  static const int INTERPOL_Y = 4;
37  static const int INTERPOL_Z = 8;
38 
39  // Linear upscaling buffer dimensions, calculated from the step sizes:
40  static const int DIM_X = 1 + (17 / INTERPOL_X);
41  static const int DIM_Y = 1 + (257 / INTERPOL_Y);
42  static const int DIM_Z = 1 + (17 / INTERPOL_Z);
43 
46 
51 
54 
57 
60 
63 
66 
67  // Per-biome terrain generator parameters:
68  struct sGenParam
69  {
72  } ;
73  static const sGenParam m_GenParam[256];
74 
75  // Distortion amplitudes for each direction, before linear upscaling
78 
81 
82 
84  void PrepareState(cChunkCoords a_ChunkCoords);
85 
87  void GenerateHeightArray(void);
88 
91 
93  void UpdateDistortAmps(void);
94 
96  void GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_RelX, int a_RelZ, NOISE_DATATYPE & a_DistortAmpX, NOISE_DATATYPE & a_DistortAmpZ);
97 
99  void Initialize(cIniFile & a_IniFile);
100 
101 
102  // cTerrainShapeGen overrides:
103  virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape & a_Shape) override;
104  virtual void InitializeShapeGen(cIniFile & a_IniFile) override;
105 } ;
cChunkDef::BiomeMap BiomeNeighbors[3][3]
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
Definition: ChunkDesc.h:36
cPerlinNoise m_NoiseDistortZ
virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape &a_Shape) override
Generates the shape for the given chunk.
cHeiGenCache m_HeightGen
Cache for m_UnderlyingHeiGen.
std::shared_ptr< cTerrainHeightGen > cTerrainHeightGenPtr
void PrepareState(cChunkCoords a_ChunkCoords)
Unless the LastChunk coords are equal to coords given, prepares the internal state (noise arrays...
static const int INTERPOL_X
cDistortedHeightmap(int a_Seed, cBiomeGenPtr a_BiomeGen)
static const int DIM_X
static const int DIM_Z
void UpdateDistortAmps(void)
Updates m_DistortAmpX/Z[] based on m_CurChunkX and m_CurChunkZ.
NOISE_DATATYPE m_FrequencyX
cBiomeGenPtr m_BiomeGen
The bime generator to query for biomes.
void Initialize(cIniFile &a_IniFile)
Reads the settings from the ini file.
void GenerateHeightArray(void)
Generates the m_DistortedHeightmap array for the current chunk.
NOISE_DATATYPE m_FrequencyZ
bool m_IsInitialized
True if Initialize() has been called.
int GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
Calculates the heightmap value (before distortion) at the specified (floating-point) coords...
static const int INTERPOL_Y
A simple cache that stores N most recently generated chunks&#39; heightmaps; N being settable upon creati...
Definition: HeiGen.h:27
NOISE_DATATYPE m_DistortedHeightmap[17 *257 *17]
float NOISE_DATATYPE
The datatype used by all the noise generators.
Definition: Noise.h:9
void GetDistortAmpsAt(BiomeNeighbors &a_Neighbors, int a_RelX, int a_RelZ, NOISE_DATATYPE &a_DistortAmpX, NOISE_DATATYPE &a_DistortAmpZ)
Calculates the X and Z distortion amplitudes based on the neighbors&#39; biomes.
cChunkDef::HeightMap m_CurChunkHeights
Heightmap for the current chunk, before distortion (from m_HeightGen).
The interface that a terrain shape generator must implement A terrain shape generator takes chunk coo...
static const int DIM_Y
static const int INTERPOL_Z
cChunkCoords m_CurChunkCoords
static const sGenParam m_GenParam[256]
This table assigns a relative maximum overhang size in each direction to biomes.
cTerrainHeightGenPtr m_UnderlyingHeiGen
The generator that provides the base heightmap (before distortion).
NOISE_DATATYPE m_FrequencyY
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:142
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
Definition: ChunkDef.h:147
cPerlinNoise m_NoiseDistortX
virtual void InitializeShapeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
std::shared_ptr< cBiomeGen > cBiomeGenPtr