summaryrefslogtreecommitdiffstats
path: root/source/Generating/DistortedHeightmap.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-05 18:27:08 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-05 18:27:08 +0200
commit270560a198db49464a5a5a6d75d9650a30208bc7 (patch)
treea1ab9162becfd1b0888a0beb359d09edb228093f /source/Generating/DistortedHeightmap.h
parentLighting: Fixed underwater lighting (FS #369) (diff)
downloadcuberite-270560a198db49464a5a5a6d75d9650a30208bc7.tar
cuberite-270560a198db49464a5a5a6d75d9650a30208bc7.tar.gz
cuberite-270560a198db49464a5a5a6d75d9650a30208bc7.tar.bz2
cuberite-270560a198db49464a5a5a6d75d9650a30208bc7.tar.lz
cuberite-270560a198db49464a5a5a6d75d9650a30208bc7.tar.xz
cuberite-270560a198db49464a5a5a6d75d9650a30208bc7.tar.zst
cuberite-270560a198db49464a5a5a6d75d9650a30208bc7.zip
Diffstat (limited to '')
-rw-r--r--source/Generating/DistortedHeightmap.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/source/Generating/DistortedHeightmap.h b/source/Generating/DistortedHeightmap.h
new file mode 100644
index 000000000..8c1b136b8
--- /dev/null
+++ b/source/Generating/DistortedHeightmap.h
@@ -0,0 +1,93 @@
+
+// DistortedHeightmap.h
+
+// Declares the cDistortedHeightmap class representing the height and composition generator capable of overhangs
+
+
+
+
+
+#pragma once
+
+#include "ComposableGenerator.h"
+#include "HeiGen.h"
+#include "../Noise.h"
+
+
+
+
+
+#define NOISE_SIZE_Y (257 + 32)
+
+
+
+
+
+class cDistortedHeightmap :
+ public cTerrainHeightGen,
+ public cTerrainCompositionGen
+{
+public:
+ cDistortedHeightmap(int a_Seed, cBiomeGen & a_BiomeGen);
+
+ void Initialize(cIniFile & a_IniFile);
+
+protected:
+ typedef cChunkDef::BiomeMap BiomeNeighbors[3][3];
+
+ cNoise m_Noise1;
+ cNoise m_Noise2;
+ cNoise m_Noise3;
+ cNoise m_Noise4;
+ cNoise m_Noise5;
+
+ int m_SeaLevel;
+ NOISE_DATATYPE m_FrequencyX;
+ NOISE_DATATYPE m_FrequencyY;
+ NOISE_DATATYPE m_FrequencyZ;
+
+ int m_CurChunkX;
+ int m_CurChunkZ;
+ NOISE_DATATYPE m_NoiseArray[17 * 17 * NOISE_SIZE_Y];
+ NOISE_DATATYPE * m_NoiseArrayX;
+ NOISE_DATATYPE * m_NoiseArrayZ;
+
+ cBiomeGen & m_BiomeGen;
+ cHeiGenCache m_HeightGen; // This generator provides us with base heightmap (before distortion)
+
+ // Per-biome terrain generator parameters:
+ struct sGenParam
+ {
+ NOISE_DATATYPE m_DistortAmpX;
+ NOISE_DATATYPE m_DistortAmpZ;
+ } ;
+ static const sGenParam m_GenParam[biNumBiomes];
+
+ NOISE_DATATYPE m_DistortAmpX[17 * 17];
+ NOISE_DATATYPE m_DistortAmpZ[17 * 17];
+
+
+ /// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise arrays, heightmap)
+ void PrepareState(int a_ChunkX, int a_ChunkZ);
+
+ /// Generates the 3D noise array using the specified noise objects
+ void GenerateNoiseArray(NOISE_DATATYPE * a_NoiseArray, cNoise & a_Noise1, cNoise & a_Noise2, cNoise & a_Noise3);
+
+ /// Calculates the heightmap value (before distortion) at the specified (floating-point) coords
+ int GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z);
+
+ /// Calculates the height (after distortion)
+ int GetValue(int a_NoiseArrayIdx, int a_RelX, int a_RelZ);
+
+ /// Updates m_DistortAmpX/Z[] based on m_CurChunkX and m_CurChunkZ
+ void UpdateDistortAmps(void);
+
+ /// Calculates the X and Z distortion amplitudes based on the neighbors' biomes
+ void GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_RelX, int a_RelZ, NOISE_DATATYPE & a_DistortAmpX, NOISE_DATATYPE & a_DistortAmpZ);
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
+
+ // cTerrainCompositionGen overrides:
+ virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
+} ;