Mgv7/flat/fractal: Stop tunnel-floor biome nodes being placed everywhere

A bool for 'in or under tunnel' was missing
1-node-deep stone ledges were being
replaced with biome surface material
This commit is contained in:
paramat 2016-03-19 19:10:37 +00:00
parent 93887043d9
commit 493a298c0c
3 changed files with 15 additions and 3 deletions

@ -565,6 +565,7 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
for (s16 z = node_min.Z; z <= node_max.Z; z++) for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) { for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
bool column_is_open = false; // Is column open to overground bool column_is_open = false; // Is column open to overground
bool is_tunnel = false; // Is tunnel or tunnel floor
u32 vi = vm->m_area.index(x, node_max.Y + 1, z); u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride + u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
(x - node_min.X); (x - node_min.X);
@ -591,13 +592,16 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) { if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
// In tunnel and ground content, excavate // In tunnel and ground content, excavate
vm->m_data[vi] = MapNode(CONTENT_AIR); vm->m_data[vi] = MapNode(CONTENT_AIR);
} else if (column_is_open && is_tunnel = true;
} else if (is_tunnel && column_is_open &&
(c == biome->c_filler || c == biome->c_stone)) { (c == biome->c_filler || c == biome->c_stone)) {
// Tunnel entrance floor // Tunnel entrance floor
vm->m_data[vi] = MapNode(biome->c_top); vm->m_data[vi] = MapNode(biome->c_top);
column_is_open = false; column_is_open = false;
is_tunnel = false;
} else { } else {
column_is_open = false; column_is_open = false;
is_tunnel = false;
} }
} }
} }

@ -693,6 +693,7 @@ void MapgenFractal::generateCaves(s16 max_stone_y)
for (s16 z = node_min.Z; z <= node_max.Z; z++) for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) { for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
bool column_is_open = false; // Is column open to overground bool column_is_open = false; // Is column open to overground
bool is_tunnel = false; // Is tunnel or tunnel floor
u32 vi = vm->m_area.index(x, node_max.Y + 1, z); u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride + u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
(x - node_min.X); (x - node_min.X);
@ -719,13 +720,16 @@ void MapgenFractal::generateCaves(s16 max_stone_y)
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) { if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
// In tunnel and ground content, excavate // In tunnel and ground content, excavate
vm->m_data[vi] = MapNode(CONTENT_AIR); vm->m_data[vi] = MapNode(CONTENT_AIR);
} else if (column_is_open && is_tunnel = true;
} else if (is_tunnel && column_is_open &&
(c == biome->c_filler || c == biome->c_stone)) { (c == biome->c_filler || c == biome->c_stone)) {
// Tunnel entrance floor // Tunnel entrance floor
vm->m_data[vi] = MapNode(biome->c_top); vm->m_data[vi] = MapNode(biome->c_top);
column_is_open = false; column_is_open = false;
is_tunnel = false;
} else { } else {
column_is_open = false; column_is_open = false;
is_tunnel = false;
} }
} }
} }

@ -875,6 +875,7 @@ void MapgenV7::generateCaves(s16 max_stone_y)
for (s16 z = node_min.Z; z <= node_max.Z; z++) for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) { for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
bool column_is_open = false; // Is column open to overground bool column_is_open = false; // Is column open to overground
bool is_tunnel = false; // Is tunnel or tunnel floor
u32 vi = vm->m_area.index(x, node_max.Y + 1, z); u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride + u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
(x - node_min.X); (x - node_min.X);
@ -901,13 +902,16 @@ void MapgenV7::generateCaves(s16 max_stone_y)
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) { if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
// In tunnel and ground content, excavate // In tunnel and ground content, excavate
vm->m_data[vi] = MapNode(CONTENT_AIR); vm->m_data[vi] = MapNode(CONTENT_AIR);
} else if (column_is_open && is_tunnel = true;
} else if (is_tunnel && column_is_open &&
(c == biome->c_filler || c == biome->c_stone)) { (c == biome->c_filler || c == biome->c_stone)) {
// Tunnel entrance floor // Tunnel entrance floor
vm->m_data[vi] = MapNode(biome->c_top); vm->m_data[vi] = MapNode(biome->c_top);
column_is_open = false; column_is_open = false;
is_tunnel = false;
} else { } else {
column_is_open = false; column_is_open = false;
is_tunnel = false;
} }
} }
} }