TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
2 / 2
100.0%
Branches:
2 / 2
100.0%
Functions:
1 / 1, 1 excl
100.0%

sources/synthetic_terrain.h
Line Branch Exec Source
1 /// @file
2 /// @brief Fully synthetic terrains made from stacks of noise layers.
3 #pragma once
4
5 #include "terraingen/noise/fractal.h"
6 #include "terraingen/noise/noise_layers.h"
7 #include "terraingen/noise/validate.h"
8 #include "terraingen/raster/raster.h"
9
10 #include <cstddef>
11 #include <vector>
12
13 namespace terraingen {
14
15 /// A synthetic terrain: a stack of noise layers evaluated with `EvaluateNoiseLayers`.
16 struct SyntheticTerrainParams {
17 3 std::vector<NoiseLayer> layers{NoiseLayer{}}; ///< 1 to `kMaxNoiseLayers`; one Perlin fBm.
18
19
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 2 times.
3 bool operator==(const SyntheticTerrainParams&) const = default;
20 };
21
22 /// Checks the layer count and every layer (`ValidateNoiseLayer`).
23 /// @throws std::invalid_argument naming the first problem.
24 void ValidateSyntheticTerrain(const SyntheticTerrainParams& params);
25
26 /// Sets every cell of `raster` to the synthetic height in metres at its centre, placed by its
27 /// `GeoTransform`, so tiles of a larger grid on the same lattice match it.
28 /// @throws std::invalid_argument as `ValidateSyntheticTerrain`.
29 void FillSyntheticTerrain(Raster<float>& raster, const SyntheticTerrainParams& params);
30
31 /// Generates the heights in metres of a north-up synthetic terrain centred on the world origin.
32 /// @param width Columns, at least 1.
33 /// @param height Rows, at least 1.
34 /// @param pixelSize Cell size in world units (metres), positive and finite.
35 /// @throws std::invalid_argument if `width` or `height` is zero, `pixelSize` is not positive and
36 /// finite, or `params` are invalid.
37 Raster<float> GenerateSyntheticTerrain(std::size_t width, std::size_t height, double pixelSize,
38 const SyntheticTerrainParams& params);
39
40 } // namespace terraingen
41