summaryrefslogtreecommitdiff
path: root/src/cavegen.cpp
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2017-05-11 03:39:43 +0100
committerparamat <mat.gregory@virginmedia.com>2017-05-16 21:56:51 +0100
commitfd32005b0f886450ada99f36460c1de58b6a832b (patch)
tree2d979dd491c912643c797abb1461ea0eb9f94b22 /src/cavegen.cpp
parent582ee15d8e861efb9cc843963a95c087dae91bcc (diff)
downloadminetest-fd32005b0f886450ada99f36460c1de58b6a832b.tar.gz
minetest-fd32005b0f886450ada99f36460c1de58b6a832b.tar.bz2
minetest-fd32005b0f886450ada99f36460c1de58b6a832b.zip
Caverns: Remove unnecessary liquid excavation
Also disable CavesRandomWalk at a safer distance from caverns. Excavating liquids in cavern code is unnecessary as in practice we are already successfully disabling the generation of liquid caves that could intersect with caverns and cause excessive amounts of spreading liquids in caverns. However to be safer this commit now disables liquid caves at a larger distance from caverns, to compensate for liquid caves being able to generate up to a mapblock beyond a mapchunk border. Not excavating liquids in cavern code also allows a feature i am working on in experimental new core mapgens, but also allows for more flexibility in future.
Diffstat (limited to 'src/cavegen.cpp')
-rw-r--r--src/cavegen.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/cavegen.cpp b/src/cavegen.cpp
index 7993b20e7..dbed79951 100644
--- a/src/cavegen.cpp
+++ b/src/cavegen.cpp
@@ -160,9 +160,9 @@ CavernsNoise::CavernsNoise(
{
assert(nodedef);
- m_ndef = nodedef;
+ m_ndef = nodedef;
- m_csize = chunksize;
+ m_csize = chunksize;
m_cavern_limit = cavern_limit;
m_cavern_taper = cavern_taper;
m_cavern_threshold = cavern_threshold;
@@ -207,7 +207,7 @@ bool CavernsNoise::generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax)
}
//// Place nodes
- bool has_cavern = false;
+ bool near_cavern = false;
v3s16 em = vm->m_area.getExtent();
u32 index2d = 0;
@@ -229,20 +229,22 @@ bool CavernsNoise::generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax)
vm->m_area.add_y(em, vi, -1),
cavern_amp_index++) {
content_t c = vm->m_data[vi].getContent();
- float nabs_cavern = fabs(noise_cavern->result[index3d]);
- // Caverns generate first but still remove lava and water in case
- // of overgenerated classic caves.
- if (nabs_cavern * cavern_amp[cavern_amp_index] > m_cavern_threshold &&
- (m_ndef->get(c).is_ground_content ||
- c == c_lava_source || c == c_water_source)) {
- vm->m_data[vi] = MapNode(CONTENT_AIR);
- has_cavern = true;
+ float n_absamp_cavern = fabs(noise_cavern->result[index3d]) *
+ cavern_amp[cavern_amp_index];
+ // Disable CavesRandomWalk at a safe distance from caverns
+ // to avoid excessively spreading liquids in caverns.
+ if (n_absamp_cavern > m_cavern_threshold - 0.1f) {
+ near_cavern = true;
+ if (n_absamp_cavern > m_cavern_threshold &&
+ m_ndef->get(c).is_ground_content)
+ vm->m_data[vi] = MapNode(CONTENT_AIR);
}
}
}
delete[] cavern_amp;
- return has_cavern;
+
+ return near_cavern;
}