summaryrefslogtreecommitdiffstats
path: root/src/Generating/CompositedHeiGen.h
blob: c4e6ce77da8b0737871a3fcaa6e59e3cb5062ad3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

// CompositedHeiGen.h

// Declares the cCompositedHeiGen class representing a cTerrainHeightGen descendant that calculates heightmap of the composited terrain
// This is used to further cache heightmaps for chunks already generated for finishers that require only heightmap information





#pragma once

#include "ComposableGenerator.h"





class cCompositedHeiGen:
	public cTerrainHeightGen
{
public:
	cCompositedHeiGen(cBiomeGenPtr a_BiomeGen, cTerrainShapeGenPtr a_ShapeGen, cTerrainCompositionGenPtr a_CompositionGen):
		m_BiomeGen(a_BiomeGen),
		m_ShapeGen(a_ShapeGen),
		m_CompositionGen(a_CompositionGen)
	{
	}



	// cTerrainHeightGen overrides:
	virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override
	{
		cChunkDesc::Shape shape;
		m_ShapeGen->GenShape(a_ChunkX, a_ChunkZ, shape);
		cChunkDesc desc(a_ChunkX, a_ChunkZ);
		m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, desc.GetBiomeMap());	  // Need to initialize biomes for the composition gen
		desc.SetHeightFromShape(shape);
		m_CompositionGen->ComposeTerrain(desc, shape);
		memcpy(a_HeightMap, desc.GetHeightMap(), sizeof(a_HeightMap));
	}

protected:
	cBiomeGenPtr m_BiomeGen;
	cTerrainShapeGenPtr m_ShapeGen;
	cTerrainCompositionGenPtr m_CompositionGen;
};