layers/craters/crater_placer.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /// @file | ||
| 2 | /// @brief `CraterPlacer`, a layer that lists the craters it applies, and `PlacedCraters`. | ||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include "terraingen/layers/craters/crater.h" | ||
| 6 | #include "terraingen/layers/craters/shaping/attributes.h" | ||
| 7 | #include "terraingen/layers/layer.h" | ||
| 8 | #include "terraingen/raster/grid.h" | ||
| 9 | |||
| 10 | #include <memory> | ||
| 11 | #include <span> | ||
| 12 | #include <vector> | ||
| 13 | |||
| 14 | namespace terraingen { | ||
| 15 | |||
| 16 | /// Craters and their attributes, in step. | ||
| 17 | struct CraterFeatures { | ||
| 18 | CraterList craters; ///< The craters, in the order applied. | ||
| 19 | std::vector<CraterAttributes> attributes; ///< Each crater's attributes, in step. | ||
| 20 | |||
| 21 | /// Appends `other`'s craters and attributes. | ||
| 22 | void Append(const CraterFeatures& other); | ||
| 23 | }; | ||
| 24 | |||
| 25 | /// A layer that places craters. Craters are a pure function of position, so the layer lists them | ||
| 26 | /// on request rather than recording them while it is applied. | ||
| 27 | class CraterPlacer { | ||
| 28 | public: | ||
| 29 | 746 | virtual ~CraterPlacer() = default; | |
| 30 | |||
| 31 | /// The craters the layer applies over `grid`, as its `Apply` there sees them. | ||
| 32 | /// @param spacing The sample spacing in metres, raised to the grid's as `Apply` raises it. | ||
| 33 | virtual CraterFeatures CratersOver(const RasterGrid& grid, double spacing) const = 0; | ||
| 34 | }; | ||
| 35 | |||
| 36 | /// The craters `layers` apply over `grid`, layer by layer in order: those of every | ||
| 37 | /// `CraterPlacer` among them. | ||
| 38 | /// @param spacing The sample spacing in metres. | ||
| 39 | CraterFeatures PlacedCraters(std::span<const std::shared_ptr<const Layer>> layers, | ||
| 40 | const RasterGrid& grid, double spacing); | ||
| 41 | |||
| 42 | } // namespace terraingen | ||
| 43 |