Mgv5/mgv7 caves: Remove sand found in underground tunnels

Add missing check for max_stone_y to mgv5 cavegen
Tunnels now carve through sand below water_level
This commit is contained in:
paramat 2015-06-25 23:55:01 +01:00
parent ffd16e3fec
commit 36163d9653
2 changed files with 17 additions and 34 deletions

View File

@ -506,30 +506,24 @@ MgStoneType MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
void MapgenV5::generateCaves(int max_stone_y) void MapgenV5::generateCaves(int max_stone_y)
{ {
u32 index = 0; if (max_stone_y >= node_min.Y) {
u32 index2d = 0; u32 index = 0;
for (s16 z=node_min.Z; z<=node_max.Z; z++) { for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) { for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z); u32 i = vm->m_area.index(node_min.X, y, z);
for (s16 x=node_min.X; x<=node_max.X; x++, i++, index++, index2d++) { for (s16 x = node_min.X; x <= node_max.X; x++, i++, index++) {
float d1 = contour(noise_cave1->result[index]); float d1 = contour(noise_cave1->result[index]);
float d2 = contour(noise_cave2->result[index]); float d2 = contour(noise_cave2->result[index]);
if (d1*d2 > 0.125) { if (d1*d2 > 0.125) {
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]);
content_t c = vm->m_data[i].getContent(); content_t c = vm->m_data[i].getContent();
if (!ndef->get(c).is_ground_content || c == CONTENT_AIR || if (!ndef->get(c).is_ground_content || c == CONTENT_AIR)
(y <= water_level &&
c != biome->c_stone &&
c != c_stone))
continue; continue;
vm->m_data[i] = MapNode(CONTENT_AIR); vm->m_data[i] = MapNode(CONTENT_AIR);
} }
} }
index2d -= ystride;
} }
index2d += ystride;
} }
if (node_max.Y > LARGE_CAVE_DEPTH) if (node_max.Y > LARGE_CAVE_DEPTH)

View File

@ -852,32 +852,21 @@ void MapgenV7::generateCaves(int max_stone_y)
{ {
if (max_stone_y >= node_min.Y) { if (max_stone_y >= node_min.Y) {
u32 index = 0; u32 index = 0;
u32 index2d = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++) { for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) { for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z); u32 i = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; for (s16 x = node_min.X; x <= node_max.X; x++, i++, index++) {
x++, i++, index++, index2d++) { float d1 = contour(noise_cave1->result[index]);
float d1 = contour(noise_cave1->result[index]); float d2 = contour(noise_cave2->result[index]);
float d2 = contour(noise_cave2->result[index]); if (d1 * d2 > 0.3) {
if (d1 * d2 > 0.3) { content_t c = vm->m_data[i].getContent();
Biome *biome = (Biome *)bmgr-> if (!ndef->get(c).is_ground_content || c == CONTENT_AIR)
getRaw(biomemap[index2d]); continue;
content_t c = vm->m_data[i].getContent();
if (!ndef->get(c).is_ground_content ||
c == CONTENT_AIR ||
(y <= water_level &&
c != biome->c_stone &&
c != c_stone))
continue;
vm->m_data[i] = MapNode(CONTENT_AIR); vm->m_data[i] = MapNode(CONTENT_AIR);
}
} }
index2d -= ystride;
} }
index2d += ystride;
} }
} }