config/config.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "terraingen/config/config.h" | ||
| 2 | |||
| 3 | namespace terraingen { | ||
| 4 | |||
| 5 | namespace { | ||
| 6 | |||
| 7 | /// Each layer of `stack` with its Hurst exponent applied, appended to `layers`. | ||
| 8 | template <typename Layers> | ||
| 9 | 423 | void AppendEffective(const std::vector<NoiseLayerConfig>& stack, Layers& layers) { | |
| 10 | 651 | for (const NoiseLayerConfig& layer : stack) { | |
| 11 | 228 | layers.push_back(layer.Effective()); | |
| 12 | } | ||
| 13 | 423 | } | |
| 14 | |||
| 15 | } // namespace | ||
| 16 | |||
| 17 | 556 | NoiseLayer NoiseLayerConfig::Effective() const { | |
| 18 | 556 | NoiseLayer effective = layer; | |
| 19 | 556 | if (hurst) { | |
| 20 | 9 | effective.fractal.gain = GainFromHurst(*hurst, layer.fractal.lacunarity); | |
| 21 | } | ||
| 22 | 556 | return effective; | |
| 23 | } | ||
| 24 | |||
| 25 | 156 | SyntheticTerrainParams NoiseLayerSpec::Params() const { | |
| 26 | 156 | SyntheticTerrainParams params; | |
| 27 | 156 | params.layers.clear(); | |
| 28 | 156 | AppendEffective(stack, params.layers); | |
| 29 | 156 | return params; | |
| 30 | } | ||
| 31 | |||
| 32 | 89 | SyntheticAlbedoParams SyntheticAlbedoSpec::Params() const { | |
| 33 | 89 | SyntheticAlbedoParams params; | |
| 34 | 89 | params.rgb = rgb; | |
| 35 | 89 | params.hue = hue; | |
| 36 | 89 | params.saturation = saturation; | |
| 37 | 89 | params.value = value; | |
| 38 | 89 | AppendEffective(hueNoise, params.hueNoise); | |
| 39 | 89 | AppendEffective(saturationNoise, params.saturationNoise); | |
| 40 | 89 | AppendEffective(valueNoise, params.valueNoise); | |
| 41 | 89 | return params; | |
| 42 | } | ||
| 43 | |||
| 44 | } // namespace terraingen | ||
| 45 |