Skip to content

Commit fd32005

Browse files
committedMay 16, 2017
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.
1 parent 582ee15 commit fd32005

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed
 

‎src/cavegen.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ CavernsNoise::CavernsNoise(
160160
{
161161
assert(nodedef);
162162

163-
m_ndef = nodedef;
163+
m_ndef = nodedef;
164164

165-
m_csize = chunksize;
165+
m_csize = chunksize;
166166
m_cavern_limit = cavern_limit;
167167
m_cavern_taper = cavern_taper;
168168
m_cavern_threshold = cavern_threshold;
@@ -207,7 +207,7 @@ bool CavernsNoise::generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax)
207207
}
208208

209209
//// Place nodes
210-
bool has_cavern = false;
210+
bool near_cavern = false;
211211
v3s16 em = vm->m_area.getExtent();
212212
u32 index2d = 0;
213213

@@ -229,20 +229,22 @@ bool CavernsNoise::generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax)
229229
vm->m_area.add_y(em, vi, -1),
230230
cavern_amp_index++) {
231231
content_t c = vm->m_data[vi].getContent();
232-
float nabs_cavern = fabs(noise_cavern->result[index3d]);
233-
// Caverns generate first but still remove lava and water in case
234-
// of overgenerated classic caves.
235-
if (nabs_cavern * cavern_amp[cavern_amp_index] > m_cavern_threshold &&
236-
(m_ndef->get(c).is_ground_content ||
237-
c == c_lava_source || c == c_water_source)) {
238-
vm->m_data[vi] = MapNode(CONTENT_AIR);
239-
has_cavern = true;
232+
float n_absamp_cavern = fabs(noise_cavern->result[index3d]) *
233+
cavern_amp[cavern_amp_index];
234+
// Disable CavesRandomWalk at a safe distance from caverns
235+
// to avoid excessively spreading liquids in caverns.
236+
if (n_absamp_cavern > m_cavern_threshold - 0.1f) {
237+
near_cavern = true;
238+
if (n_absamp_cavern > m_cavern_threshold &&
239+
m_ndef->get(c).is_ground_content)
240+
vm->m_data[vi] = MapNode(CONTENT_AIR);
240241
}
241242
}
242243
}
243244

244245
delete[] cavern_amp;
245-
return has_cavern;
246+
247+
return near_cavern;
246248
}
247249

248250

‎src/mapgen_v5.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ void MapgenV5::makeChunk(BlockMakeData *data)
204204

205205
// Generate caverns, tunnels and classic caves
206206
if (flags & MG_CAVES) {
207-
bool has_cavern = false;
207+
bool near_cavern = false;
208208
// Generate caverns
209209
if (spflags & MGV5_CAVERNS)
210-
has_cavern = generateCaverns(stone_surface_max_y);
210+
near_cavern = generateCaverns(stone_surface_max_y);
211211
// Generate tunnels and classic caves
212-
if (has_cavern)
212+
if (near_cavern)
213213
// Disable classic caves in this mapchunk by setting
214214
// 'large cave depth' to world base. Avoids excessive liquid in
215215
// large caverns and floating blobs of overgenerated liquid.

‎src/mapgen_v7.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ void MapgenV7::makeChunk(BlockMakeData *data)
292292

293293
// Generate caverns, tunnels and classic caves
294294
if (flags & MG_CAVES) {
295-
bool has_cavern = false;
295+
bool near_cavern = false;
296296
// Generate caverns
297297
if (spflags & MGV7_CAVERNS)
298-
has_cavern = generateCaverns(stone_surface_max_y);
298+
near_cavern = generateCaverns(stone_surface_max_y);
299299
// Generate tunnels and classic caves
300-
if (has_cavern)
300+
if (near_cavern)
301301
// Disable classic caves in this mapchunk by setting
302302
// 'large cave depth' to world base. Avoids excessive liquid in
303303
// large caverns and floating blobs of overgenerated liquid.

0 commit comments

Comments
 (0)
Please sign in to comment.