Mapgen: Fix light in tunnels at mapchunk borders
authorparamat <mat.gregory@virginmedia.com>
Sun, 13 Mar 2016 07:56:27 +0000 (07:56 +0000)
committerparamat <mat.gregory@virginmedia.com>
Mon, 14 Mar 2016 08:45:01 +0000 (08:45 +0000)
Don't excavate the overgenerated stone at node_max.Y + 1,
this creates a 'roof' over the tunnel, preventing light in
tunnels at mapchunk borders when generating mapchunks upwards.

src/mapgen_flat.cpp
src/mapgen_fractal.cpp
src/mapgen_v5.cpp
src/mapgen_v7.cpp
src/mapgen_valleys.cpp

index 0d071411d75a5a376511804c90e035f656003ffa..d654a772e25fa5334fee1c553c52d0147af06649 100644 (file)
@@ -573,6 +573,12 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
 
                for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
                                y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
+                       // Don't excavate the overgenerated stone at node_max.Y + 1,
+                       // this creates a 'roof' over the tunnel, preventing light in
+                       // tunnels at mapchunk borders when generating mapchunks upwards.
+                       if (y > node_max.Y)
+                               continue;
+
                        content_t c = vm->m_data[vi].getContent();
                        if (c == CONTENT_AIR || c == biome->c_water_top ||
                                        c == biome->c_water) {
index 8a5c1e2bc8dde8b2d87f80d6c305880f15d6f9a7..cdea9c09af854e0e4ba79ed186db1e982c8bcb59 100644 (file)
@@ -701,6 +701,12 @@ void MapgenFractal::generateCaves(s16 max_stone_y)
 
                for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
                                y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
+                       // Don't excavate the overgenerated stone at node_max.Y + 1,
+                       // this creates a 'roof' over the tunnel, preventing light in
+                       // tunnels at mapchunk borders when generating mapchunks upwards.
+                       if (y > node_max.Y)
+                               continue;
+
                        content_t c = vm->m_data[vi].getContent();
                        if (c == CONTENT_AIR || c == biome->c_water_top ||
                                        c == biome->c_water) {
index 0bb3715a85337773a3a5b2ac2d5d64be4ecb42c9..e9b1b58b3599686ec1619b74d60ff17e75bfb415 100644 (file)
@@ -519,6 +519,12 @@ void MapgenV5::generateCaves(int max_stone_y)
        for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
                u32 vi = vm->m_area.index(node_min.X, y, z);
                for (s16 x = node_min.X; x <= node_max.X; x++, vi++, index++) {
+                       // Don't excavate the overgenerated stone at node_max.Y + 1,
+                       // this creates a 'roof' over the tunnel, preventing light in
+                       // tunnels at mapchunk borders when generating mapchunks upwards.
+                       if (y > node_max.Y)
+                               continue;
+
                        float d1 = contour(noise_cave1->result[index]);
                        float d2 = contour(noise_cave2->result[index]);
                        if (d1 * d2 > 0.125f) {
index 029f56a45a74d3d9b8f38dcbaa7024ab552d065e..24867623cec11b551ce329d9f8016e89ded8a473 100644 (file)
@@ -883,6 +883,12 @@ void MapgenV7::generateCaves(s16 max_stone_y)
 
                for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
                                y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
+                       // Don't excavate the overgenerated stone at node_max.Y + 1,
+                       // this creates a 'roof' over the tunnel, preventing light in
+                       // tunnels at mapchunk borders when generating mapchunks upwards.
+                       if (y > node_max.Y)
+                               continue;
+
                        content_t c = vm->m_data[vi].getContent();
                        if (c == CONTENT_AIR || c == biome->c_water_top ||
                                        c == biome->c_water) {
index d6fcde5f78b90c9cb8c24636c53120eaba98cc36..34a316abddbd9ef117634ce27b77d4d4a4bf7082 100644 (file)
@@ -931,6 +931,12 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
                for (s16 y = node_max.Y + 1;
                                y >= node_min.Y - 1;
                                y--, index_3d -= ystride, vm->m_area.add_y(em, index_data, -1)) {
+                       // Don't excavate the overgenerated stone at node_max.Y + 1,
+                       // this creates a 'roof' over the tunnel, preventing light in
+                       // tunnels at mapchunk borders when generating mapchunks upwards.
+                       if (y > node_max.Y)
+                               continue;
+
                        float terrain = noise_terrain_height->result[index_2d];
 
                        // Saves some time.