fix world generator

This commit is contained in:
MihailRis 2025-11-29 16:15:19 +03:00
parent 1f9b10db6e
commit 618b3d7f61

View File

@ -91,7 +91,7 @@ static inline void generate_pole(
voxel* voxels,
int x, int z
) {
uint y = top;
uint y = std::min<uint>(top, CHUNK_H - 1);
uint layerExtension = 0;
for (const auto& layer : layers.layers) {
// skip layer if can't be generated under sea level
@ -106,7 +106,9 @@ static inline void generate_pole(
} else {
layerHeight += layerExtension;
}
layerHeight = std::min(static_cast<uint>(layerHeight), y+1);
layerHeight = std::min(
static_cast<uint>(layerHeight), std::min<uint>(CHUNK_H - 1, y + 1)
);
for (uint i = 0; i < layerHeight; i++, y--) {
voxels[vox_index(x, y, z)].id = layer.rt.id;