Mgv7, mgflat, mgfractal: Tunnel generation code optimisation
authorparamat <mat.gregory@virginmedia.com>
Tue, 12 Apr 2016 03:43:22 +0000 (04:43 +0100)
committerparamat <mat.gregory@virginmedia.com>
Tue, 12 Apr 2016 05:58:04 +0000 (06:58 +0100)
src/mapgen_flat.cpp
src/mapgen_fractal.cpp
src/mapgen_v7.cpp

index ecfbe49ba4d51360feb0ff1d684e0d7e8ac0f839..0c243842ed97a3d29a4be248361d08da40046327 100644 (file)
@@ -591,17 +591,18 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
                        // Ground
                        float d1 = contour(noise_cave1->result[index3d]);
                        float d2 = contour(noise_cave2->result[index3d]);
+
                        if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
                                // In tunnel and ground content, excavate
                                vm->m_data[vi] = MapNode(CONTENT_AIR);
                                is_tunnel = true;
-                       } else if (is_tunnel && column_is_open &&
-                                       (c == biome->c_filler || c == biome->c_stone)) {
-                               // Tunnel entrance floor
-                               vm->m_data[vi] = MapNode(biome->c_top);
-                               column_is_open = false;
-                               is_tunnel = false;
                        } else {
+                               // Not in tunnel or not ground content
+                               if (is_tunnel && column_is_open &&
+                                               (c == biome->c_filler || c == biome->c_stone))
+                                       // Tunnel entrance floor
+                                       vm->m_data[vi] = MapNode(biome->c_top);
+
                                column_is_open = false;
                                is_tunnel = false;
                        }
index 810645abbee3518dce362f0648ddbdc44d525ebf..d75d1149e4082ac1a3751be60bdae13958b158ec 100644 (file)
@@ -719,17 +719,18 @@ void MapgenFractal::generateCaves(s16 max_stone_y)
                        // Ground
                        float d1 = contour(noise_cave1->result[index3d]);
                        float d2 = contour(noise_cave2->result[index3d]);
+
                        if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
                                // In tunnel and ground content, excavate
                                vm->m_data[vi] = MapNode(CONTENT_AIR);
                                is_tunnel = true;
-                       } else if (is_tunnel && column_is_open &&
-                                       (c == biome->c_filler || c == biome->c_stone)) {
-                               // Tunnel entrance floor
-                               vm->m_data[vi] = MapNode(biome->c_top);
-                               column_is_open = false;
-                               is_tunnel = false;
                        } else {
+                               // Not in tunnel or not ground content
+                               if (is_tunnel && column_is_open &&
+                                               (c == biome->c_filler || c == biome->c_stone))
+                                       // Tunnel entrance floor
+                                       vm->m_data[vi] = MapNode(biome->c_top);
+
                                column_is_open = false;
                                is_tunnel = false;
                        }
index 54abba1459223b2b5eb03fc62b25e5069e3de9c3..069c341199c69b49d9c91e8b7887f825bd0cca1a 100644 (file)
@@ -772,17 +772,18 @@ void MapgenV7::generateCaves(s16 max_stone_y)
                        // Ground
                        float d1 = contour(noise_cave1->result[index3d]);
                        float d2 = contour(noise_cave2->result[index3d]);
+
                        if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
                                // In tunnel and ground content, excavate
                                vm->m_data[vi] = MapNode(CONTENT_AIR);
                                is_tunnel = true;
-                       } else if (is_tunnel && column_is_open &&
-                                       (c == biome->c_filler || c == biome->c_stone)) {
-                               // Tunnel entrance floor
-                               vm->m_data[vi] = MapNode(biome->c_top);
-                               column_is_open = false;
-                               is_tunnel = false;
                        } else {
+                               // Not in tunnel or not ground content
+                               if (is_tunnel && column_is_open &&
+                                               (c == biome->c_filler || c == biome->c_stone))
+                                       // Tunnel entrance floor
+                                       vm->m_data[vi] = MapNode(biome->c_top);
+
                                column_is_open = false;
                                is_tunnel = false;
                        }