Skip to content

Commit

Permalink
Mgv7, mgflat, mgfractal: Tunnel generation code optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
paramat committed Apr 12, 2016
1 parent e661d8b commit 4fdf66b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
13 changes: 7 additions & 6 deletions src/mapgen_flat.cpp
Expand Up @@ -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;
}
Expand Down
13 changes: 7 additions & 6 deletions src/mapgen_fractal.cpp
Expand Up @@ -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;
}
Expand Down
13 changes: 7 additions & 6 deletions src/mapgen_v7.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4fdf66b

Please sign in to comment.