layers/boulders/ejecta_index.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /// @file | ||
| 2 | /// @brief `EjectaIndex`, craters bucketed by the discs their ejecta reach. | ||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include "terraingen/layers/craters/crater.h" | ||
| 6 | #include "terraingen/util/surface.h" | ||
| 7 | |||
| 8 | #include <cstdint> | ||
| 9 | #include <functional> | ||
| 10 | #include <vector> | ||
| 11 | |||
| 12 | namespace terraingen { | ||
| 13 | |||
| 14 | /// Craters bucketed on a plane by the discs their ejecta reach, so that the craters able to reach | ||
| 15 | /// a point are found without visiting all of them. On a body every crater is a candidate. | ||
| 16 | class EjectaIndex { | ||
| 17 | public: | ||
| 18 | 2878439 | EjectaIndex() = default; | |
| 19 | |||
| 20 | /// Indexes `craters`, each reaching `reach(crater)` metres from its centre. | ||
| 21 | EjectaIndex(CraterList craters, const Surface& surface, | ||
| 22 | const std::function<double(const Crater&)>& reach); | ||
| 23 | |||
| 24 | 1206864 | const CraterList& Craters() const { | |
| 25 | 1206864 | return craters_; | |
| 26 | } | ||
| 27 | 3712819 | bool Empty() const { | |
| 28 | 3712819 | return craters_.Empty(); | |
| 29 | } | ||
| 30 | |||
| 31 | /// The craters whose reach may hold (`x`, `y`), in ascending order; a superset of those | ||
| 32 | /// that do. | ||
| 33 | const std::vector<std::uint32_t>& Near(double x, double y) const; | ||
| 34 | |||
| 35 | private: | ||
| 36 | CraterList craters_; | ||
| 37 | std::vector<std::uint32_t> all_; | ||
| 38 | double minX_ = 0.0; | ||
| 39 | double minY_ = 0.0; | ||
| 40 | double cell_ = 0.0; | ||
| 41 | std::size_t columns_ = 0; | ||
| 42 | std::size_t rows_ = 0; | ||
| 43 | std::vector<std::vector<std::uint32_t>> buckets_; | ||
| 44 | }; | ||
| 45 | |||
| 46 | } // namespace terraingen | ||
| 47 |