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 | 67 | boulders.insert(boulders.end(), other.boulders.begin(), other.boulders.end()); | |
| 22 | 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 |