0x004BDC67 (when treeType is nullopt) & 0x004BDDC6 (when treeType is set)
| 137 | |
| 138 | // 0x004BDC67 (when treeType is nullopt) & 0x004BDDC6 (when treeType is set) |
| 139 | bool placeTreeCluster(const World::TilePos2& centreLoc, const uint16_t range, const uint16_t density, const std::optional<uint8_t> treeType) |
| 140 | { |
| 141 | const auto numPlacements = (range * range * density) / 8192; |
| 142 | uint16_t numErrors = 0; |
| 143 | for (auto i = 0; i < numPlacements; ++i) |
| 144 | { |
| 145 | // Choose a random offset in a circle |
| 146 | auto& rng = gPrng1(); |
| 147 | auto randomMagnitude = rng.randNext(std::numeric_limits<uint16_t>::max()) * range / 65536; |
| 148 | auto randomDirection = rng.randNext(Math::Trigonometry::kDirectionPrecisionHigh - 1); |
| 149 | World::Pos2 randomOffset( |
| 150 | Math::Trigonometry::integerSinePrecisionHigh(randomDirection, randomMagnitude), |
| 151 | Math::Trigonometry::integerCosinePrecisionHigh(randomDirection, randomMagnitude)); |
| 152 | |
| 153 | if (!placeRandomTree(randomOffset + World::toWorldSpace(centreLoc), treeType)) |
| 154 | { |
| 155 | numErrors++; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | // Have we placed any trees? |
| 160 | return (numErrors < numPlacements); |
| 161 | } |
| 162 | } |
no test coverage detected