fix: y is too height

This commit is contained in:
2026-04-18 16:19:19 +08:00
parent 03ea97055f
commit af34d7eb82

View File

@@ -249,8 +249,13 @@ void Chunk::resolve_blocks() {
float temp = PerlinNoise::noise(world_x * BIOME_NOISE_FREQUENCY, 0.0f, world_z * BIOME_NOISE_FREQUENCY); float temp = PerlinNoise::noise(world_x * BIOME_NOISE_FREQUENCY, 0.0f, world_z * BIOME_NOISE_FREQUENCY);
float humid = PerlinNoise::noise(world_x * BIOME_NOISE_FREQUENCY, 1.0f, world_z * BIOME_NOISE_FREQUENCY); float humid = PerlinNoise::noise(world_x * BIOME_NOISE_FREQUENCY, 1.0f, world_z * BIOME_NOISE_FREQUENCY);
int height = get_interpolated_height(world_x, world_z, temp, humid); int height = get_interpolated_height(world_x, world_z, temp, humid);
heights[x][z] = height;
auto biome = get_biome_from_noise(temp, humid); auto biome = get_biome_from_noise(temp, humid);
if (height >= SIZE_Y) {
Logger::warn("height: {} is exceed max_height", height);
height = SIZE_Y - 1;
}
heights[x][z] = height;
for (int y = 5; y < height - 5; y++) { for (int y = 5; y < height - 5; y++) {
m_blocks[get_index(x, y, z)] = 3; m_blocks[get_index(x, y, z)] = 3;
} }