1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Unify low/high parameters using kMaximumLandHeight

This commit is contained in:
Aaron van Geffen
2024-09-10 14:34:46 +02:00
parent b434e1bc35
commit e2d05642ae
2 changed files with 9 additions and 8 deletions

View File

@@ -330,8 +330,8 @@ namespace OpenRCT2::Ui::Windows
.smooth_strength = 1,
.normalize_height = false,
.smoothTileEdges = true,
.heightmapLow = 2,
.heightmapHigh = 70,
.heightmapLow = 1,
.heightmapHigh = 35,
};
bool _randomTerrain = true;
@@ -735,7 +735,7 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex)
{
case WIDX_SIMPLEX_LOW_UP:
_settings.simplex_low = std::min(_settings.simplex_low + 1, 24);
_settings.simplex_low = std::min(_settings.simplex_low + 1, kMaximumLandHeight / 2 - 1);
Invalidate();
break;
case WIDX_SIMPLEX_LOW_DOWN:
@@ -743,7 +743,7 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_SIMPLEX_HIGH_UP:
_settings.simplex_high = std::min(_settings.simplex_high + 1, 36);
_settings.simplex_high = std::min(_settings.simplex_high + 1, kMaximumLandHeight / 2);
Invalidate();
break;
case WIDX_SIMPLEX_HIGH_DOWN:
@@ -849,7 +849,7 @@ namespace OpenRCT2::Ui::Windows
InvalidateWidget(WIDX_HEIGHTMAP_STRENGTH);
break;
case WIDX_HEIGHTMAP_LOW_UP:
_settings.heightmapLow = std::min(_settings.heightmapLow + 1, kMaximumWaterHeight - 1);
_settings.heightmapLow = std::min(_settings.heightmapLow + 1, kMaximumLandHeight / 2 - 1);
_settings.heightmapHigh = std::max(_settings.heightmapHigh, _settings.heightmapLow + 1);
InvalidateWidget(WIDX_HEIGHTMAP_LOW);
break;
@@ -858,7 +858,7 @@ namespace OpenRCT2::Ui::Windows
InvalidateWidget(WIDX_HEIGHTMAP_LOW);
break;
case WIDX_HEIGHTMAP_HIGH_UP:
_settings.heightmapHigh = std::min<int32_t>(_settings.heightmapHigh + 1, kMaximumWaterHeight);
_settings.heightmapHigh = std::min<int32_t>(_settings.heightmapHigh + 1, kMaximumLandHeight - 1);
InvalidateWidget(WIDX_HEIGHTMAP_HIGH);
break;
case WIDX_HEIGHTMAP_HIGH_DOWN:

View File

@@ -879,7 +879,7 @@ static void MapGenGenerateFromHeightmapImage(MapGenSettings* settings)
Guard::Assert(settings->heightmapHigh > settings->heightmapLow, "Output range is invalid");
const uint8_t rangeIn = maxValue - minValue;
const uint8_t rangeOut = settings->heightmapHigh - settings->heightmapLow;
const uint8_t rangeOut = (settings->heightmapHigh - settings->heightmapLow) * 2;
for (uint32_t y = 0; y < _heightMapData.height; y++)
{
@@ -893,7 +893,8 @@ static void MapGenGenerateFromHeightmapImage(MapGenSettings* settings)
// Read value from bitmap, and convert its range
uint8_t value = dest[x + y * _heightMapData.width];
value = static_cast<uint8_t>(static_cast<float>(value - minValue) / rangeIn * rangeOut) + settings->heightmapLow;
value = static_cast<uint8_t>(static_cast<float>(value - minValue) / rangeIn * rangeOut)
+ (settings->heightmapLow * 2);
surfaceElement->BaseHeight = value;
// Floor to even number