mirror of
https://github.com/minetest/minetest.git
synced 2024-08-19 04:54:18 +02:00
Mgvalleys / cavegen: Place riverbed nodes under river water
When a CavesNoiseIntersection tunnel intersects a river place biome 'riverbed' nodes in tunnel entrance instead of biome 'top' nodes.
This commit is contained in:
parent
97c763158c
commit
2ba8ad1dfe
@ -79,6 +79,7 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
|
||||
for (s16 z = nmin.Z; z <= nmax.Z; z++)
|
||||
for (s16 x = nmin.X; x <= nmax.X; x++, index2d++) {
|
||||
bool column_is_open = false; // Is column open to overground
|
||||
bool is_under_river = false; // Is column under river water
|
||||
bool is_tunnel = false; // Is tunnel or tunnel floor
|
||||
u32 vi = vm->m_area.index(x, nmax.Y, z);
|
||||
u32 index3d = (z - nmin.Z) * m_zstride_1d + m_csize.Y * m_ystride +
|
||||
@ -99,6 +100,10 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
|
||||
c == biome->c_water) {
|
||||
column_is_open = true;
|
||||
continue;
|
||||
} else if (c == biome->c_river_water) {
|
||||
column_is_open = true;
|
||||
is_under_river = true;
|
||||
continue;
|
||||
}
|
||||
// Ground
|
||||
float d1 = contour(noise_cave1->result[index3d]);
|
||||
@ -111,9 +116,13 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
|
||||
} else {
|
||||
// Not in tunnel or not ground content
|
||||
if (is_tunnel && column_is_open &&
|
||||
(c == biome->c_filler || c == biome->c_stone))
|
||||
(c == biome->c_filler || c == biome->c_stone)) {
|
||||
// Tunnel entrance floor
|
||||
vm->m_data[vi] = MapNode(biome->c_top);
|
||||
if (is_under_river)
|
||||
vm->m_data[vi] = MapNode(biome->c_riverbed);
|
||||
else
|
||||
vm->m_data[vi] = MapNode(biome->c_top);
|
||||
}
|
||||
|
||||
column_is_open = false;
|
||||
is_tunnel = false;
|
||||
|
@ -665,6 +665,7 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth)
|
||||
for (s16 x = node_min.X; x <= node_max.X; x++, index_2d++) {
|
||||
Biome *biome = (Biome *)m_bmgr->getRaw(biomemap[index_2d]);
|
||||
bool tunnel_air_above = false;
|
||||
bool is_under_river = false;
|
||||
bool underground = false;
|
||||
u32 index_data = vm->m_area.index(x, node_max.Y, z);
|
||||
u32 index_3d = (z - node_min.Z) * zstride_1d + csize.Y * ystride + (x - node_min.X);
|
||||
@ -696,14 +697,13 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth)
|
||||
}
|
||||
|
||||
content_t c = vm->m_data[index_data].getContent();
|
||||
// Detect river water to place riverbed nodes in tunnels
|
||||
if (c == biome->c_river_water)
|
||||
is_under_river = true;
|
||||
|
||||
float d1 = contour(noise_cave1->result[index_3d]);
|
||||
float d2 = contour(noise_cave2->result[index_3d]);
|
||||
|
||||
// River water is not set as ground content
|
||||
// in the default game. This can produce strange results
|
||||
// when a tunnel undercuts a river. However, that's not for
|
||||
// the mapgen to correct. Fix it in lua.
|
||||
|
||||
if (d1 * d2 > cave_width && ndef->get(c).is_ground_content) {
|
||||
// in a tunnel
|
||||
vm->m_data[index_data] = n_air;
|
||||
@ -716,8 +716,10 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth)
|
||||
vm->m_area.add_y(em, j, 1);
|
||||
|
||||
if (sr > terrain - y) {
|
||||
// Put dirt in tunnels near the surface.
|
||||
if (underground)
|
||||
// Put biome nodes in tunnels near the surface
|
||||
if (is_under_river)
|
||||
vm->m_data[index_data] = MapNode(biome->c_riverbed);
|
||||
else if (underground)
|
||||
vm->m_data[index_data] = MapNode(biome->c_filler);
|
||||
else
|
||||
vm->m_data[index_data] = MapNode(biome->c_top);
|
||||
|
Loading…
Reference in New Issue
Block a user