noise_cave1->perlinMap3D(nmin.X, nmin.Y - 1, nmin.Z);
noise_cave2->perlinMap3D(nmin.X, nmin.Y - 1, nmin.Z);
- v3s16 em = vm->m_area.getExtent();
+ const v3s16 &em = vm->m_area.getExtent();
u32 index2d = 0; // Biomemap index
for (s16 z = nmin.Z; z <= nmax.Z; z++)
{
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;
noise_cavern->perlinMap3D(nmin.X, nmin.Y - 1, nmin.Z);
// Cache cavern_amp values
- float cavern_amp[m_csize.Y + 1];
+ float *cavern_amp = new float[m_csize.Y + 1];
u8 cavern_amp_index = 0; // Index zero at column top
for (s16 y = nmax.Y; y >= nmin.Y - 1; y--, cavern_amp_index++) {
cavern_amp[cavern_amp_index] =
}
//// Place nodes
- bool has_cavern = false;
- v3s16 em = vm->m_area.getExtent();
+ bool near_cavern = false;
+ const v3s16 &em = vm->m_area.getExtent();
u32 index2d = 0;
for (s16 z = nmin.Z; z <= nmax.Z; z++)
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);
}
}
}
- return has_cavern;
+ delete[] cavern_amp;
+
+ return near_cavern;
}
s32 seed,
int water_level,
content_t water_source,
- content_t lava_source)
+ content_t lava_source,
+ int lava_depth)
{
assert(ndef);
this->seed = seed;
this->water_level = water_level;
this->np_caveliquids = &nparams_caveliquids;
- this->lava_depth = DEFAULT_LAVA_DEPTH;
+ this->lava_depth = lava_depth;
c_water_source = water_source;
if (c_water_source == CONTENT_IGNORE)
v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
p += of;
- if (vm->m_area.contains(p) == false)
+ if (!vm->m_area.contains(p))
continue;
u32 i = vm->m_area.index(p);
v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
p += of;
- if (vm->m_area.contains(p) == false)
+ if (!vm->m_area.contains(p))
continue;
u32 i = vm->m_area.index(p);
p.X >= node_min.X && p.X <= node_max.X) {
u32 index = (p.Z - node_min.Z) * ystride + (p.X - node_min.X);
return heightmap[index];
- } else {
- return water_level;
}
+
+ return water_level;
+
}