./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
7 / 7
100.0%
Branches:
18 / 29
62.1%
Functions:
1 / 1, 2 excl
100.0%

include/terraingen/layers/boulders/boulder_placer.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief `BoulderPlacer`, a layer that lists the boulders it places.
5 #pragma once
6
7 #include "terraingen/layers/boulders/boulder.h"
8 #include "terraingen/layers/boulders/boulder_models.h"
9 #include "terraingen/layers/ground.h"
10 #include "terraingen/raster/grid.h"
11
12 #include <vector>
13
14 namespace terraingen {
15
16 /// Boulders, and those of them placed as their own 3D models.
17
17/28
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✓ Branch 5 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 14 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 time.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 19 taken 1 time.
✗ Branch 20 not taken.
✓ Branch 20 taken 1 time.
✓ Branch 21 taken 1 time.
✓ Branch 26 taken 1 time.
✗ Branch 28 not taken.
✓ Branch 29 taken 1 time.
✗ Branch 30 not taken.
✓ Branch 31 taken 1 time.
✗ Branch 34 not taken.
✓ Branch 35 taken 1 time.
209 struct BoulderFeatures {
18 BoulderList boulders; ///< Every boulder, in the order placed.
19 std::vector<BoulderModel> models; ///< The boulders placed as their own 3D models.
20
21 /// Appends `other`'s boulders and models.
22 57 void Append(const BoulderFeatures& other) {
23 57 boulders.Append(other.boulders);
24 57 models.insert(models.end(), other.models.begin(), other.models.end());
25 57 }
26 };
27
28 /// A layer that places boulders. Boulders are a pure function of position, so the layer lists
29 /// them on request rather than recording them while it is applied.
30
1/1
✓ Branch 1 taken 42 times.
402 class BoulderPlacer {
31 public:
32 virtual ~BoulderPlacer() = default;
33
34 /// The boulders the layer places over `grid`, each read on
35 /// `ground` (null leaves the ground unknown, and models unplaced).
36 /// @param spacing The sample spacing in meters models are marked at, finer than the grid's or
37 /// not (`ListedSpacing`); 0 for the grid's. Every boulder of the layer's diameter range is
38 /// listed, however small, since those too small for the heights stand as models or in lists.
39 virtual BoulderFeatures BouldersOver(const RasterGrid& grid, double spacing,
40 const Ground* ground) const = 0;
41 };
42
43 } // namespace terraingen
44