mirror of
https://github.com/minetest/minetest.git
synced 2024-11-24 00:23:46 +01:00
Mgvalleys: Don't let cavegen place biome nodes everywhere
Fix use of 'air_above' bool so that biome nodes are only placed in tunnel floors Minor code improvements 'Continue' when massive cave air is placed
This commit is contained in:
parent
73d4538d94
commit
fe349d401d
@ -921,14 +921,13 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
u32 index_2d = 0;
|
u32 index_2d = 0;
|
||||||
u32 index_3d = 0;
|
|
||||||
for (s16 z = node_min.Z; z <= node_max.Z; z++)
|
for (s16 z = node_min.Z; z <= node_max.Z; z++)
|
||||||
for (s16 x = node_min.X; x <= node_max.X; x++, index_2d++) {
|
for (s16 x = node_min.X; x <= node_max.X; x++, index_2d++) {
|
||||||
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index_2d]);
|
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index_2d]);
|
||||||
bool air_above = false;
|
bool tunnel_air_above = false;
|
||||||
bool underground = false;
|
bool underground = false;
|
||||||
u32 index_data = vm->m_area.index(x, node_max.Y, z);
|
u32 index_data = vm->m_area.index(x, node_max.Y, z);
|
||||||
index_3d = (z - node_min.Z) * zstride_1d + csize.Y * ystride + (x - node_min.X);
|
u32 index_3d = (z - node_min.Z) * zstride_1d + csize.Y * ystride + (x - node_min.X);
|
||||||
|
|
||||||
// Dig caves on down loop to check for air above.
|
// Dig caves on down loop to check for air above.
|
||||||
// Don't excavate the overgenerated stone at node_max.Y + 1,
|
// Don't excavate the overgenerated stone at node_max.Y + 1,
|
||||||
@ -942,12 +941,10 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
|
|||||||
float terrain = noise_terrain_height->result[index_2d];
|
float terrain = noise_terrain_height->result[index_2d];
|
||||||
|
|
||||||
// Saves some time.
|
// Saves some time.
|
||||||
if (y > terrain + 10) {
|
if (y > terrain + 10)
|
||||||
air_above = true;
|
|
||||||
continue;
|
continue;
|
||||||
} else if (y < terrain - 40) {
|
else if (y < terrain - 40)
|
||||||
underground = true;
|
underground = true;
|
||||||
}
|
|
||||||
|
|
||||||
// Dig massive caves.
|
// Dig massive caves.
|
||||||
if (node_max.Y <= massive_cave_depth
|
if (node_max.Y <= massive_cave_depth
|
||||||
@ -955,6 +952,7 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
|
|||||||
> tcave_cache[y - node_min.Y + 1]) {
|
> tcave_cache[y - node_min.Y + 1]) {
|
||||||
vm->m_data[index_data] = n_air;
|
vm->m_data[index_data] = n_air;
|
||||||
made_a_big_one = true;
|
made_a_big_one = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
content_t c = vm->m_data[index_data].getContent();
|
content_t c = vm->m_data[index_data].getContent();
|
||||||
@ -963,23 +961,22 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
|
|||||||
|
|
||||||
// River water is not set as ground content
|
// River water is not set as ground content
|
||||||
// in the default game. This can produce strange results
|
// in the default game. This can produce strange results
|
||||||
// when a cave undercuts a river. However, that's not for
|
// when a tunnel undercuts a river. However, that's not for
|
||||||
// the mapgen to correct. Fix it in lua.
|
// the mapgen to correct. Fix it in lua.
|
||||||
|
|
||||||
if (c == CONTENT_AIR) {
|
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
|
||||||
air_above = true;
|
// in a tunnel
|
||||||
} else if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
|
|
||||||
// in a cave
|
|
||||||
vm->m_data[index_data] = n_air;
|
vm->m_data[index_data] = n_air;
|
||||||
air_above = true;
|
tunnel_air_above = true;
|
||||||
} else if (air_above && (c == biome->c_filler || c == biome->c_stone)) {
|
} else if (c == biome->c_filler || c == biome->c_stone) {
|
||||||
// at the cave floor
|
if (tunnel_air_above) {
|
||||||
s16 sr = ps.range(0,39);
|
// at the tunnel floor
|
||||||
|
s16 sr = ps.range(0, 39);
|
||||||
u32 j = index_data;
|
u32 j = index_data;
|
||||||
vm->m_area.add_y(em, j, 1);
|
vm->m_area.add_y(em, j, 1);
|
||||||
|
|
||||||
if (sr > terrain - y) {
|
if (sr > terrain - y) {
|
||||||
// Put dirt in caves near the surface.
|
// Put dirt in tunnels near the surface.
|
||||||
if (underground)
|
if (underground)
|
||||||
vm->m_data[index_data] = MapNode(biome->c_filler);
|
vm->m_data[index_data] = MapNode(biome->c_filler);
|
||||||
else
|
else
|
||||||
@ -998,19 +995,17 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
|
|||||||
&& sr >= 0 && sr < water_chance)
|
&& sr >= 0 && sr < water_chance)
|
||||||
vm->m_data[j] = n_water;
|
vm->m_data[j] = n_water;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
air_above = false;
|
tunnel_air_above = false;
|
||||||
underground = true;
|
|
||||||
} else if (c == biome->c_filler || c == biome->c_stone) {
|
|
||||||
air_above = false;
|
|
||||||
underground = true;
|
underground = true;
|
||||||
} else {
|
} else {
|
||||||
air_above = false;
|
tunnel_air_above = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node_max.Y <= large_cave_depth && (!made_a_big_one)) {
|
if (node_max.Y <= large_cave_depth && !made_a_big_one) {
|
||||||
u32 bruises_count = ps.range(0, 2);
|
u32 bruises_count = ps.range(0, 2);
|
||||||
for (u32 i = 0; i < bruises_count; i++) {
|
for (u32 i = 0; i < bruises_count; i++) {
|
||||||
CaveV5 cave(this, &ps);
|
CaveV5 cave(this, &ps);
|
||||||
|
Loading…
Reference in New Issue
Block a user