./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
1 / 1
100.0%
Branches:
3 / 3
100.0%
Functions:
-
-%

src/albedo/zone_shadows.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief Internal: the topographic shadows of the distal reflectance zones around new craters.
5 #pragma once
6
7 #include "terraingen/albedo/crater_albedo_options.h"
8 #include "terraingen/geometry/geometry.h"
9 #include "terraingen/geometry/surface.h"
10
11 #include <cstddef>
12 #include <vector>
13
14 namespace terraingen::detail {
15
16 /// How far a jet from a crater's rim runs above the ground, on `azimuths` rays of `samples`
17 /// samples around the crater, of which `rays` rays from `first` and their first `used` samples
18 /// are held: those reaching the region evaluated.
19
3/3
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 74 times.
✓ Branch 3 taken 75 times.
225 struct ShadowProfile {
20 std::size_t azimuths = 0;
21 std::size_t samples = 0;
22 std::size_t first = 0;
23 std::size_t rays = 0;
24 std::size_t used = 0;
25 double start = 0.0;
26 double step = 0.0;
27 double depth = 1.0;
28 std::vector<float> gap;
29
30 /// How deep in shadow the ground is at `distance` meters and `angle` radians from the
31 /// crater's center, from 0 in the open to 1 in full shadow.
32 double Shade(double distance, double angle) const;
33
34 /// The surface points of the held samples around `center`, row-major by ray.
35 std::vector<Vec2d> Points(const Vec2d& center, const Surface& surface) const;
36
37 /// Sets the samples along each held ray from the ground's `heights` there, row-major by ray:
38 /// how far a jet from the rim, dropping by at most `drop` meters per sample, runs above them.
39 void TraceJets(const std::vector<float>& heights, double drop);
40 };
41
42 /// The rays, of `azimuths` around a center, that reach a region, with one more on each side, and
43 /// the farthest distance in meters of the region from the center.
44 struct RayWindow {
45 std::size_t first = 0;
46 std::size_t rays = 0;
47 double far = 0.0;
48 };
49
50 /// The `RayWindow` of `azimuths` rays around `center` over `region`.
51 RayWindow RaysOver(const Vec2d& center, const Bounds2d& region, const Surface& surface,
52 std::size_t azimuths);
53
54 /// The shadow profile of `shadows` from the rim of a crater `radius` meters across to `reach`
55 /// meters, holding the rays of `window` and the samples out to its far side; heights not yet
56 /// traced.
57 ShadowProfile MakeShadowProfile(const ZoneShadows& shadows, double radius, double reach,
58 const RayWindow& window);
59
60 } // namespace terraingen::detail
61