mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Cavegen: Fix errors when getting biome outside mapchunk (#7480)
Some cave segments are outside the mapchunk. Previously, biome was being calculated by a function that uses the noise maps. Points outside the mapchunk resulted in incorrect noise map indexes that were sometimes outside the noise map size, causing a crash. Use either noise maps or point noise calculations depending on point location.
This commit is contained in:
parent
b589352e79
commit
93661ca212
1 changed files with 10 additions and 1 deletions
|
@ -507,7 +507,16 @@ void CavesRandomWalk::carveRoute(v3f vec, float f, bool randomize_xz)
|
||||||
MapNode liquidnode = CONTENT_IGNORE;
|
MapNode liquidnode = CONTENT_IGNORE;
|
||||||
|
|
||||||
if (bmgn) {
|
if (bmgn) {
|
||||||
Biome *biome = (Biome *)bmgn->getBiomeAtPoint(cpabs);
|
Biome *biome = nullptr;
|
||||||
|
if (cpabs.X < node_min.X || cpabs.X > node_max.X ||
|
||||||
|
cpabs.Z < node_min.Z || cpabs.Z > node_max.Z)
|
||||||
|
// Point is outside heat and humidity noise maps so use point noise
|
||||||
|
// calculations.
|
||||||
|
biome = (Biome *)bmgn->calcBiomeAtPoint(cpabs);
|
||||||
|
else
|
||||||
|
// Point is inside heat and humidity noise maps so use them
|
||||||
|
biome = (Biome *)bmgn->getBiomeAtPoint(cpabs);
|
||||||
|
|
||||||
if (biome->c_cave_liquid != CONTENT_IGNORE)
|
if (biome->c_cave_liquid != CONTENT_IGNORE)
|
||||||
liquidnode = biome->c_cave_liquid;
|
liquidnode = biome->c_cave_liquid;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue