@@ -633,6 +633,7 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
633
633
u16 base_filler = 0 ;
634
634
u16 depth_water_top = 0 ;
635
635
u16 depth_riverbed = 0 ;
636
+ s16 biome_y_min = -MAX_MAP_GENERATION_LIMIT;
636
637
u32 vi = vm->m_area .index (x, node_max.Y , z);
637
638
638
639
// Check node at base of mapchunk above, either a node of a previously
@@ -650,22 +651,20 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
650
651
651
652
for (s16 y = node_max.Y ; y >= node_min.Y ; y--) {
652
653
content_t c = vm->m_data [vi].getContent ();
653
-
654
- // Biome is recalculated each time an upper surface is detected while
655
- // working down a column. The selected biome then remains in effect for
656
- // all nodes below until the next surface and biome recalculation.
657
- // Biome is recalculated:
654
+ // Biome is (re)calculated:
658
655
// 1. At the surface of stone below air or water.
659
656
// 2. At the surface of water below air.
660
657
// 3. When stone or water is detected but biome has not yet been calculated.
658
+ // 4. When stone or water is detected just below a biome's lower limit.
661
659
bool is_stone_surface = (c == c_stone) &&
662
- (air_above || water_above || !biome);
660
+ (air_above || water_above || !biome || y < biome_y_min); // 1, 3, 4
663
661
664
662
bool is_water_surface =
665
663
(c == c_water_source || c == c_river_water_source) &&
666
- (air_above || !biome);
664
+ (air_above || !biome || y < biome_y_min); // 2, 3, 4
667
665
668
666
if (is_stone_surface || is_water_surface) {
667
+ // (Re)calculate biome
669
668
// Limit to +-MAX MAP GENERATION LIMIT to work with biome y_min / y_max.
670
669
s32 relative_y = rangelim (y - biome_zero_level,
671
670
-MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
@@ -677,9 +676,11 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
677
676
depth_top = biome->depth_top ;
678
677
base_filler = MYMAX (depth_top +
679
678
biome->depth_filler +
680
- noise_filler_depth->result [index ], 0 .f );
679
+ noise_filler_depth->result [index ], 0 .0f );
681
680
depth_water_top = biome->depth_water_top ;
682
681
depth_riverbed = biome->depth_riverbed ;
682
+ biome_y_min = rangelim (biome->y_min + biome_zero_level,
683
+ -MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
683
684
684
685
// Detect stone type for dungeons during every biome calculation.
685
686
// If none detected the last selected biome stone is chosen.
0 commit comments