mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-08 11:05:28 +01:00
Cavegen y biome check (#13472)
This commit is contained in:
@@ -38,14 +38,16 @@ static NoiseParams nparams_caveliquids(0, 1, v3f(150.0, 150.0, 150.0), 776, 3, 0
|
||||
////
|
||||
|
||||
CavesNoiseIntersection::CavesNoiseIntersection(
|
||||
const NodeDefManager *nodedef, BiomeManager *biomemgr, v3s16 chunksize,
|
||||
const NodeDefManager *nodedef, BiomeManager *biomemgr, BiomeGen *biomegen, v3s16 chunksize,
|
||||
NoiseParams *np_cave1, NoiseParams *np_cave2, s32 seed, float cave_width)
|
||||
{
|
||||
assert(nodedef);
|
||||
assert(biomemgr);
|
||||
assert(biomegen);
|
||||
|
||||
m_ndef = nodedef;
|
||||
m_bmgr = biomemgr;
|
||||
m_bmgn = biomegen;
|
||||
|
||||
m_csize = chunksize;
|
||||
m_cave_width = cave_width;
|
||||
@@ -80,6 +82,8 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
|
||||
const v3s16 &em = vm->m_area.getExtent();
|
||||
u32 index2d = 0; // Biomemap index
|
||||
|
||||
s16 *biome_transitions = m_bmgn->getBiomeTransitions();
|
||||
|
||||
for (s16 z = nmin.Z; z <= nmax.Z; z++)
|
||||
for (s16 x = nmin.X; x <= nmax.X; x++, index2d++) {
|
||||
bool column_is_open = false; // Is column open to overground
|
||||
@@ -96,6 +100,10 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
|
||||
u16 base_filler = depth_top + biome->depth_filler;
|
||||
u16 depth_riverbed = biome->depth_riverbed;
|
||||
u16 nplaced = 0;
|
||||
|
||||
int cur_biome_depth = 0;
|
||||
s16 biome_y_min = biome_transitions[cur_biome_depth];
|
||||
|
||||
// Don't excavate the overgenerated stone at nmax.Y + 1,
|
||||
// this creates a 'roof' over the tunnel, preventing light in
|
||||
// tunnels at mapchunk borders when generating mapchunks upwards.
|
||||
@@ -103,6 +111,20 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
|
||||
for (s16 y = nmax.Y; y >= nmin.Y - 1; y--,
|
||||
index3d -= m_ystride,
|
||||
VoxelArea::add_y(em, vi, -1)) {
|
||||
// We need this check to make sure that biomes don't generate too far down
|
||||
if (y < biome_y_min) {
|
||||
biome = m_bmgn->getBiomeAtIndex(index2d, v3s16(x, y, z));
|
||||
|
||||
// Finding the height of the next biome
|
||||
// On first iteration this may loop a couple times after than it should just run once
|
||||
while (y < biome_y_min) {
|
||||
biome_y_min = biome_transitions[++cur_biome_depth];
|
||||
}
|
||||
|
||||
/*if (x == nmin.X && z == nmin.Z)
|
||||
printf("Cave: check @ %i -> %s -> again at %i\n", y, biome->name.c_str(), biome_y_min);*/
|
||||
}
|
||||
|
||||
content_t c = vm->m_data[vi].getContent();
|
||||
|
||||
if (c == CONTENT_AIR || c == biome->c_water_top ||
|
||||
|
||||
Reference in New Issue
Block a user