OpenTTD Source 20260108-master-g8ba1860eaa
tgp.cpp File Reference

OTTD Perlin Noise Landscape Generator, aka TerraGenesis Perlin. More...

#include "stdafx.h"
#include "clear_map.h"
#include "void_map.h"
#include "genworld.h"
#include "core/random_func.hpp"
#include "landscape_type.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  HeightMap
 Height map - allocated array of heights (Map::SizeX() + 1) * (Map::SizeY() + 1) More...
 

Macros

#define F(fraction)   ((Height)(fraction * mh))
 

Typedefs

using Height = int16_t
 Fixed point type for heights.
 
using Amplitude = int
 Fixed point array for amplitudes.
 

Functions

static Height I2H (int i)
 Conversion: int to Height.
 
static int H2I (Height i)
 Conversion: Height to int.
 
static Height A2H (Amplitude i)
 Conversion: Amplitude to Height.
 
static Height TGPGetMaxHeight ()
 Gets the maximum allowed height while generating a map based on mapsize, terraintype, and the maximum height level.
 
uint GetEstimationTGPMapHeight ()
 Get an overestimation of the highest peak TGP wants to generate.
 
static Amplitude GetAmplitude (int frequency)
 Get the amplitude associated with the currently selected smoothness and maximum height level.
 
static bool IsValidXY (int x, int y)
 Check if a X/Y set are within the map.
 
static void AllocHeightMap ()
 Allocate array of (Map::SizeX() + 1) * (Map::SizeY() + 1) heights and init the _height_map structure members.
 
static void FreeHeightMap ()
 Free height map.
 
static Height RandomHeight (Amplitude r_max)
 Generates new random height in given amplitude (generated numbers will range from - amplitude to + amplitude)
 
static void HeightMapGenerate ()
 Base Perlin noise generator - fills height map with raw Perlin noise.
 
static void HeightMapGetMinMaxAvg (Height *min_ptr, Height *max_ptr, Height *avg_ptr)
 Returns min, max and average height from height map.
 
static int * HeightMapMakeHistogram (Height h_min, Height h_max, int *hist_buf)
 Dill histogram and return pointer to its base point - to the count of zero heights.
 
static void HeightMapSineTransform (Height h_min, Height h_max)
 Applies sine wave redistribution onto height map.
 
static void HeightMapCurves (uint level)
 Additional map variety is provided by applying different curve maps to different parts of the map.
 
static void HeightMapAdjustWaterLevel (int64_t water_percent, Height h_max_new)
 Adjusts heights in height map to contain required amount of water tiles.
 
static double perlin_coast_noise_2D (const double x, const double y, const double p, const int prime)
 This is a similar function to the main perlin noise calculation, but uses the value p passed as a parameter rather than selected from the predefined sequences.
 
static void HeightMapCoastLines (BorderFlags water_borders)
 This routine sculpts in from the edge a random amount, again a Perlin sequence, to avoid the rigid flat-edge slopes that were present before.
 
static void HeightMapSmoothCoastInDirection (int org_x, int org_y, int dir_x, int dir_y)
 Start at given point, move in given direction, find and Smooth coast in that direction.
 
static void HeightMapSmoothCoasts (BorderFlags water_borders)
 Smooth coasts by modulating height of tiles close to map edges with cosine of distance from edge.
 
static void HeightMapSmoothSlopes (Height dh_max)
 This routine provides the essential cleanup necessary before OTTD can display the terrain.
 
static void HeightMapNormalize ()
 Height map terraform post processing:
 
static double int_noise (const long x, const long y, const int prime)
 The Perlin Noise calculation using large primes The initial number is adjusted by two values; the generation_seed, and the passed parameter; prime.
 
static double linear_interpolate (const double a, const double b, const double x)
 This routine determines the interpolated value between a and b.
 
static double interpolated_noise (const double x, const double y, const int prime)
 This routine returns the smoothed interpolated noise for an x and y, using the values from the surrounding positions.
 
static void TgenSetTileHeight (TileIndex tile, int height)
 A small helper function to initialize the terrain.
 
void GenerateTerrainPerlin ()
 The main new land generator using Perlin noise.
 

Variables

static const int HEIGHT_DECIMAL_BITS = 4
 
static const int AMPLITUDE_DECIMAL_BITS = 10
 
static HeightMap _height_map = { {}, 0, 0, 0 }
 Global height map instance.
 
static const int MAX_TGP_FREQUENCIES = 10
 Maximum number of TGP noise frequencies.
 
static constexpr int WATER_PERCENT_FACTOR = 1024
 
static const int64_t _water_percent [4] = {70, 170, 270, 420}
 Desired water percentage (100% == 1024) - indexed by _settings_game.difficulty.quantity_sea_lakes.
 

Detailed Description

OTTD Perlin Noise Landscape Generator, aka TerraGenesis Perlin.

Quickie guide to Perlin Noise Perlin noise is a predictable pseudo random number sequence. By generating it in 2 dimensions, it becomes a useful random map that, for a given seed and starting X & Y, is entirely predictable. On the face of it, that may not be useful. However, it means that if you want to replay a map in a different terrain, or just vary the sea level, you just re-run the generator with the same seed. The seed is an int32_t, and is randomised on each run of New Game. The Scenario Generator does not randomise the value, so that you can experiment with one terrain until you are happy, or click "Random" for a new random seed.

Perlin Noise is a series of "octaves" of random noise added together. By reducing the amplitude of the noise with each octave, the first octave of noise defines the main terrain sweep, the next the ripples on that, and the next the ripples on that. I use 6 octaves, with the amplitude controlled by a power ratio, usually known as a persistence or p value. This I vary by the smoothness selection, as can be seen in the table below. The closer to 1, the more of that octave is added. Each octave is however raised to the power of its position in the list, so the last entry in the "smooth" row, 0.35, is raised to the power of 6, so can only add 0.001838... of the amplitude to the running total.

In other words; the first p value sets the general shape of the terrain, the second sets the major variations to that, ... until finally the smallest bumps are added.

Usefully, this routine is totally scalable; so when 32bpp comes along, the terrain can be as bumpy as you like! It is also infinitely expandable; a single random seed terrain continues in X & Y as far as you care to calculate. In theory, we could use just one seed value, but randomly select where in the Perlin XY space we use for the terrain. Personally I prefer using a simple (0, 0) to (X, Y), with a varying seed.

Other things i have had to do: mountainous wasn't mountainous enough, and since we only have 0..15 heights available, I add a second generated map (with a modified seed), onto the original. This generally raises the terrain, which then needs scaling back down. Overall effect is a general uplift.

However, the values on the top of mountains are then almost guaranteed to go too high, so large flat plateaus appeared at height 15. To counter this, I scale all heights above 12 to proportion up to 15. It still makes the mountains have flattish tops, rather than craggy peaks, but at least they aren't smooth as glass.

For a full discussion of Perlin Noise, please visit: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Evolution II

The algorithm as described in the above link suggests to compute each tile height as composition of several noise waves. Some of them are computed directly by noise(x, y) function, some are calculated using linear approximation. Our first implementation of perlin_noise_2D() used 4 noise(x, y) calls plus 3 linear interpolations. It was called 6 times for each tile. This was a bit CPU expensive.

The following implementation uses optimized algorithm that should produce the same quality result with much less computations, but more memory accesses. The overall speedup should be 300% to 800% depending on CPU and memory speed.

I will try to explain it on the example below:

Have a map of 4x4 tiles, our simplified noise generator produces only two values -1 and +1, use 3 octaves with wave length 1, 2 and 4, with amplitudes 3, 2, 1. Original algorithm produces:

h00 = lerp(lerp(-3, 3, 0/4), lerp(3, -3, 0/4), 0/4) + lerp(lerp(-2, 2, 0/2), lerp( 2, -2, 0/2), 0/2) + -1 = lerp(-3.0, 3.0, 0/4) + lerp(-2, 2, 0/2) + -1 = -3.0 + -2 + -1 = -6.0 h01 = lerp(lerp(-3, 3, 1/4), lerp(3, -3, 1/4), 0/4) + lerp(lerp(-2, 2, 1/2), lerp( 2, -2, 1/2), 0/2) + 1 = lerp(-1.5, 1.5, 0/4) + lerp( 0, 0, 0/2) + 1 = -1.5 + 0 + 1 = -0.5 h02 = lerp(lerp(-3, 3, 2/4), lerp(3, -3, 2/4), 0/4) + lerp(lerp( 2, -2, 0/2), lerp(-2, 2, 0/2), 0/2) + -1 = lerp( 0, 0, 0/4) + lerp( 2, -2, 0/2) + -1 = 0 + 2 + -1 = 1.0 h03 = lerp(lerp(-3, 3, 3/4), lerp(3, -3, 3/4), 0/4) + lerp(lerp( 2, -2, 1/2), lerp(-2, 2, 1/2), 0/2) + 1 = lerp( 1.5, -1.5, 0/4) + lerp( 0, 0, 0/2) + 1 = 1.5 + 0 + 1 = 2.5

h10 = lerp(lerp(-3, 3, 0/4), lerp(3, -3, 0/4), 1/4) + lerp(lerp(-2, 2, 0/2), lerp( 2, -2, 0/2), 1/2) + 1 = lerp(-3.0, 3.0, 1/4) + lerp(-2, 2, 1/2) + 1 = -1.5 + 0 + 1 = -0.5 h11 = lerp(lerp(-3, 3, 1/4), lerp(3, -3, 1/4), 1/4) + lerp(lerp(-2, 2, 1/2), lerp( 2, -2, 1/2), 1/2) + -1 = lerp(-1.5, 1.5, 1/4) + lerp( 0, 0, 1/2) + -1 = -0.75 + 0 + -1 = -1.75 h12 = lerp(lerp(-3, 3, 2/4), lerp(3, -3, 2/4), 1/4) + lerp(lerp( 2, -2, 0/2), lerp(-2, 2, 0/2), 1/2) + 1 = lerp( 0, 0, 1/4) + lerp( 2, -2, 1/2) + 1 = 0 + 0 + 1 = 1.0 h13 = lerp(lerp(-3, 3, 3/4), lerp(3, -3, 3/4), 1/4) + lerp(lerp( 2, -2, 1/2), lerp(-2, 2, 1/2), 1/2) + -1 = lerp( 1.5, -1.5, 1/4) + lerp( 0, 0, 1/2) + -1 = 0.75 + 0 + -1 = -0.25

Optimization 1:

1) we need to allocate a bit more tiles: (size_x + 1) * (size_y + 1) = (5 * 5):

2) setup corner values using amplitude 3 { -3.0 X X X 3.0 } { X X X X X } { X X X X X } { X X X X X } { 3.0 X X X -3.0 }

3a) interpolate values in the middle { -3.0 X 0.0 X 3.0 } { X X X X X } { 0.0 X 0.0 X 0.0 } { X X X X X } { 3.0 X 0.0 X -3.0 }

3b) add patches with amplitude 2 to them { -5.0 X 2.0 X 1.0 } { X X X X X } { 2.0 X -2.0 X 2.0 } { X X X X X } { 1.0 X 2.0 X -5.0 }

4a) interpolate values in the middle { -5.0 -1.5 2.0 1.5 1.0 } { -1.5 -0.75 0.0 0.75 1.5 } { 2.0 0.0 -2.0 0.0 2.0 } { 1.5 0.75 0.0 -0.75 -1.5 } { 1.0 1.5 2.0 -1.5 -5.0 }

4b) add patches with amplitude 1 to them { -6.0 -0.5 1.0 2.5 0.0 } { -0.5 -1.75 1.0 -0.25 2.5 } { 1.0 1.0 -3.0 1.0 1.0 } { 2.5 -0.25 1.0 -1.75 -0.5 } { 0.0 2.5 1.0 -0.5 -6.0 }

Optimization 2:

As you can see above, each noise function was called just once. Therefore we don't need to use noise function that calculates the noise from x, y and some prime. The same quality result we can obtain using standard Random() function instead.

Definition in file tgp.cpp.

Typedef Documentation

◆ Amplitude

using Amplitude = int

Fixed point array for amplitudes.

Definition at line 156 of file tgp.cpp.

◆ Height

using Height = int16_t

Fixed point type for heights.

Definition at line 152 of file tgp.cpp.

Function Documentation

◆ A2H()

static Height A2H ( Amplitude  i)
static

Conversion: Amplitude to Height.

Definition at line 197 of file tgp.cpp.

Referenced by RandomHeight().

◆ AllocHeightMap()

static void AllocHeightMap ( )
inlinestatic

Allocate array of (Map::SizeX() + 1) * (Map::SizeY() + 1) heights and init the _height_map structure members.

Definition at line 325 of file tgp.cpp.

References _height_map, HeightMap::dim_x, HeightMap::h, HeightMap::size_x, HeightMap::size_y, Map::SizeX(), and Map::SizeY().

Referenced by GenerateTerrainPerlin().

◆ FreeHeightMap()

static void FreeHeightMap ( )
inlinestatic

Free height map.

Definition at line 339 of file tgp.cpp.

References _height_map, and HeightMap::h.

Referenced by GenerateTerrainPerlin().

◆ GenerateTerrainPerlin()

void GenerateTerrainPerlin ( )

The main new land generator using Perlin noise.

Desert landscape is handled different to all others to give a desert valley between two high mountains. Clearly if a low height terrain (flat/very flat) is chosen, then the tropic areas won't be high enough, and there will be very little tropic on the map. Thus Tropic works best on Hilly or Mountainous.

Definition at line 980 of file tgp.cpp.

References _height_map, _settings_game, AllocHeightMap(), Clamp(), GameSettings::construction, ConstructionSettings::freeform_edges, FreeHeightMap(), GenerateWorldSetAbortCallback(), GWP_LANDSCAPE, H2I(), HeightMap::height(), HeightMapGenerate(), HeightMapNormalize(), IncreaseGeneratingWorldProgress(), MakeVoid(), HeightMap::size_x, HeightMap::size_y, Map::SizeX(), Map::SizeY(), TgenSetTileHeight(), TGPGetMaxHeight(), and TileXY().

Referenced by GenerateLandscape().

◆ GetAmplitude()

static Amplitude GetAmplitude ( int  frequency)
static

Get the amplitude associated with the currently selected smoothness and maximum height level.

Parameters
frequencyThe frequency to get the amplitudes for
Returns
The amplitudes to apply to the map.

< Very smooth

< Smooth

< Rough

< Very rough

Definition at line 269 of file tgp.cpp.

References _settings_game, Clamp(), GameSettings::game_creation, I2H(), MAX_TGP_FREQUENCIES, GameCreationSettings::tgen_smoothness, and TGPGetMaxHeight().

Referenced by HeightMapGenerate().

◆ GetEstimationTGPMapHeight()

uint GetEstimationTGPMapHeight ( )

Get an overestimation of the highest peak TGP wants to generate.

Definition at line 258 of file tgp.cpp.

References H2I(), and TGPGetMaxHeight().

Referenced by GenerateWorld().

◆ H2I()

static int H2I ( Height  i)
static

Conversion: Height to int.

Definition at line 191 of file tgp.cpp.

Referenced by GenerateTerrainPerlin(), and GetEstimationTGPMapHeight().

◆ HeightMapAdjustWaterLevel()

static void HeightMapAdjustWaterLevel ( int64_t  water_percent,
Height  h_max_new 
)
static

Adjusts heights in height map to contain required amount of water tiles.

Definition at line 667 of file tgp.cpp.

References _height_map, HeightMap::h, HeightMapGetMinMaxAvg(), HeightMapMakeHistogram(), I2H(), HeightMap::size_x, and HeightMap::size_y.

Referenced by HeightMapNormalize().

◆ HeightMapCoastLines()

static void HeightMapCoastLines ( BorderFlags  water_borders)
static

This routine sculpts in from the edge a random amount, again a Perlin sequence, to avoid the rigid flat-edge slopes that were present before.

The Perlin noise map doesn't know where we are going to slice across, and so we often cut straight through high terrain. The smoothing routine makes it legal, gradually increasing up from the edge to the original terrain height. By cutting parts of this away, it gives a far more irregular edge to the map-edge. Sometimes it works beautifully with the existing sea & lakes, and creates a very realistic coastline. Other times the variation is less, and the map-edge shows its cliff-like roots.

This routine may be extended to randomly sculpt the height of the terrain near the edge. This will have the coast edge at low level (1-3), rising in smoothed steps inland to about 15 tiles in. This should make it look as though the map has been built for the map size, rather than a slice through a larger map.

Please note that all the small numbers; 53, 101, 167, etc. are small primes to help give the perlin noise a bit more of a random feel.

Definition at line 726 of file tgp.cpp.

References _height_map, _settings_game, abs(), GameSettings::game_creation, HeightMap::height(), GameCreationSettings::map_x, GameCreationSettings::map_y, NorthEast, NorthWest, perlin_coast_noise_2D(), HeightMap::size_x, HeightMap::size_y, SouthEast, SouthWest, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by HeightMapNormalize().

◆ HeightMapCurves()

static void HeightMapCurves ( uint  level)
static

Additional map variety is provided by applying different curve maps to different parts of the map.

A randomized low resolution grid contains which curve map to use on each part of the make. This filtered non-linearly to smooth out transitions between curves, so each tile could have between 100% of one map applied or 25% of four maps.

The curve maps define different land styles, i.e. lakes, low-lands, hills and mountain ranges, although these are dependent on the landscape style chosen as well.

The level parameter dictates the resolution of the grid. A low resolution grid will result in larger continuous areas of a land style, a higher resolution grid splits the style into smaller areas.

Parameters
levelRough indication of the size of the grid sections to style. Small level means large grid sections.

Basically scale height X to height Y. Everything in between is interpolated.

< The height to scale from.

< The height to scale to.

Definition at line 549 of file tgp.cpp.

References _height_map, Clamp(), HasBit(), HeightMap::height(), I2H(), RandomRange(), HeightMap::size_x, HeightMap::size_y, and TGPGetMaxHeight().

Referenced by HeightMapNormalize().

◆ HeightMapGenerate()

static void HeightMapGenerate ( )
static

Base Perlin noise generator - fills height map with raw Perlin noise.

This runs several iterations with increasing precision; the last iteration looks at areas of 1 by 1 tiles, the second to last at 2 by 2 tiles and the initial 2**MAX_TGP_FREQUENCIES by 2**MAX_TGP_FREQUENCIES tiles.

Definition at line 362 of file tgp.cpp.

References _height_map, GetAmplitude(), HeightMap::h, HeightMap::height(), Map::LogX(), Map::LogY(), MAX_TGP_FREQUENCIES, RandomHeight(), HeightMap::size_x, and HeightMap::size_y.

Referenced by GenerateTerrainPerlin().

◆ HeightMapGetMinMaxAvg()

static void HeightMapGetMinMaxAvg ( Height min_ptr,
Height max_ptr,
Height avg_ptr 
)
static

Returns min, max and average height from height map.

Definition at line 422 of file tgp.cpp.

References _height_map, HeightMap::h, HeightMap::height(), HeightMap::size_x, and HeightMap::size_y.

Referenced by HeightMapAdjustWaterLevel().

◆ HeightMapMakeHistogram()

static int * HeightMapMakeHistogram ( Height  h_min,
Height  h_max,
int *  hist_buf 
)
static

Dill histogram and return pointer to its base point - to the count of zero heights.

Definition at line 445 of file tgp.cpp.

References _height_map, and HeightMap::h.

Referenced by HeightMapAdjustWaterLevel().

◆ HeightMapNormalize()

◆ HeightMapSineTransform()

static void HeightMapSineTransform ( Height  h_min,
Height  h_max 
)
static

Applies sine wave redistribution onto height map.

Definition at line 459 of file tgp.cpp.

References _height_map, _settings_game, GameSettings::game_creation, HeightMap::h, I2H(), and GameCreationSettings::landscape.

Referenced by HeightMapNormalize().

◆ HeightMapSmoothCoastInDirection()

static void HeightMapSmoothCoastInDirection ( int  org_x,
int  org_y,
int  dir_x,
int  dir_y 
)
static

Start at given point, move in given direction, find and Smooth coast in that direction.

Definition at line 782 of file tgp.cpp.

References _height_map, HeightMap::height(), I2H(), and IsValidXY().

Referenced by HeightMapSmoothCoasts().

◆ HeightMapSmoothCoasts()

static void HeightMapSmoothCoasts ( BorderFlags  water_borders)
static

Smooth coasts by modulating height of tiles close to map edges with cosine of distance from edge.

Definition at line 819 of file tgp.cpp.

References _height_map, HeightMapSmoothCoastInDirection(), NorthEast, NorthWest, HeightMap::size_x, HeightMap::size_y, SouthEast, SouthWest, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by HeightMapNormalize().

◆ HeightMapSmoothSlopes()

static void HeightMapSmoothSlopes ( Height  dh_max)
static

This routine provides the essential cleanup necessary before OTTD can display the terrain.

When generated, the terrain heights can jump more than one level between tiles. This routine smooths out those differences so that the most it can change is one level. When OTTD can support cliffs, this routine may not be necessary.

Definition at line 841 of file tgp.cpp.

References _height_map, HeightMap::height(), HeightMap::size_x, and HeightMap::size_y.

Referenced by HeightMapNormalize().

◆ I2H()

static Height I2H ( int  i)
static

◆ int_noise()

static double int_noise ( const long  x,
const long  y,
const int  prime 
)
static

The Perlin Noise calculation using large primes The initial number is adjusted by two values; the generation_seed, and the passed parameter; prime.

prime is used to allow the perlin noise generator to create useful random numbers from slightly different series.

Definition at line 895 of file tgp.cpp.

References _settings_game, GameSettings::game_creation, and GameCreationSettings::generation_seed.

Referenced by interpolated_noise().

◆ interpolated_noise()

static double interpolated_noise ( const double  x,
const double  y,
const int  prime 
)
static

This routine returns the smoothed interpolated noise for an x and y, using the values from the surrounding positions.

Definition at line 919 of file tgp.cpp.

References int_noise(), and linear_interpolate().

Referenced by perlin_coast_noise_2D().

◆ IsValidXY()

static bool IsValidXY ( int  x,
int  y 
)
inlinestatic

Check if a X/Y set are within the map.

Parameters
xcoordinate x
ycoordinate y
Returns
true if within the map

Definition at line 316 of file tgp.cpp.

References _height_map, HeightMap::size_x, and HeightMap::size_y.

Referenced by HeightMapSmoothCoastInDirection().

◆ linear_interpolate()

static double linear_interpolate ( const double  a,
const double  b,
const double  x 
)
inlinestatic

This routine determines the interpolated value between a and b.

Definition at line 909 of file tgp.cpp.

Referenced by interpolated_noise().

◆ perlin_coast_noise_2D()

static double perlin_coast_noise_2D ( const double  x,
const double  y,
const double  p,
const int  prime 
)
static

This is a similar function to the main perlin noise calculation, but uses the value p passed as a parameter rather than selected from the predefined sequences.

as you can guess by its title, i use this to create the indented coastline, which is just another perlin sequence.

Definition at line 945 of file tgp.cpp.

References interpolated_noise().

Referenced by HeightMapCoastLines().

◆ RandomHeight()

static Height RandomHeight ( Amplitude  r_max)
inlinestatic

Generates new random height in given amplitude (generated numbers will range from - amplitude to + amplitude)

Parameters
r_maxLimit of result
Returns
generated height

Definition at line 349 of file tgp.cpp.

References A2H(), and RandomRange().

Referenced by HeightMapGenerate().

◆ TgenSetTileHeight()

static void TgenSetTileHeight ( TileIndex  tile,
int  height 
)
static

A small helper function to initialize the terrain.

Definition at line 963 of file tgp.cpp.

References CLEAR_GRASS, IsInnerTile(), MakeClear(), and SetTileHeight().

Referenced by GenerateTerrainPerlin().

◆ TGPGetMaxHeight()

static Height TGPGetMaxHeight ( )
static

Gets the maximum allowed height while generating a map based on mapsize, terraintype, and the maximum height level.

Returns
The maximum height for the map generation.
Note
Values should never be lower than 3 since the minimum snowline height is 2.

Desired maximum height - indexed by:

It is indexed by map size as well as terrain type since the map size limits the height of a usable mountain. For example, on a 64x64 map a 24 high single peak mountain (as if you raised land 24 times in the center of the map) will leave only a ring of about 10 tiles around the mountain to build on. On a 4096x4096 map, it won't cover any major part of the map.

< Very flat

< Flat

< Hilly

< Mountainous

< Alpinist

Definition at line 216 of file tgp.cpp.

References _settings_game, GameSettings::construction, GameCreationSettings::custom_terrain_type, CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY, GameSettings::difficulty, GameSettings::game_creation, I2H(), Map::LogX(), Map::LogY(), ConstructionSettings::map_height_limit, MAX_MAP_SIZE_BITS, MIN_MAP_SIZE_BITS, and DifficultySettings::terrain_type.

Referenced by GenerateTerrainPerlin(), GetAmplitude(), GetEstimationTGPMapHeight(), HeightMapCurves(), and HeightMapNormalize().

Variable Documentation

◆ _height_map

◆ _water_percent

const int64_t _water_percent[4] = {70, 170, 270, 420}
static

Desired water percentage (100% == 1024) - indexed by _settings_game.difficulty.quantity_sea_lakes.

Definition at line 208 of file tgp.cpp.

Referenced by HeightMapNormalize().

◆ AMPLITUDE_DECIMAL_BITS

const int AMPLITUDE_DECIMAL_BITS = 10
static

Definition at line 157 of file tgp.cpp.

◆ HEIGHT_DECIMAL_BITS

const int HEIGHT_DECIMAL_BITS = 4
static

Definition at line 153 of file tgp.cpp.

◆ MAX_TGP_FREQUENCIES

const int MAX_TGP_FREQUENCIES = 10
static

Maximum number of TGP noise frequencies.

Definition at line 203 of file tgp.cpp.

Referenced by GetAmplitude(), and HeightMapGenerate().

◆ WATER_PERCENT_FACTOR

constexpr int WATER_PERCENT_FACTOR = 1024
staticconstexpr

Definition at line 205 of file tgp.cpp.