TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
16 / 17
94.1%
Branches:
5 / 5
100.0%
Functions:
7 / 7
100.0%

layers/craters/generation/cell_cache.cpp
Line Branch Exec Source
1 #include "terraingen/layers/craters/generation/cell_cache.h"
2
3 #include "terraingen/noise/hash.h"
4 #include "terraingen/util/log.h"
5
6 namespace terraingen {
7
8 5734404 std::size_t CraterCellCache::KeyHash::operator()(const Key& key) const {
9 const UVec3 hash =
10 5734404 Pcg3dHash({static_cast<std::uint32_t>(key.exponent), static_cast<std::uint32_t>(key.i),
11 5734404 static_cast<std::uint32_t>(key.j)});
12 5734404 return (static_cast<std::size_t>(hash.x) << 32) ^ hash.y;
13 }
14
15 886 CraterCellCache::CraterCellCache(std::size_t maxCraters)
16
1/1
✓ Branch 2 taken 885 times.
887 : cache_(
17 107469 maxCraters, [](const CraterList& craters) { return craters.Size(); },
18 887 [maxCraters](std::size_t evicted) {
19
1/1
✓ Branch 1 taken 369 times.
369 LogDebug("craters", "Crater cache evicted ", evicted, " cells to stay within ",
20 369 maxCraters, " craters");
21 1254 }) {}
22
23 363513 CellCraterSource CachedCellCraters(CraterCellCache& cache, const SurfaceCells& cells,
24 const SizeFrequencyDistribution& density,
25 const CraterAgeModel& ages, std::uint32_t seed) {
26 363513 return [&cache, &cells, &density, &ages, seed](const CraterBand& band, const CellIndex& cell) {
27 ✗ return cache.Get(band.exponent, cell, [&] {
28 106180 return GenerateCellCraters(cells, band, cell, density, ages, seed);
29
2/2
✓ Branch 1 taken 2764800 times.
✓ Branch 4 taken 2764800 times.
2764800 });
30
1/1
✓ Branch 1 taken 363513 times.
727026 };
31 }
32
33 } // namespace terraingen
34