./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
11 / 11
100.0%
Branches:
6 / 6
100.0%
Functions:
2 / 2
100.0%

src/layers/craters/shaping/attributes.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 #include "terraingen/layers/craters/shaping/attributes.h"
4
5 #include "layers/craters/shaping/resolved_state.h"
6 #include "terraingen/layers/craters/shaping/apply.h"
7
8 #include <cmath>
9 #include <limits>
10
11 namespace terraingen {
12
13 34361 CraterAttributes ComputeCraterAttributes(const Crater& crater, const CraterState& state,
14 const CraterProfile& profile) {
15 34361 const double diameter = crater.diameter;
16 34361 double rim = -std::numeric_limits<double>::infinity();
17
2/2
✓ Branch 0 taken 2096021 times.
✓ Branch 1 taken 34361 times.
2130382 for (int step = 70; step <= 130; ++step) {
18 2096021 const double radii = 0.01 * static_cast<double>(step);
19 2096021 rim = std::fmax(rim, profile.Height(0.5 * radii * diameter, diameter, state));
20 }
21 double floor = std::numeric_limits<double>::infinity();
22
2/2
✓ Branch 0 taken 3470461 times.
✓ Branch 1 taken 34361 times.
3504822 for (int step = 0; step <= 100; ++step) {
23 3470461 floor = std::fmin(floor, profile.Height(0.005 * step * diameter, diameter, state));
24 }
25
2/2
✓ Branch 0 taken 34360 times.
✓ Branch 1 taken 1 time.
68721 return {-floor, rim, state.current.depthRatio, state.Freshness(), profile.IsComplex(diameter)};
26 }
27
28 34318 CraterAttributes CraterShapeModels::Attributes(const Crater& crater) const {
29 34318 return ComputeCraterAttributes(crater, ResolvedCraterState(*this, crater), *profile);
30 }
31
32 } // namespace terraingen
33