aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2016-04-12 04:43:22 +0100
committerparamat <mat.gregory@virginmedia.com>2016-04-12 06:58:04 +0100
commit4fdf66bbf4d90846844ee3f6d41acb31ce06ca8b (patch)
tree1b5159c125275b472b06b2e89210b43de3a35561
parente661d8b32c99681c98b8bc469ceb19f7699cf381 (diff)
downloadminetest-4fdf66bbf4d90846844ee3f6d41acb31ce06ca8b.tar.gz
minetest-4fdf66bbf4d90846844ee3f6d41acb31ce06ca8b.tar.bz2
minetest-4fdf66bbf4d90846844ee3f6d41acb31ce06ca8b.zip
Mgv7, mgflat, mgfractal: Tunnel generation code optimisation
-rw-r--r--src/mapgen_flat.cpp13
-rw-r--r--src/mapgen_fractal.cpp13
-rw-r--r--src/mapgen_v7.cpp13
3 files changed, 21 insertions, 18 deletions
diff --git a/src/mapgen_flat.cpp b/src/mapgen_flat.cpp
index ecfbe49ba..0c243842e 100644
--- a/src/mapgen_flat.cpp
+++ b/src/mapgen_flat.cpp
@@ -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;
}
diff --git a/src/mapgen_fractal.cpp b/src/mapgen_fractal.cpp
index 810645abb..d75d1149e 100644
--- a/src/mapgen_fractal.cpp
+++ b/src/mapgen_fractal.cpp
@@ -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;
}
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index 54abba145..069c34119 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -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;
}