Make density a HeightMap property

This commit is contained in:
Aaron van Geffen committed 2025-03-09 00:41:08 +01:00
1 parent 64aaaa57ee
commit 8d5c70cec5
4 files changed
+18 -8

No files matched your search

@@ -26,11 +26,21 @@ namespace OpenRCT2::World::MapGenerator
public:
uint16_t width{};
uint16_t height{};
uint8_t density{};
HeightMap(int32_t targetWidth, int32_t targetHeight)
: _height(targetWidth * targetHeight)
, width(targetWidth)
, height(targetHeight)
, density(1)
{
}
HeightMap(int32_t baseWidth, int32_t baseHeight, uint8_t density_)
: _height((baseWidth * density_) * (baseHeight * density_))
, width(baseWidth * density_)
, height(baseHeight * density_)
, density(density_)
{
}
+5 -5
View File
@@ -126,14 +126,14 @@ namespace OpenRCT2::World::MapGenerator
/**
* Sets the height of the actual game map tiles to the height map.
*/
void setMapHeight(Settings* settings, const HeightMap& heightMap, const uint8_t density)
void setMapHeight(Settings* settings, const HeightMap& heightMap)
{
for (auto y = 1; y < heightMap.height / density - 1; y++)
for (auto y = 1; y < heightMap.height / heightMap.density - 1; y++)
{
for (auto x = 1; x < heightMap.width / density - 1; x++)
for (auto x = 1; x < heightMap.width / heightMap.density - 1; x++)
{
auto heightX = x * density;
auto heightY = y * density;
auto heightX = x * heightMap.density;
auto heightY = y * heightMap.density;
uint8_t q00 = heightMap[{ heightX + 0, heightY + 0 }];
uint8_t q01 = heightMap[{ heightX + 0, heightY + 1 }];
+1 -1
View File
@@ -54,6 +54,6 @@ namespace OpenRCT2::World::MapGenerator
void generate(Settings* settings);
void resetSurfaces(Settings* settings);
void setWaterLevel(int32_t waterLevel);
void setMapHeight(Settings* settings, const HeightMap& heightMap, const uint8_t density);
void setMapHeight(Settings* settings, const HeightMap& heightMap);
} // namespace OpenRCT2::World::MapGenerator
@@ -206,13 +206,13 @@ namespace OpenRCT2::World::MapGenerator
// Create the temporary height map and initialise
const auto& mapSize = settings->mapSize;
const auto density = 2;
auto heightMap = HeightMap(mapSize.x * density, mapSize.y * density);
auto heightMap = HeightMap(mapSize.x, mapSize.y, density);
generateSimplexNoise(settings, heightMap);
smoothHeightMap(2 + (UtilRand() % 6), heightMap);
// Set the game map to the height map
setMapHeight(settings, heightMap, density);
setMapHeight(settings, heightMap);
if (settings->smoothTileEdges)
{