mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Make density a HeightMap property
This commit is contained in:
@@ -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_)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }];
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user