1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Cavegen y biome check (#13472)

This commit is contained in:
Riley Adams 2023-06-05 05:59:22 -04:00 committed by GitHub
parent 1ef9fc9d1f
commit 29b7aea38b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 7 deletions

View file

@ -147,18 +147,50 @@ BiomeGenOriginal::BiomeGenOriginal(BiomeManager *biomemgr,
// fallback biome when biome generation (which calculates the biomemap IDs)
// is disabled.
memset(biomemap, 0, sizeof(biome_t) * m_csize.X * m_csize.Z);
// Calculating the bounding position of each biome so we know when we might switch
// First gathering all heights where we might switch
std::vector<s16> temp_transition_heights;
temp_transition_heights.reserve(m_bmgr->getNumObjects() * 2);
for (size_t i = 0; i < m_bmgr->getNumObjects(); i++) {
Biome *b = (Biome *)m_bmgr->getRaw(i);
temp_transition_heights.push_back(b->max_pos.Y);
temp_transition_heights.push_back(b->min_pos.Y);
}
// Sorting the biome transition points
std::sort(temp_transition_heights.begin(), temp_transition_heights.end(), std::greater<int>());
// Getting rid of duplicate biome transition points
s16 last = temp_transition_heights[0];
size_t out_pos = 1;
for (size_t i = 1; i < temp_transition_heights.size(); i++){
if (temp_transition_heights[i] != last) {
last = temp_transition_heights[i];
temp_transition_heights[out_pos++] = last;
}
}
biome_transitions = new s16[out_pos];
memcpy(biome_transitions, temp_transition_heights.data(), sizeof(s16) * out_pos);
}
BiomeGenOriginal::~BiomeGenOriginal()
{
delete []biomemap;
delete []biome_transitions;
delete noise_heat;
delete noise_humidity;
delete noise_heat_blend;
delete noise_humidity_blend;
}
s16* BiomeGenOriginal::getBiomeTransitions() const
{
return biome_transitions;
}
BiomeGen *BiomeGenOriginal::clone(BiomeManager *biomemgr) const
{
return new BiomeGenOriginal(biomemgr, m_params, m_csize);