@@ -44,10 +44,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
44
44
#include < cmath>
45
45
46
46
47
- static FlagDesc flagdesc_mapgen_valleys[] = {
48
- {" altitude_chill" , MGVALLEYS_ALT_CHILL},
49
- {" humid_rivers" , MGVALLEYS_HUMID_RIVERS},
50
- {NULL , 0 }
47
+ FlagDesc flagdesc_mapgen_valleys[] = {
48
+ {" altitude_chill" , MGVALLEYS_ALT_CHILL},
49
+ {" humid_rivers" , MGVALLEYS_HUMID_RIVERS},
50
+ {" vary_river_depth" , MGVALLEYS_VARY_RIVER_DEPTH},
51
+ {" altitude_dry" , MGVALLEYS_ALT_DRY},
52
+ {NULL , 0 }
51
53
};
52
54
53
55
@@ -94,8 +96,6 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenValleysParams *params,
94
96
MapgenBasic::np_cave2 = params->np_cave2 ;
95
97
MapgenBasic::np_cavern = params->np_cavern ;
96
98
97
- humid_rivers = (spflags & MGVALLEYS_HUMID_RIVERS);
98
- use_altitude_chill = (spflags & MGVALLEYS_ALT_CHILL);
99
99
humidity_adjust = bp->np_humidity .offset - 50 .0f ;
100
100
}
101
101
@@ -298,10 +298,10 @@ void MapgenValleys::calculateNoise()
298
298
float heat_offset = 0 .0f ;
299
299
float humidity_scale = 1 .0f ;
300
300
// Altitude chill tends to reduce the average heat.
301
- if (use_altitude_chill )
301
+ if (spflags & MGVALLEYS_ALT_CHILL )
302
302
heat_offset = 5 .0f ;
303
303
// River humidity tends to increase the humidity range.
304
- if (humid_rivers )
304
+ if (spflags & MGVALLEYS_HUMID_RIVERS )
305
305
humidity_scale = 0 .8f ;
306
306
307
307
for (s32 index = 0 ; index < csize.X * csize.Z ; index ++) {
@@ -477,17 +477,16 @@ int MapgenValleys::generateTerrain()
477
477
if (surface_y > surface_max_y)
478
478
surface_max_y = std::ceil (surface_y);
479
479
480
- if (humid_rivers) {
481
- // Derive heat from (base) altitude. This will be most correct
482
- // at rivers, since other surface heights may vary below.
483
- if (use_altitude_chill && (surface_y > 0 .0f || river_y > 0 .0f ))
484
- t_heat -= alt_to_heat *
485
- std::fmax (surface_y, river_y) / altitude_chill;
486
-
487
- // If humidity is low or heat is high, lower the water table
480
+ // Optionally vary river depth according to heat and humidity
481
+ if (spflags & MGVALLEYS_VARY_RIVER_DEPTH) {
482
+ float heat = ((spflags & MGVALLEYS_ALT_CHILL) &&
483
+ (surface_y > 0 .0f || river_y > 0 .0f )) ?
484
+ t_heat - alt_to_heat *
485
+ std::fmax (surface_y, river_y) / altitude_chill :
486
+ t_heat;
488
487
float delta = m_bgen->humidmap [index_2d] - 50 .0f ;
489
488
if (delta < 0 .0f ) {
490
- float t_evap = (t_heat - 32 .0f ) / evaporation;
489
+ float t_evap = (heat - 32 .0f ) / evaporation;
491
490
river_y += delta * std::fmax (t_evap, 0 .08f );
492
491
}
493
492
}
@@ -534,33 +533,32 @@ int MapgenValleys::generateTerrain()
534
533
}
535
534
}
536
535
537
- if (humid_rivers) {
538
- // Use base ground (water table) in a riverbed, to avoid an
539
- // unnatural rise in humidity.
536
+ // Optionally increase humidity around rivers
537
+ if (spflags & MGVALLEYS_HUMID_RIVERS) {
538
+ // Ground height ignoring riverbeds
540
539
float t_alt = std::fmax (noise_rivers->result [index_2d],
541
540
(float )heightmap[index_2d]);
542
- float humid = m_bgen->humidmap [index_2d];
543
541
float water_depth = (t_alt - river_y) / humidity_dropoff;
544
- humid *= 1 .0f + std::pow (0 .5f , std::fmax (water_depth, 1 .0f ));
542
+ m_bgen->humidmap [index_2d] *=
543
+ 1 .0f + std::pow (0 .5f , std::fmax (water_depth, 1 .0f ));
544
+ }
545
545
546
- // Reduce humidity with altitude (ignoring riverbeds)
546
+ // Optionally decrease humidity with altitude
547
+ if (spflags & MGVALLEYS_ALT_DRY) {
548
+ // Ground height ignoring riverbeds
549
+ float t_alt = std::fmax (noise_rivers->result [index_2d],
550
+ (float )heightmap[index_2d]);
547
551
if (t_alt > 0 .0f )
548
- humid -= alt_to_humid * t_alt / altitude_chill;
549
-
550
- m_bgen->humidmap [index_2d] = humid;
552
+ m_bgen->humidmap [index_2d] -=
553
+ alt_to_humid * t_alt / altitude_chill;
551
554
}
552
555
553
- // Assign the heat adjusted by any changed altitudes.
554
- // The altitude will change about half the time.
555
- if (use_altitude_chill) {
556
+ // Optionally decrease heat with altitude
557
+ if (spflags & MGVALLEYS_ALT_CHILL) {
556
558
// Ground height ignoring riverbeds
557
559
float t_alt = std::fmax (noise_rivers->result [index_2d],
558
560
(float )heightmap[index_2d]);
559
-
560
- if (humid_rivers && heightmap[index_2d] == (s16)myround (surface_y))
561
- // The altitude hasn't changed. Use the first result
562
- m_bgen->heatmap [index_2d] = t_heat;
563
- else if (t_alt > 0 .0f )
561
+ if (t_alt > 0 .0f )
564
562
m_bgen->heatmap [index_2d] -=
565
563
alt_to_heat * t_alt / altitude_chill;
566
564
}
0 commit comments