Caverns: Remove unnecessary liquid excavation
authorparamat <mat.gregory@virginmedia.com>
Thu, 11 May 2017 02:39:43 +0000 (03:39 +0100)
committerparamat <mat.gregory@virginmedia.com>
Tue, 16 May 2017 20:56:51 +0000 (21:56 +0100)
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.

src/cavegen.cpp
src/mapgen_v5.cpp
src/mapgen_v7.cpp

index 7993b20e7932a7ab2dd0631c091f2481129b2442..dbed7995111dc5c4a614749f32763bd1f91cae65 100644 (file)
@@ -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;
 }
 
 
index c7079d2290e8e5f47cd97b33a77f9db5b5c807cd..1c4d1fd70ac3ab761d9e67344a9a47e8eaa243f7 100644 (file)
@@ -204,12 +204,12 @@ void MapgenV5::makeChunk(BlockMakeData *data)
 
        // Generate caverns, tunnels and classic caves
        if (flags & MG_CAVES) {
-               bool has_cavern = false;
+               bool near_cavern = false;
                // Generate caverns
                if (spflags & MGV5_CAVERNS)
-                       has_cavern = generateCaverns(stone_surface_max_y);
+                       near_cavern = generateCaverns(stone_surface_max_y);
                // Generate tunnels and classic caves
-               if (has_cavern)
+               if (near_cavern)
                        // Disable classic caves in this mapchunk by setting
                        // 'large cave depth' to world base. Avoids excessive liquid in
                        // large caverns and floating blobs of overgenerated liquid.
index 420d771851a1a4559e7bae9d7cadf2257c2a7ec7..dbf2b02ae38fbf76a649436bff22b244e2b1fc63 100644 (file)
@@ -292,12 +292,12 @@ void MapgenV7::makeChunk(BlockMakeData *data)
 
        // Generate caverns, tunnels and classic caves
        if (flags & MG_CAVES) {
-               bool has_cavern = false;
+               bool near_cavern = false;
                // Generate caverns
                if (spflags & MGV7_CAVERNS)
-                       has_cavern = generateCaverns(stone_surface_max_y);
+                       near_cavern = generateCaverns(stone_surface_max_y);
                // Generate tunnels and classic caves
-               if (has_cavern)
+               if (near_cavern)
                        // Disable classic caves in this mapchunk by setting
                        // 'large cave depth' to world base. Avoids excessive liquid in
                        // large caverns and floating blobs of overgenerated liquid.