TerrainGen coverage


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

layers/boulders/boulder_placer.h
Line Branch Exec Source
1 /// @file
2 /// @brief `BoulderPlacer`, a layer that lists the boulders it places.
3 #pragma once
4
5 #include "terraingen/layers/boulders/boulder.h"
6 #include "terraingen/layers/boulders/boulder_models.h"
7 #include "terraingen/layers/ground.h"
8 #include "terraingen/raster/grid.h"
9
10 #include <vector>
11
12 namespace terraingen {
13
14 /// Boulders, and those of them placed as their own 3D models.
15 struct BoulderFeatures {
16 std::vector<Boulder> boulders; ///< Every boulder, in the order placed.
17 std::vector<BoulderModel> models; ///< The boulders placed as their own 3D models.
18
19 /// Appends `other`'s boulders and models.
20 67 void Append(const BoulderFeatures& other) {
21
1/1
✓ Branch 5 taken 67 times.
67 boulders.insert(boulders.end(), other.boulders.begin(), other.boulders.end());
22
1/1
✓ Branch 5 taken 67 times.
67 models.insert(models.end(), other.models.begin(), other.models.end());
23 67 }
24 };
25
26 /// A layer that places boulders. Boulders are a pure function of position, so the layer lists
27 /// them on request rather than recording them while it is applied.
28 class BoulderPlacer {
29 public:
30 233 virtual ~BoulderPlacer() = default;
31
32 /// The boulders the layer places over `grid`, as its `Apply` there sees them, each read on
33 /// `ground` (null leaves the ground unknown, and models unplaced).
34 /// @param spacing The sample spacing in metres, raised to the grid's as `Apply` raises it.
35 virtual BoulderFeatures BouldersOver(const RasterGrid& grid, double spacing,
36 const Ground* ground) const = 0;
37 };
38
39 } // namespace terraingen
40