1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-10 19:32:10 +00:00

Refactor "Cavegen y biome check"

This commit is contained in:
sfan5 2024-09-06 11:30:10 +02:00 committed by GitHub
parent 486dc3288d
commit 3af226cb06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 51 deletions

View file

@ -82,8 +82,6 @@ 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
@ -101,8 +99,7 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
u16 depth_riverbed = biome->depth_riverbed;
u16 nplaced = 0;
int cur_biome_depth = 0;
s16 biome_y_min = biome_transitions[cur_biome_depth];
s16 biome_y_min = m_bmgn->getNextTransitionY(nmax.Y);
// Don't excavate the overgenerated stone at nmax.Y + 1,
// this creates a 'roof' over the tunnel, preventing light in
@ -114,15 +111,12 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
// 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));
biome_y_min = m_bmgn->getNextTransitionY(y);
// 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 && false) {
dstream << "cavegen: biome at " << y << " is " << biome->name
<< ", next at " << biome_y_min << std::endl;
}
/*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();