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, cBiomeGen & 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 } ;
float NOISE_DATATYPE
The datatype used by all the noise generators.
Definition: Noise.h:9
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
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
Definition: ChunkDef.h:137
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
Definition: ChunkDesc.h:36
The interface that a biome generator must implement A biome generator takes chunk coords on input and...
The interface that a terrain shape generator must implement A terrain shape generator takes chunk coo...
cHeiGenBiomal m_UnderlyingHeiGen
The generator that provides the base heightmap (before distortion).
NOISE_DATATYPE m_DistortAmpZ[DIM_X *DIM_Z]
cPerlinNoise m_NoiseDistortZ
virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape &a_Shape) override
Generates the shape for the given chunk.
NOISE_DATATYPE m_FrequencyX
static const int INTERPOL_Y
static const int DIM_X
static const int INTERPOL_X
cChunkCoords m_CurChunkCoords
cChunkDef::BiomeMap BiomeNeighbors[3][3]
static const int DIM_Z
NOISE_DATATYPE m_FrequencyZ
cChunkDef::HeightMap m_CurChunkHeights
Heightmap for the current chunk, before distortion (from m_HeightGen).
void Initialize(cIniFile &a_IniFile)
Reads the settings from the ini file.
static const int INTERPOL_Z
static const int DIM_Y
int GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
Calculates the heightmap value (before distortion) at the specified (floating-point) coords.
cBiomeGen & m_BiomeGen
The bime generator to query for biomes.
cHeiGenCache m_HeightGen
Cache for m_UnderlyingHeiGen.
cPerlinNoise m_NoiseDistortX
void UpdateDistortAmps(void)
Updates m_DistortAmpX/Z[] based on m_CurChunkX and m_CurChunkZ.
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' biomes.
NOISE_DATATYPE m_DistortedHeightmap[17 *257 *17]
NOISE_DATATYPE m_DistortAmpX[DIM_X *DIM_Z]
static const sGenParam m_GenParam[256]
This table assigns a relative maximum overhang size in each direction to biomes.
NOISE_DATATYPE m_FrequencyY
void PrepareState(cChunkCoords a_ChunkCoords)
Unless the LastChunk coords are equal to coords given, prepares the internal state (noise arrays,...
cDistortedHeightmap(int a_Seed, cBiomeGen &a_BiomeGen)
virtual void InitializeShapeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
bool m_IsInitialized
True if Initialize() has been called.
void GenerateHeightArray(void)
Generates the m_DistortedHeightmap array for the current chunk.
A simple cache that stores N most recently generated chunks' heightmaps; N being settable upon creati...
Definition: HeiGen.h:29