./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
236 / 237
99.6%
Branches:
165 / 186
88.7%
Functions:
16 / 16
100.0%

src/layers/boulders/boulder_pose.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 #include "terraingen/layers/boulders/boulder_layer.h"
4
5 #include "terraingen/noise/hash.h"
6 #include "terraingen/random/stream.h"
7 #include "terraingen/util/bits.h"
8
9 #include <algorithm>
10 #include <cmath>
11 #include <vector>
12
13 namespace terraingen {
14
15 31101 const ManualBoulder* BoulderLayer::Fixed(std::uint64_t id) const {
16 31101 const auto found = m_fixed.find(id);
17
2/2
✓ Branch 0 taken 18123 times.
✓ Branch 1 taken 12978 times.
49224 return found != m_fixed.end() ? &found->second : nullptr;
18 }
19
20 16948 bool BoulderLayer::Settles(const Boulder& boulder) const {
21
1/2
✓ Branch 0 taken 16948 times.
✗ Branch 1 not taken.
16948 if (!m_options.pose.settle) {
22 return false;
23 }
24
2/2
✓ Branch 0 taken 16497 times.
✓ Branch 1 taken 451 times.
16948 const ManualBoulder* fixed = boulder.parent == 0 ? Fixed(boulder.id) : nullptr;
25
4/4
✓ Branch 0 taken 8506 times.
✓ Branch 1 taken 7991 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1 time.
16505 return fixed == nullptr || !fixed->FixesOrientation();
26 }
27
28 485622 double BoulderLayer::Wear(double diameter, const BoulderAbundance& abundance, double density,
29 std::uint64_t id) const {
30 485622 RandomStream random = AttributeStream(id, BoulderDraw::Wear);
31 485622 const double thrown = random.NextDouble();
32
3/4
✓ Branch 0 taken 13211 times.
✓ Branch 1 taken 472411 times.
✓ Branch 2 taken 13211 times.
✗ Branch 3 not taken.
485622 if (abundance.ejecta > 0.0 && density > 0.0) {
33 13211 const double fromCrater = abundance.ejecta * m_ejectaSizes->Incremental(diameter) / density;
34
2/2
✓ Branch 0 taken 10818 times.
✓ Branch 1 taken 2393 times.
13211 if (thrown < fromCrater) {
35 10818 return abundance.ejectaWear;
36 }
37 }
38 474804 return random.NextDouble();
39 }
40
41 485622 Boulder BoulderLayer::DrawPose(const ThinnedCandidate& thinned, double spacing,
42 const ManualBoulder* fixed) const {
43 485622 const Crater& candidate = thinned.candidate;
44 485622 RandomStream random = AttributeStream(candidate.id, BoulderDraw::Pose);
45 485622 const BoulderPose& pose = m_options.pose;
46 485622 const double ratio =
47 485622 ValueRange{pose.minHeightRatio, pose.maxHeightRatio}.Lerp(random.NextDouble());
48 485622 double wear = Wear(candidate.diameter, thinned.abundance, thinned.density, candidate.id);
49
4/4
✓ Branch 0 taken 9616 times.
✓ Branch 1 taken 476006 times.
✓ Branch 2 taken 9590 times.
✓ Branch 3 taken 26 times.
485622 if (fixed != nullptr && fixed->wear) {
50 9590 wear = *fixed->wear;
51 }
52 485622 double share = random.NextDouble();
53
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 484131 times.
485622 if (pose.burialByWear > 0.0) {
54 1491 share = (1.0 - pose.burialByWear) * share + pose.burialByWear * wear;
55 }
56 485622 const double burial = ValueRange{pose.minBurial, pose.maxBurial}.Lerp(share);
57 485622 const double yaw = 2.0 * kPi * random.NextDouble();
58 485622 const double lean = (pose.maxLeanDegrees * kDegree) * random.NextDouble();
59 485622 Boulder boulder{
60 485622 candidate.x, candidate.y, candidate.diameter, ratio * candidate.diameter, burial,
61 485622 yaw, lean, candidate.id};
62 485622 boulder.wear = wear;
63 485622 boulder.model = m_options.rendering.modelThreshold.IsModel(boulder.diameter, spacing);
64
2/2
✓ Branch 0 taken 9616 times.
✓ Branch 1 taken 476006 times.
485622 if (fixed != nullptr) {
65
2/2
✓ Branch 0 taken 9592 times.
✓ Branch 1 taken 24 times.
9616 boulder.height = fixed->height.value_or(boulder.height);
66
2/2
✓ Branch 0 taken 9603 times.
✓ Branch 1 taken 13 times.
9616 boulder.burial = fixed->burial.value_or(boulder.burial);
67
2/2
✓ Branch 0 taken 9591 times.
✓ Branch 1 taken 25 times.
9616 if (fixed->yawDegrees) {
68 9591 boulder.yaw = *fixed->yawDegrees * kDegree;
69 }
70
2/2
✓ Branch 0 taken 9590 times.
✓ Branch 1 taken 26 times.
9616 if (fixed->leanDegrees) {
71 9590 boulder.lean = *fixed->leanDegrees * kDegree;
72 }
73 9616 boulder.shapeSeed = fixed->shapeSeed;
74
2/2
✓ Branch 0 taken 9584 times.
✓ Branch 1 taken 32 times.
19200 boulder.model = fixed->model.value_or(boulder.model);
75 }
76 485622 return boulder;
77 }
78
79 485622 std::optional<Boulder> BoulderLayer::PlaceCandidate(const ThinnedCandidate& thinned, double spacing,
80 const Ground* ground) const {
81
2/2
✓ Branch 0 taken 9642 times.
✓ Branch 1 taken 475980 times.
485622 const ManualBoulder* fixed = thinned.candidate.manual ? Fixed(thinned.candidate.id) : nullptr;
82 485622 Boulder boulder = DrawPose(thinned, spacing, fixed);
83 485622 const BoulderPose& pose = m_options.pose;
84
8/8
✓ Branch 0 taken 62022 times.
✓ Branch 1 taken 423600 times.
✓ Branch 2 taken 61398 times.
✓ Branch 3 taken 624 times.
✓ Branch 4 taken 61396 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1641 times.
✓ Branch 7 taken 59755 times.
547018 if (pose.maxSlopeDegrees && ground != nullptr && !thinned.candidate.manual &&
85 61396 !Roll(boulder, *ground)) {
86 1641 return std::nullopt;
87 }
88 483981 ReadGround(boulder, ground);
89
2/4
✓ Branch 0 taken 465918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465918 times.
✗ Branch 3 not taken.
465918 if (pose.sideShare > 0.0 || pose.endShare > 0.0 || (pose.maxTiltDegrees * kDegree) > 0.0 ||
90
8/8
✓ Branch 0 taken 465918 times.
✓ Branch 1 taken 18063 times.
✓ Branch 2 taken 464856 times.
✓ Branch 3 taken 1062 times.
✓ Branch 4 taken 9603 times.
✓ Branch 5 taken 455253 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 16 times.
949917 pose.followSlope || (fixed != nullptr && fixed->FixesOrientation())) {
91 28712 Settle(boulder, ground, fixed);
92 }
93
2/2
✓ Branch 0 taken 3612 times.
✓ Branch 1 taken 480369 times.
483981 if (m_options.ventifacts.share > 0.0) {
94 3612 Abrade(boulder);
95 }
96 483981 return boulder;
97 }
98
99 483981 void BoulderLayer::ReadGround(Boulder& boulder, const Ground* ground) const {
100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483981 times.
483981 boulder.ground.reset();
101
2/2
✓ Branch 0 taken 323719 times.
✓ Branch 1 taken 160262 times.
483981 if (ground != nullptr) {
102 323719 const double height =
103 323719 static_cast<double>(ground->HeightAt(boulder.x, boulder.y, m_options.groundSpacing));
104
2/2
✓ Branch 0 taken 323715 times.
✓ Branch 1 taken 4 times.
323719 if (!std::isnan(height)) {
105 323715 boulder.ground = height;
106 }
107 }
108 483981 }
109
110 3612 void BoulderLayer::Abrade(Boulder& boulder) const {
111 3612 const BoulderVentifacts& ventifacts = m_options.ventifacts;
112 3612 RandomStream random = AttributeStream(boulder.id, BoulderDraw::Abrade);
113
2/2
✓ Branch 1 taken 1709 times.
✓ Branch 2 taken 1903 times.
3612 if (random.NextDouble() >= ventifacts.share) {
114 1709 return;
115 }
116 1903 const double reach = 0.5 * boulder.diameter * (1.0 - boulder.wear);
117 4413 const auto facet = [&](double wind, double pick) {
118 2510 return BoulderFacet{wind + kPi,
119 2510 ValueRange{(ventifacts.minAngleDegrees * kDegree),
120 607 (ventifacts.maxAngleDegrees * kDegree)}
121 2510 .Lerp(pick),
122 reach};
123 1903 };
124 1903 boulder.facets[0] = facet((ventifacts.windAzimuthDegrees * kDegree), random.NextDouble());
125 1903 boulder.facetCount = 1;
126 1903 const double keel = random.NextDouble();
127 1903 const double second = random.NextDouble();
128
4/4
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 721 times.
✓ Branch 2 taken 607 times.
✓ Branch 3 taken 575 times.
1903 if (ventifacts.secondWindAzimuthDegrees && keel < ventifacts.keelShare) {
129 607 boulder.facets[1] = facet((*ventifacts.secondWindAzimuthDegrees * kDegree), second);
130 607 boulder.facetCount = 2;
131 }
132 }
133
134 61396 bool BoulderLayer::Roll(Boulder& boulder, const Ground& ground) const {
135 61396 constexpr double kMaxSteps = 128.0;
136 61396 const BoulderPose& pose = m_options.pose;
137
2/2
✓ Branch 0 taken 59016 times.
✓ Branch 1 taken 2380 times.
61396 const double limit = std::tan((*pose.maxSlopeDegrees * kDegree));
138
2/2
✓ Branch 0 taken 59016 times.
✓ Branch 1 taken 2380 times.
61396 const double reach = pose.rollDistance.value_or(0.0);
139 61396 const double step = std::fmax(boulder.diameter, reach / kMaxSteps);
140 61396 double rolled = 0.0;
141 661180 for (;;) {
142 361288 const std::optional<Vec2d> g = Gradient(boulder, ground);
143
1/2
✓ Branch 0 taken 361288 times.
✗ Branch 1 not taken.
361288 const double gradient = g ? std::hypot(g->x, g->y) : 0.0;
144
2/2
✓ Branch 0 taken 301533 times.
✓ Branch 1 taken 59755 times.
361288 if (!(gradient > limit)) {
145 61396 return true;
146 }
147
2/2
✓ Branch 0 taken 299892 times.
✓ Branch 1 taken 1641 times.
301533 if (rolled + step > reach) {
148 return false;
149 }
150 299892 const Vec2d to = m_surface.Locate({boulder.x, boulder.y},
151 299892 {-g->x / gradient * step, -g->y / gradient * step});
152 299892 boulder.x = to.x;
153 299892 boulder.y = to.y;
154 299892 rolled += step;
155 299892 }
156 }
157
158 362444 std::optional<Vec2d> BoulderLayer::Gradient(const Boulder& boulder, const Ground& ground) const {
159 724888 return GroundGradient(ground, m_surface, {boulder.x, boulder.y}, 0.5 * boulder.diameter,
160 362444 m_options.groundSpacing);
161 }
162
163 28712 Vec3d BoulderLayer::UpAxis(RandomStream& random, const ManualBoulder* fixedTilt) const {
164 28712 const BoulderPose& pose = m_options.pose;
165 28712 Vec3d up{0.0, 0.0, 1.0};
166 28712 double cosine = 1.0;
167 28712 double azimuth = 0.0;
168
2/2
✓ Branch 0 taken 17975 times.
✓ Branch 1 taken 10737 times.
28712 if ((pose.maxTiltDegrees * kDegree) > 0.0) {
169 17975 cosine = 1.0 - random.NextDouble() * (1.0 - std::cos(pose.maxTiltDegrees * kDegree));
170 17975 const double sine = std::sqrt(std::fmax(0.0, 1.0 - cosine * cosine));
171 17975 azimuth = 2.0 * kPi * random.NextDouble();
172 17975 up = {sine * std::cos(azimuth), sine * std::sin(azimuth), cosine};
173 }
174
2/2
✓ Branch 0 taken 19122 times.
✓ Branch 1 taken 9590 times.
28712 if (fixedTilt == nullptr) {
175 19122 return up;
176 }
177
2/2
✓ Branch 0 taken 9585 times.
✓ Branch 1 taken 5 times.
9590 if (!((pose.maxTiltDegrees * kDegree) > 0.0)) {
178 9585 azimuth = 2.0 * kPi * random.NextDouble();
179 }
180 9590 const double tilt =
181
1/2
✓ Branch 0 taken 9590 times.
✗ Branch 1 not taken.
9590 fixedTilt->tiltDegrees ? *fixedTilt->tiltDegrees * kDegree : std::acos(cosine);
182 9590 const double toward =
183
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9583 times.
9590 fixedTilt->tiltAzimuthDegrees ? *fixedTilt->tiltAzimuthDegrees * kDegree : azimuth;
184 9590 return {std::sin(tilt) * std::cos(toward), std::sin(tilt) * std::sin(toward), std::cos(tilt)};
185 }
186
187 28712 void BoulderLayer::Settle(Boulder& boulder, const Ground* ground,
188 const ManualBoulder* fixed) const {
189 28712 const BoulderPose& pose = m_options.pose;
190 28712 RandomStream random = AttributeStream(boulder.id, BoulderDraw::Settle);
191 28712 const double pick = random.NextDouble();
192
2/2
✓ Branch 0 taken 26904 times.
✓ Branch 1 taken 1808 times.
28712 boulder.rest = pick < pose.endShare ? BoulderRest::End
193
2/2
✓ Branch 0 taken 21472 times.
✓ Branch 1 taken 5432 times.
26904 : pick < pose.endShare + pose.sideShare ? BoulderRest::Side
194 : BoulderRest::Face;
195
4/4
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 19112 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9591 times.
28712 if (fixed != nullptr && fixed->rest) {
196 9 boulder.rest = *fixed->rest;
197 }
198
5/6
✓ Branch 0 taken 9591 times.
✓ Branch 1 taken 19112 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 9590 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
28712 const bool fixesTilt = fixed != nullptr && (fixed->tiltDegrees.has_value() ||
199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 fixed->tiltAzimuthDegrees.has_value());
200 28712 Vec3d up = UpAxis(random, fixesTilt ? fixed : nullptr);
201 28712 bool sloped = false;
202
3/4
✓ Branch 0 taken 1156 times.
✓ Branch 1 taken 27556 times.
✓ Branch 2 taken 1156 times.
✗ Branch 3 not taken.
28712 if (pose.followSlope && ground != nullptr) {
203
1/2
✓ Branch 1 taken 1156 times.
✗ Branch 2 not taken.
1156 if (const std::optional<Vec2d> g = Gradient(boulder, *ground)) {
204 1156 const double slope = std::atan(std::hypot(g->x, g->y));
205 1156 up = TiltRotation(slope, std::atan2(-g->y, -g->x)).Apply(up);
206 1156 sloped = true;
207 }
208 }
209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28712 times.
28712 boulder.tilt = std::acos(std::clamp(up.z, -1.0, 1.0));
210 28712 boulder.tiltAzimuth = std::atan2(up.y, up.x);
211
2/2
✓ Branch 0 taken 9589 times.
✓ Branch 1 taken 19123 times.
28712 if (fixesTilt && !sloped) {
212
1/2
✓ Branch 0 taken 9589 times.
✗ Branch 1 not taken.
9589 if (fixed->tiltDegrees) {
213 9589 boulder.tilt = *fixed->tiltDegrees * kDegree;
214 }
215
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9583 times.
9589 if (fixed->tiltAzimuthDegrees) {
216 6 boulder.tiltAzimuth = *fixed->tiltAzimuthDegrees * kDegree;
217 }
218 }
219 28712 }
220
221 3616 void BoulderLayer::ReadGrounds(std::vector<Boulder>& boulders,
222 const std::vector<std::size_t>& indices, const Ground* ground,
223 unsigned threads) const {
224
1/1
✓ Branch 1 taken 3616 times.
3616 std::vector<Vec2d> points;
225
1/1
✓ Branch 1 taken 3616 times.
3616 points.reserve(indices.size());
226
2/2
✓ Branch 0 taken 13053 times.
✓ Branch 1 taken 3616 times.
16669 for (const std::size_t n : indices) {
227
2/2
✓ Branch 0 taken 507 times.
✓ Branch 1 taken 12546 times.
13053 boulders[n].ground.reset();
228
1/1
✓ Branch 1 taken 13053 times.
13053 points.push_back({boulders[n].x, boulders[n].y});
229 }
230
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 time.
3616 if (ground == nullptr || points.empty()) {
231 3615 return;
232 }
233
1/1
✓ Branch 1 taken 1 time.
1 std::vector<float> heights(points.size());
234
1/1
✓ Branch 3 taken 1 time.
1 ground->HeightsAt(points, heights, m_options.groundSpacing, threads);
235
2/2
✓ Branch 0 taken 507 times.
✓ Branch 1 taken 1 time.
508 for (std::size_t k = 0; k < indices.size(); ++k) {
236
1/2
✓ Branch 0 taken 507 times.
✗ Branch 1 not taken.
507 if (!std::isnan(heights[k])) {
237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 507 times.
1014 boulders[indices[k]].ground = heights[k];
238 }
239 }
240 3616 }
241
242 4961 BoulderLayer::BreakStage BoulderLayer::Stage(const Boulder& parent) const {
243
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 890 times.
4961 const BoulderFragmentation& fragmentation = *m_options.fragmentation;
244 4961 const bool rubble = parent.wear >= fragmentation.rubbleWear;
245 4961 BreakStage stage;
246
1/2
✓ Branch 0 taken 4071 times.
✗ Branch 1 not taken.
4071 stage.opening = rubble || fragmentation.rubbleWear <= fragmentation.splitWear
247
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 890 times.
4961 ? 1.0
248 4071 : (parent.wear - fragmentation.splitWear) /
249 4071 (fragmentation.rubbleWear - fragmentation.splitWear);
250
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 4071 times.
4961 stage.scatter = !rubble ? 0.0
251
1/2
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
890 : fragmentation.rubbleWear < 1.0 ? (parent.wear - fragmentation.rubbleWear) /
252 890 (1.0 - fragmentation.rubbleWear)
253 : 1.0;
254 4961 return stage;
255 }
256
257 16120 Boulder BoulderLayer::PlacePiece(const Boulder& parent, const BoulderFragment& fragment,
258 std::size_t k, const PieceFrame& frame, double push,
259 double twist) const {
260 16120 const BoulderFragmentation& fragmentation = *m_options.fragmentation;
261 16120 const BoulderPlacement& placement = frame.placement;
262 16120 const double scatter = frame.stage.scatter;
263 16120 const auto [low, high] = ZRange(fragment.shape.mesh.positions, [&](const Vec3d& p) {
264 7985008 return placement.Apply(fragment.center + p * fragment.scale);
265 });
266 16120 const Vec3d center = placement.Apply(fragment.center);
267 16120 const double out = std::hypot(center.x, center.y);
268
1/2
✓ Branch 0 taken 16120 times.
✗ Branch 1 not taken.
16120 const double angle = out > 0.0 ? std::atan2(center.y, center.x) : 2.0 * kPi * push;
269 16120 const double gap = (frame.stage.opening * fragmentation.gapRatio +
270 16120 scatter * fragmentation.spreadRatio * (0.5 + 0.5 * push)) *
271 16120 parent.diameter;
272 16120 Boulder piece = parent;
273 16120 piece.facetCount = 0;
274
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 15889 times.
16120 const IdWords id = SplitId(parent.id);
275 16120 const UVec3 key =
276 16120 Pcg3dHash({id.low, id.high, kBoulderPieceStream + static_cast<std::uint32_t>(k)});
277
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 15889 times.
16120 piece.id = JoinWords(key.x, key.y);
278 16120 piece.parent = parent.id;
279 16120 piece.piece = static_cast<std::uint32_t>(k);
280 16120 piece.diameter = parent.diameter * fragment.scale;
281 16120 piece.height = parent.height * fragment.shape.shortAxis * fragment.scale / frame.shortAxis;
282 16120 piece.yaw = parent.yaw + scatter * kPi * (2.0 * twist - 1.0);
283 16120 piece.lean = parent.lean * (1.0 - scatter);
284 16120 piece.tilt = parent.tilt * (1.0 - scatter);
285
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 15889 times.
16120 const double sunk = std::clamp(-low / (high - low), 0.0, 0.95);
286 16120 piece.burial = std::fmax(sunk, sunk + scatter * (m_options.pose.maxBurial - sunk));
287 32240 const Vec2d at = m_surface.Locate(
288 16120 {parent.x, parent.y}, {center.x + gap * std::cos(angle), center.y + gap * std::sin(angle)});
289 16120 piece.x = at.x;
290 16120 piece.y = at.y;
291 16120 return piece;
292 }
293
294 5423 std::vector<Boulder> BoulderLayer::Break(const Boulder& parent, double spacing,
295 double smallest) const {
296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5423 times.
5423 if (!m_options.fragmentation) {
297 ✗ return {parent};
298 }
299
2/2
✓ Branch 0 taken 4988 times.
✓ Branch 1 taken 435 times.
5423 const BoulderFragmentation& fragmentation = *m_options.fragmentation;
300
6/6
✓ Branch 0 taken 4988 times.
✓ Branch 1 taken 435 times.
✓ Branch 2 taken 4962 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 4961 times.
10385 if (parent.diameter < fragmentation.minDiameter || parent.wear < fragmentation.splitWear ||
301 4962 Fixed(parent.id) != nullptr) {
302 462 return {parent};
303 }
304 4961 const auto shape = Shape(parent);
305
2/2
✓ Branch 1 taken 4961 times.
✓ Branch 4 taken 4961 times.
4961 const auto fragments = CachedFragments(ShapeSeed(parent, m_options.rendering.shapePrototypes));
306 4961 Boulder origin = parent;
307 4961 origin.x = 0.0;
308 4961 origin.y = 0.0;
309
2/2
✓ Branch 2 taken 4961 times.
✓ Branch 5 taken 4961 times.
4961 const PieceFrame frame{PlaceBoulderModel(origin, *shape, 0.0, Settles(parent)), Stage(parent),
310 4961 shape->shortAxis};
311
1/1
✓ Branch 1 taken 4961 times.
4961 const IdWords id = SplitId(parent.id);
312
1/1
✓ Branch 1 taken 4961 times.
4961 RandomStream random(m_options.seed, kBoulderPieceStream, id.low, id.high);
313 4961 std::vector<Boulder> pieces;
314
2/2
✓ Branch 0 taken 16120 times.
✓ Branch 1 taken 4961 times.
21081 for (std::size_t k = 0; k < fragments->size(); ++k) {
315
1/1
✓ Branch 1 taken 16120 times.
16120 const double push = random.NextDouble();
316
1/1
✓ Branch 1 taken 16120 times.
16120 const double twist = random.NextDouble();
317
1/1
✓ Branch 1 taken 16120 times.
16120 Boulder piece = PlacePiece(parent, (*fragments)[k], k, frame, push, twist);
318
2/2
✓ Branch 0 taken 1237 times.
✓ Branch 1 taken 14883 times.
16120 if (piece.diameter < smallest) {
319 1237 continue;
320 }
321
1/1
✓ Branch 1 taken 14883 times.
14883 piece.model = m_options.rendering.modelThreshold.IsModel(piece.diameter, spacing);
322
1/1
✓ Branch 1 taken 14883 times.
14883 pieces.push_back(piece);
323 }
324 4961 return pieces;
325
2/4
✓ Branch 1 taken 4961 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4961 times.
✗ Branch 4 not taken.
14883 }
326
327 } // namespace terraingen
328