diff options
author | paramat <mat.gregory@virginmedia.com> | 2016-07-20 00:23:08 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-07-21 05:01:18 +0100 |
commit | 2ba8ad1dfe2698cf9820a6dde3b40423cd719ddf (patch) | |
tree | 90ee8e2d6b1fc8868dc266c289748db6e95605ee /src | |
parent | 97c763158c3efd733bca1b4b46fb82c135df09f7 (diff) | |
download | minetest-2ba8ad1dfe2698cf9820a6dde3b40423cd719ddf.tar.gz minetest-2ba8ad1dfe2698cf9820a6dde3b40423cd719ddf.tar.bz2 minetest-2ba8ad1dfe2698cf9820a6dde3b40423cd719ddf.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/cavegen.cpp | 13 | ||||
-rw-r--r-- | src/mapgen_valleys.cpp | 16 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/cavegen.cpp b/src/cavegen.cpp index dc7355fe0..bb6aa25a6 100644 --- a/src/cavegen.cpp +++ b/src/cavegen.cpp @@ -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; diff --git a/src/mapgen_valleys.cpp b/src/mapgen_valleys.cpp index a61f1b329..456e6aa1a 100644 --- a/src/mapgen_valleys.cpp +++ b/src/mapgen_valleys.cpp @@ -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); |