diff options
author | paramat <paramat@users.noreply.github.com> | 2017-09-11 21:23:43 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-09-14 04:13:47 +0100 |
commit | 7640749d68b87a62868840d34a665101861ca9c0 (patch) | |
tree | 98c7d5c02cfbe841221d5a10d588731ce3b634c0 | |
parent | a9d43a04713dd0342d675f3bbb5cbacd863b4118 (diff) | |
download | minetest-7640749d68b87a62868840d34a665101861ca9c0.tar.gz minetest-7640749d68b87a62868840d34a665101861ca9c0.tar.bz2 minetest-7640749d68b87a62868840d34a665101861ca9c0.zip |
Cavegen: Avoid unsupported biome 'top' or 'filler' nodes
For 3D noise tunnels only, replace unsupported biome 'top' and 'filler'
nodes in tunnel roof with the defined biome 'stone'.
This makes terrain created by 3D noise tunnels consistent with the rest
of mapgen, which does exactly the same in this situation.
-rw-r--r-- | src/cavegen.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/cavegen.cpp b/src/cavegen.cpp index ad5103893..e66634517 100644 --- a/src/cavegen.cpp +++ b/src/cavegen.cpp @@ -81,6 +81,7 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm, bool column_is_open = false; // Is column open to overground bool is_under_river = false; // Is column under river water bool is_under_tunnel = false; // Is tunnel or is under tunnel + bool is_top_filler_above = false; // Is top or filler above node // Indexes at column top u32 vi = vm->m_area.index(x, nmax.Y, z); u32 index3d = (z - nmin.Z) * m_zstride_1d + m_csize.Y * m_ystride + @@ -98,19 +99,22 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm, for (s16 y = nmax.Y; y >= nmin.Y - 1; y--, index3d -= m_ystride, vm->m_area.add_y(em, vi, -1)) { - content_t c = vm->m_data[vi].getContent(); + if (c == CONTENT_AIR || c == biome->c_water_top || c == biome->c_water) { column_is_open = true; + is_top_filler_above = false; continue; } if (c == biome->c_river_water) { column_is_open = true; is_under_river = true; + is_top_filler_above = false; continue; } + // Ground float d1 = contour(noise_cave1->result[index3d]); float d2 = contour(noise_cave2->result[index3d]); @@ -119,12 +123,17 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm, // In tunnel and ground content, excavate vm->m_data[vi] = MapNode(CONTENT_AIR); is_under_tunnel = true; + // If tunnel roof is top or filler, replace with stone + if (is_top_filler_above) + vm->m_data[vi + em.X] = MapNode(biome->c_stone); + is_top_filler_above = false; } else if (column_is_open && is_under_tunnel && (c == biome->c_stone || c == biome->c_filler)) { // Tunnel entrance floor, place biome surface nodes if (is_under_river) { if (nplaced < depth_riverbed) { vm->m_data[vi] = MapNode(biome->c_riverbed); + is_top_filler_above = true; nplaced++; } else { // Disable top/filler placement @@ -134,9 +143,11 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm, } } else if (nplaced < depth_top) { vm->m_data[vi] = MapNode(biome->c_top); + is_top_filler_above = true; nplaced++; } else if (nplaced < base_filler) { vm->m_data[vi] = MapNode(biome->c_filler); + is_top_filler_above = true; nplaced++; } else { // Disable top/filler placement @@ -145,6 +156,10 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm, } } else { // Not tunnel or tunnel entrance floor + // Check node for possible replacing with stone for tunnel roof + if (c == biome->c_top || c == biome->c_filler) + is_top_filler_above = true; + column_is_open = false; } } |