TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
9 / 9
100.0%
Branches:
7 / 12
58.3%
Functions:
3 / 3, 1 excl
100.0%

layers/craters/degradation/state.h
Line Branch Exec Source
1 /// @file
2 /// @brief A crater's shape measures and degradation state.
3 #pragma once
4
5 #include <functional>
6
7 namespace terraingen {
8
9 /// A crater's shape measures relative to its diameter.
10 struct CraterMorphometry {
11 11 double depthRatio = 0.0; ///< Rim-to-floor depth / diameter.
12 11 double rimHeightRatio = 0.0; ///< Rim height above the pre-impact surface / diameter.
13
14
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 bool operator==(const CraterMorphometry&) const = default;
15 };
16
17 /// A crater's degradation state: its morphometry when fresh and now.
18 struct CraterState {
19 2 CraterMorphometry fresh; ///< When fresh; some profiles place a degraded rim from it.
20 2 CraterMorphometry current; ///< Now; profiles shape the crater to it.
21 /// Diffusion age over diameter squared, kappa t / D^2, for profiles that diffuse the fresh
22 /// shape (`DiffusedProfile`); 0 for none.
23 2 double diffusion = 0.0;
24
25 /// How fresh the crater looks: its depth now over its depth when fresh; 1 for a fresh crater
26 /// (or one with no fresh depth), falling as it degrades.
27 309448 double Freshness() const {
28
2/2
✓ Branch 0 taken 309446 times.
✓ Branch 1 taken 2 times.
309448 return fresh.depthRatio > 0.0 ? current.depthRatio / fresh.depthRatio : 1.0;
29 }
30
31
3/6
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 bool operator==(const CraterState&) const = default;
32 };
33
34 /// The morphometry of a fresh crater of a diameter (m) on some body, such as
35 /// `LunarFreshCraterMorphometry`; must be thread-safe.
36 using FreshMorphometry = std::function<CraterMorphometry(double diameter)>;
37
38 } // namespace terraingen
39