summaryrefslogtreecommitdiffstats
path: root/src/SetChunkData.cpp
blob: 4d298a093ff3f01761e162aa8ed966811383dda3 (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
#include "Globals.h"
#include "SetChunkData.h"
#include "BlockType.h"
#include "Entities/Entity.h"





void SetChunkData::UpdateHeightMap()
{
	for (int x = 0; x < cChunkDef::Width; x++)
	{
		for (int z = 0; z < cChunkDef::Width; z++)
		{
			HEIGHTTYPE Height = 0;
			for (HEIGHTTYPE y = cChunkDef::Height - 1; y > 0; y--)
			{
				BLOCKTYPE BlockType = BlockData.GetBlock({x, y, z});
				if (BlockType != E_BLOCK_AIR)
				{
					Height = y;
					break;
				}
			}  // for y
			auto idx = x + cChunkDef::Width * z;
			HeightMap[idx] = Height;
		}  // for z
	}  // for x
}