MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / generate

Method generate

src/OpenLoco/src/Map/MapGenerator/SimplexTerrainGenerator.cpp:8–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace OpenLoco::World::MapGenerator
7{
8 void SimplexTerrainGenerator::generate(const Scenario::Options& options, HeightMapRange heightMap, uint32_t seed)
9 {
10 initialiseRng(seed);
11
12 auto hillDensity = std::clamp<uint8_t>(options.hillDensity, 0, 100) / 100.0f;
13 auto smoothingPasses = std::clamp<uint8_t>(options.numTerrainSmoothingPasses, 1, 5);
14
15 SimplexSettings settings;
16 settings.low = options.minLandHeight;
17 settings.smooth = smoothingPasses;
18
19 switch (options.topographyStyle)
20 {
21 case Scenario::TopographyStyle::flatLand:
22 settings.high = options.minLandHeight + 8;
23 settings.baseFreq = 4.0f * hillDensity;
24 settings.octaves = 5;
25 generate(settings, heightMap);
26 break;
27 case Scenario::TopographyStyle::smallHills:
28 settings.high = options.minLandHeight + 14;
29 settings.baseFreq = 6.0f * hillDensity;
30 settings.octaves = 6;
31 generate(settings, heightMap);
32 break;
33 case Scenario::TopographyStyle::mountains:
34 settings.high = 32;
35 settings.baseFreq = 4.0f * hillDensity;
36 settings.octaves = 6;
37 generate(settings, heightMap);
38 break;
39 case Scenario::TopographyStyle::halfMountainsHills:
40 settings.high = 32;
41 settings.baseFreq = 8.0f * hillDensity;
42 settings.octaves = 6;
43 generate(settings, heightMap);
44 break;
45 case Scenario::TopographyStyle::halfMountainsFlat:
46 settings.high = 32;
47 settings.baseFreq = 6.0f * hillDensity;
48 settings.octaves = 5;
49 generate(settings, heightMap);
50 break;
51 }
52 }
53
54 void SimplexTerrainGenerator::initialiseRng(uint32_t seed)
55 {

Callers

nothing calls this directly

Calls 2

generateFunction · 0.85
setProgressFunction · 0.50

Tested by

no test coverage detected