1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Cavegen y biome check (#13472)

This commit is contained in:
Riley Adams 2023-06-05 05:59:22 -04:00 committed by GitHub
parent 1ef9fc9d1f
commit 29b7aea38b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 7 deletions

View file

@ -636,6 +636,8 @@ void MapgenBasic::generateBiomes()
noise_filler_depth->perlinMap2D(node_min.X, node_min.Z);
s16 *biome_transitions = biomegen->getBiomeTransitions();
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
Biome *biome = NULL;
@ -644,9 +646,11 @@ void MapgenBasic::generateBiomes()
u16 base_filler = 0;
u16 depth_water_top = 0;
u16 depth_riverbed = 0;
s16 biome_y_min = -MAX_MAP_GENERATION_LIMIT;
u32 vi = vm->m_area.index(x, node_max.Y, z);
int cur_biome_depth = 0;
s16 biome_y_min = biome_transitions[cur_biome_depth];
// Check node at base of mapchunk above, either a node of a previously
// generated mapchunk or if not, a node of overgenerated base terrain.
content_t c_above = vm->m_data[vi + em.X].getContent();
@ -675,8 +679,19 @@ void MapgenBasic::generateBiomes()
(air_above || !biome || y < biome_y_min); // 2, 3, 4
if (is_stone_surface || is_water_surface) {
// (Re)calculate biome
biome = biomegen->getBiomeAtIndex(index, v3s16(x, y, z));
if (!biome || y < biome_y_min) {
// (Re)calculate biome
biome = biomegen->getBiomeAtIndex(index, v3s16(x, y, z));
// Finding the height of the next biome
// On first iteration this may loop a couple times after than it should just run once
while (y < biome_y_min) {
biome_y_min = biome_transitions[++cur_biome_depth];
}
/*if (x == node_min.X && z == node_min.Z)
printf("Map: check @ %i -> %s -> again at %i\n", y, biome->name.c_str(), biome_y_min);*/
}
// Add biome to biomemap at first stone surface detected
if (biomemap[index] == BIOME_NONE && is_stone_surface)
@ -693,7 +708,6 @@ void MapgenBasic::generateBiomes()
noise_filler_depth->result[index], 0.0f);
depth_water_top = biome->depth_water_top;
depth_riverbed = biome->depth_riverbed;
biome_y_min = biome->min_pos.Y;
}
if (c == c_stone) {
@ -833,7 +847,7 @@ void MapgenBasic::generateCavesNoiseIntersection(s16 max_stone_y)
if (node_min.Y > max_stone_y || cave_width >= 10.0f)
return;
CavesNoiseIntersection caves_noise(ndef, m_bmgr, csize,
CavesNoiseIntersection caves_noise(ndef, m_bmgr, biomegen, csize,
&np_cave1, &np_cave2, seed, cave_width);
caves_noise.generateCaves(vm, node_min, node_max, biomemap);