add sea_level variable

This commit is contained in:
MihailRis
2024-08-17 19:06:14 +03:00
parent c5877684eb
commit 510c45ffe9
4 changed files with 70 additions and 37 deletions
+2 -2
View File
@@ -20,17 +20,17 @@ void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ, int seed) {
auto heightmap = def.script->generateHeightmap(
{chunkX*CHUNK_W, chunkZ*CHUNK_D}, {CHUNK_W, CHUNK_D}
);
uint seaLevel = 64;
auto values = heightmap->getValues();
const auto& layers = def.script->getLayers();
uint lastLayersHeight = def.script->getLastLayersHeight();
uint seaLevel = def.script->getSeaLevel();
auto baseWater = content->blocks.require("base:water").rt.id;
std::memset(voxels, 0, sizeof(voxel) * CHUNK_VOL);
for (uint z = 0; z < CHUNK_D; z++) {
for (uint x = 0; x < CHUNK_W; x++) {
int height = values[z * CHUNK_W + x] * 255 + 10;
int height = values[z * CHUNK_W + x] * CHUNK_H;
for (uint y = height+1; y <= seaLevel; y++) {
voxels[vox_index(x, y, z)].id = baseWater;
}