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 | 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 | 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 |