16float dot(V
a, V
b) {
return a.x *
b.x +
a.y *
b.y +
a.z *
b.z; }
17V
cross(V
a, V
b) {
return {
a.
y *
b.z -
a.z *
b.y,
a.z *
b.x -
a.x *
b.z,
a.x *
b.y -
a.y *
b.x}; }
21 return std::isfinite(
a.x) && std::isfinite(
a.y) && std::isfinite(
a.z) &&
22 std::max({std::fabs(
a.x), std::fabs(
a.y), std::fabs(
a.z)}) <= 100000.f;
28Result<void>
validate(
const BridgeParameters&
p) {
30 return invalid<void>(
"unknown bridge kind or non-finite endpoint");
31 const float dimensions[] = {
32 p.width,
p.deckThickness,
p.memberWidth,
p.pierWidth,
p.pierDepth,
p.archRise,
33 p.towerHeight,
p.trussHeight,
p.cableRadius,
p.railingHeight,
p.railingWidth,
p.memberDepth,
34 p.girderHeight,
p.archRibWidth,
p.archRibDepth,
p.foundationHeight,
p.foundationScale,
p.pierCapHeight,
35 p.abutmentDepth,
p.wingWallLength,
p.uvMeters,
p.towerLegWidth};
36 for (
float value : dimensions)
38 return
invalid<void>(
"bridge dimensions must be finite and in [0.01,100] metres");
39 if (!std::isfinite(
p.sidewalkWidth) ||
p.sidewalkWidth < 0.f ||
p.sidewalkWidth > 20.f ||
40 !std::isfinite(
p.groundY) || !std::isfinite(
p.cableSag) ||
p.cableSag < .05f ||
p.cableSag > .95f ||
41 !std::isfinite(
p.towerInset) ||
p.towerInset < .15f ||
p.towerInset > .4f ||
42 !std::isfinite(
p.towerTopWidthRatio) ||
p.towerTopWidthRatio < .05f ||
p.towerTopWidthRatio > 1.f ||
44 p.railingBars > 8 ||
p.plankCount < 8 ||
p.plankCount > 2048 || !std::isfinite(
p.portalInset) ||
45 p.portalInset < 0.f ||
p.portalInset > .2f || !std::isfinite(
p.cantileverCenterRatio) ||
46 p.cantileverCenterRatio < .1f ||
p.cantileverCenterRatio > .7f ||
p.spans < 1 ||
p.spans > 64 ||
p.panels < 2 ||
47 p.panels > 64 ||
p.curveSegments < 4 ||
p.curveSegments > 128 ||
p.cableSides < 3 ||
p.cableSides > 16)
48 return invalid<void>(
"bridge offsets, ratios or subdivision counts outside supported bounds");
49 const double span = std::hypot(
double(
p.end.x) -
p.start.x,
double(
p.end.z) -
p.start.z);
52 if (span < 12. || span > 10000. || std::max(std::fabs(
p.start.y), std::fabs(
p.end.y)) > 100000.f ||
53 std::min(
p.start.y,
p.end.y) -
p.deckThickness - below -
p.foundationHeight -
p.pierCapHeight <=
p.groundY)
54 return invalid<void>(
"horizontal span must be [12,10000]; foundations must lie below the complete structure");
60 constexpr std::string_view names[] = {
"beam",
"slab",
"arch",
"tiedArch",
"throughTruss",
61 "deckTruss",
"suspension",
"cableStayed",
"cantilever",
"trestle"};
62 const auto index =
static_cast<unsigned>(
kind);
63 return index < std::size(names) ? names[
index] : std::string_view{};
66 constexpr std::string_view names[] = {
67 "deck",
"asphalt.bridge",
"pier",
"abutment",
"girder",
"arch",
"truss",
"tower",
"cable",
68 "hanger",
"railing",
"marking",
"footing",
"cap",
"sidewalk",
"connection",
"anchor"};
69 const auto index =
static_cast<unsigned>(part);
70 return index < std::size(names) ? names[
index] : std::string_view{};
73 constexpr std::string_view names[] = {
"concrete",
"limestone",
"paintedSteel",
"galvanizedSteel",
74 "timber",
"asphalt",
"whitePaint",
"yellowPaint"};
76 return index < std::size(names) ? names[
index] : std::string_view{};
79 if (
bridgeKindName(
kind).empty())
return invalid<BridgeParameters>(
"unknown bridge preset");
83 p.connectionDetails =
true;
84 float span = 72.f,
height = 9.f;
87 p.foundationScale = 1.8f;
88 p.pierCapHeight = 1.f;
91 p.girderHeight = 1.2f;
99 p.deckThickness = .65f;
100 p.foundationHeight = .65f;
101 p.abutmentDepth = 2.4f;
102 p.wingWallLength = 5.f;
104 p.railingHeight = .95f;
105 p.sidewalkWidth = .4f;
114 p.archRibWidth = .95f;
115 p.archRibDepth = 1.1f;
117 p.memberDepth = .55f;
119 p.railingHeight = .9f;
126 p.archRibWidth = .65f;
127 p.archRibDepth = .85f;
129 p.memberWidth = .35f;
131 p.cableRadius = .055f;
139 p.portalInset = .07f;
140 p.memberWidth = .42f;
157 p.towerHeight = 32.f;
159 p.towerLegWidth = 2.1f;
161 p.cableRadius = .14f;
162 p.girderHeight = 1.5f;
163 p.memberWidth = .35f;
170 p.towerHeight = 28.f;
171 p.towerLegWidth = 1.9f;
173 p.towerTopWidthRatio = .2f;
174 p.cableRadius = .065f;
180 p.trussHeight = 20.f;
182 p.memberWidth = .65f;
183 p.memberDepth = .85f;
184 p.cantileverCenterRatio = .30f;
188 p.foundationHeight = 1.2f;
195 p.sidewalkWidth = 0.f;
197 p.deckThickness = .22f;
198 p.memberWidth = .28f;
199 p.memberDepth = .32f;
200 p.girderHeight = .5f;
202 p.foundationHeight = .4f;
204 p.railingWidth = .1f;
209 p.start = {-span * .5f,
height, 0.f};
210 p.end = {span * .5f,
height, 0.f};
220 side =
unit(
cross({0.f, 1.f, 0.f},
p.end -
p.start));
221 horizontalLength = std::hypot(
p.end.x -
p.start.x,
p.end.z -
p.start.z);
222 half =
p.width * .5f +
p.sidewalkWidth;
223 plan.cableSides =
p.cableSides;
230 for (
float lateral : {-half * .72f, 0.f, half * .72f})
232 point(1, -
p.deckThickness -
p.girderHeight * .5f,
lateral),
p.memberWidth * 1.6f,
p.girderHeight,
237 support(
p.towerInset);
238 support(1.f -
p.towerInset);
240 for (
int i = 1; i <
p.spans; ++i) support(
static_cast<float>(i) /
static_cast<float>(
p.spans));
245 if (towers) cables();
246 return std::move(plan);
250 const BridgeParameters&
p;
253 float half = 0.f, horizontalLength = 0.f;
255 return p.start + (
p.end -
p.start) *
t + V{0.f,
y, 0.f} + side *
lateral;
277 member.material = finish(part);
279 plan.members.push_back(
member);
291 for (
int i = 0; i <
p.plankCount; ++i) {
292 float a = (
static_cast<float>(i) + .025f) /
static_cast<float>(
p.plankCount);
293 float b = (
static_cast<float>(i) + .975f) /
static_cast<float>(
p.plankCount);
294 add(
point(
a, -
p.deckThickness * .5f),
point(
b, -
p.deckThickness * .5f), half * 2.f,
p.deckThickness,
297 for (
float lateral : {-half * .72f, 0.f, half * .72f})
299 point(1, -
p.deckThickness -
p.girderHeight * .5f,
lateral),
p.memberWidth,
p.girderHeight,
302 add(
point(0, -
p.deckThickness * .5f),
point(1, -
p.deckThickness * .5f), half * 2.f,
p.deckThickness,
305 if (
p.sidewalkWidth > .01f)
306 for (
float sign : {-1.f, 1.f}) {
307 float lateral = sign * (
p.width * .5f +
p.sidewalkWidth * .5f);
312 for (
float sign : {-1.f, 1.f}) {
313 add(
point(0, .036f, sign * (
p.width * .5f - .18f)),
point(1, .036f, sign * (
p.width * .5f - .18f)),
321 for (
float t : {0.f, 1.f}) {
322 float top = -
p.deckThickness;
324 footing(
t, 0.f, half * 2.f + 1.2f,
p.abutmentDepth + 1.4f);
326 block(
t,
top -
p.pierCapHeight * .5f, 0.f, half * 2.f + .45f,
p.abutmentDepth + .3f,
p.pierCapHeight,
329 for (
float sign : {-1.f, 1.f})
331 float travel = (
static_cast<float>(
step) + .5f) *
p.wingWallLength / 4.f;
332 float along =
t + (
t == 0.f ? -1.f : 1.f) * travel / horizontalLength;
334 block(along,
bottom +
height * .5f, sign * (half + travel * .12f), .5f,
340 if (!
p.railings)
return;
342 for (
float lateral : {-half + .18f, half - .18f}) {
345 plan.members.back().material =
350 for (
int i = 0; i <=
p.panels / 2; ++i) {
351 float t =
static_cast<float>(i) /
static_cast<float>(std::max(1,
p.panels / 2));
352 block(
t, .18f + (
p.railingHeight + .3f) * .5f,
lateral, .65f, .65f,
p.railingHeight + .3f,
361 for (
float lateral : {-half + .12f, half - .12f}) {
362 for (
int bar = 1; bar <=
p.railingBars; ++bar) {
363 float y = base +
p.railingHeight *
static_cast<float>(bar) /
static_cast<float>(
p.railingBars);
368 int posts = std::min(256, std::max(2,
static_cast<int>(std::ceil(horizontalLength / 2.4f))));
369 for (
int i = 0; i <= posts; ++i) {
370 float t =
static_cast<float>(i) /
static_cast<float>(posts);
374 block(
t, base + .035f,
lateral,
p.railingWidth * 2.8f,
p.railingWidth * 2.8f, .07f,
379 void support(
float t) {
380 if (!
p.piers)
return;
381 float deckBottom = -
p.deckThickness;
384 for (
float lateral : {-half * .78f, half * .78f}) {
385 footing(
t,
lateral,
p.memberWidth * 2.7f,
p.memberWidth * 2.7f);
387 a.y =
p.groundY +
p.foundationHeight;
391 add(
point(
t, deckBottom -
p.memberWidth * .5f, -half),
point(
t, deckBottom -
p.memberWidth * .5f, half),
394 for (
float sign : {-1.f, 1.f}) {
395 V foot =
point(
t, 0.f, sign * half * .9f);
396 foot.y =
p.groundY +
p.foundationHeight + .25f;
397 add(foot,
point(
t, deckBottom -
p.memberWidth, -sign * half * .75f),
p.memberWidth * .55f,
403 float base =
p.groundY -
point(
t).y +
p.foundationHeight;
404 for (
int leg = 0; leg < (twin ? 2 : 1); ++leg) {
405 float lateral = twin ? (leg == 0 ? -half * .90f : half * .90f) : 0.f;
406 float width = twin ?
p.pierWidth :
p.pierWidth * 1.7f;
407 footing(
t,
lateral,
width *
p.foundationScale,
p.pierDepth *
p.foundationScale);
410 plan.members.back().endWidth =
width * .8f;
411 plan.members.back().endHeight =
p.pierDepth * .85f;
413 block(
t, deckBottom -
p.pierCapHeight * .5f, 0.f, half * 2.f + .4f,
p.pierDepth * 1.5f,
p.pierCapHeight,
416 void joint(
float t,
float y,
float lateral) {
417 if (!
p.connectionDetails)
return;
418 for (
float sign : {-1.f, 1.f}) {
421 for (
float dx : {-.22f, .22f})
422 for (
float dy : {-.22f, .22f}) {
424 point(
t +
dx *
p.memberDepth / horizontalLength,
y +
dy *
p.memberDepth,
offset - sign * .04f);
432 int spans = above ? 1 :
p.spans;
433 for (
int span = 0; span < spans; ++span) {
435 float t = (
static_cast<float>(span) +
u) /
static_cast<float>(spans);
437 above ? 4.f *
p.archRise *
u * (1.f -
u)
438 : -
p.deckThickness -
p.archRibDepth * .5f -
p.archRise * (2.f *
u - 1.f) * (2.f *
u - 1.f);
441 for (
float lateral : {-half * .85f, half * .85f}) {
442 for (
int i = 0; i <
p.curveSegments; ++i) {
443 float a =
static_cast<float>(i) /
static_cast<float>(
p.curveSegments),
444 b =
static_cast<float>(i + 1) /
static_cast<float>(
p.curveSegments);
448 for (
int i = 1; i <
p.panels; ++i) {
449 float u =
static_cast<float>(i) /
static_cast<float>(
p.panels),
450 t = (
static_cast<float>(span) +
u) /
static_cast<float>(spans);
452 above ?
p.cableRadius * 2.f :
p.memberWidth, above ?
p.cableRadius * 2.f :
p.memberWidth,
460 if (above &&
p.crossBracing)
461 for (
int i = 1; i < 6; ++i) {
462 float u =
static_cast<float>(i) / 6.f;
472 float distance = std::min(std::fabs(
t -
p.towerInset), std::fabs(
t - (1.f -
p.towerInset)));
473 return p.trussHeight * std::max(
p.cantileverCenterRatio, 1.f -
distance /
p.towerInset);
475 if (!below &&
p.portalInset > 0.f)
476 return p.trussHeight * std::min({1.f,
t /
p.portalInset, (1.f -
t) /
p.portalInset});
477 return p.trussHeight;
479 const float base = below ? -
p.deckThickness : 0.f;
480 for (
float lateral : {-half * .93f, half * .93f}) {
481 for (
int i = 0; i <
p.panels; ++i) {
482 float a =
static_cast<float>(i) /
static_cast<float>(
p.panels),
483 b =
static_cast<float>(i + 1) /
static_cast<float>(
p.panels);
494 if (std::fabs(ya - base) > .01f) joint(
a, ya,
lateral);
500 for (
int i = 1; i <
p.panels; ++i) {
501 float t =
static_cast<float>(i) /
static_cast<float>(
p.panels),
502 next =
static_cast<float>(i + 1) /
static_cast<float>(
p.panels);
504 if (!below && std::min(
y, yn) <
p.railingHeight * 2.f)
continue;
505 add(
point(
t,
y, -half * .93f),
point(
t,
y, half * .93f),
p.memberWidth * .7f,
p.memberDepth * .7f,
507 add(
point(
t,
y, -half * .93f),
point(next, yn, half * .93f),
p.memberWidth * .45f,
p.memberDepth * .45f,
509 add(
point(
t,
y, half * .93f),
point(next, yn, -half * .93f),
p.memberWidth * .45f,
p.memberDepth * .45f,
515 const float a =
p.towerInset,
b = 1.f -
a, topRatio = suspension ? 1.f :
p.towerTopWidthRatio;
516 for (
float t : {
a,
b}) {
517 for (
float sign : {-1.f, 1.f}) {
518 float lateral = sign * half * .90f;
521 plan.members.back().endWidth =
p.towerLegWidth * .78f;
522 plan.members.back().endHeight =
p.towerLegWidth * .90f;
524 block(
t,
p.towerHeight + .18f,
lateral,
p.towerLegWidth * 1.5f,
p.towerLegWidth * 1.6f, .36f,
530 for (
float level : {.30f, .67f}) {
531 float y =
p.towerHeight *
level;
533 for (
int i = 0; i < 20; ++i) {
534 float u =
static_cast<float>(i) / 20.f,
v =
static_cast<float>(i + 1) / 20.f;
535 float ya =
y + 2.0f * (1.f - (2.f *
u - 1.f) * (2.f *
u - 1.f));
536 float yb =
y + 2.0f * (1.f - (2.f *
v - 1.f) * (2.f *
v - 1.f));
537 add(
point(
t, ya, (2.f *
u - 1.f) * half * .9f),
point(
t, yb, (2.f *
v - 1.f) * half * .9f),
543 float y =
p.towerHeight * .2f,
ratio = 1.f - (1.f - topRatio) * .2f;
548 for (
float lateral : {-half * .90f, half * .90f}) {
553 auto cableY = [&](
float t) {
554 if (
t <
a)
return p.towerHeight *
t /
a;
555 if (
t >
b)
return p.towerHeight * (1.f -
t) /
a;
556 float u = (
t -
a) / (
b -
a);
557 return p.towerHeight * (1.f -
p.cableSag * 4.f *
u * (1.f -
u));
560 p.cableRadius * 1.6f);
562 p.cableRadius * 1.6f);
563 for (
int i = 0; i <
p.curveSegments; ++i) {
564 float t0 =
a + (
b -
a) *
static_cast<float>(i) /
static_cast<float>(
p.curveSegments),
565 t1 =
a + (
b -
a) *
static_cast<float>(i + 1) /
static_cast<float>(
p.curveSegments);
567 p.cableRadius * 1.6f);
569 for (
int i = 1; i <
p.panels; ++i) {
570 float t =
static_cast<float>(i) /
static_cast<float>(
p.panels);
572 p.cableRadius * .42f);
574 for (
float t : {0.f, 1.f})
576 for (
float t : {
a,
b})
577 block(
t,
p.towerHeight,
lateral,
p.towerLegWidth * .8f,
p.towerLegWidth * 1.3f, .5f,
580 for (
int i = 0; i <=
p.panels; ++i) {
581 float t =
static_cast<float>(i) /
static_cast<float>(
p.panels), tower =
t <= .5f ?
a :
b;
582 if (std::fabs(
t - tower) < .035f)
continue;
583 float fan = .7f + .3f * std::min(1.f, std::fabs(
t - tower) /
a);
585 point(tower,
p.towerHeight * fan,
lateral * (1.f - (1.f - topRatio) * fan)),
591 for (
float lateral : {-half * .75f, half * .75f})
593 point(1, -
p.deckThickness -
p.girderHeight * .5f,
lateral),
p.memberWidth,
p.girderHeight,
596 for (
int i = 0; i <
p.panels; ++i) {
597 float a0 =
static_cast<float>(i) /
static_cast<float>(
p.panels),
598 b0 =
static_cast<float>(i + 1) /
static_cast<float>(
p.panels);
599 for (
float lateral : {-half * .75f, half * .75f})
611 auto plan = BridgePlanner(
p).build();
612 if (plan.
members.size() > 16384u)
return invalid<BridgePlan>(
"bridge plan exceeds member budget");
618 return invalid<MeshBuild>(
"invalid bridge member count or cable tessellation");
620 for (
const auto&
m : plan.
members) {
622 length(
m.to -
m.from) < 1e-5f || !std::isfinite(
m.width) || !std::isfinite(
m.height) ||
m.width < .001f ||
627 return invalid<MeshBuild>(
"invalid or degenerate bridge member");
629 (!std::isfinite(
m.endWidth) || !std::isfinite(
m.endHeight) ||
m.endWidth < .001f ||
m.endHeight < .001f ||
630 m.endWidth > 1000.f ||
m.endHeight > 1000.f))
631 return invalid<MeshBuild>(
"tapered section requires bounded positive end dimensions");
635 if (
elements > 4000000u)
return invalid<MeshBuild>(
"bridge mesh exceeds element budget");
637 for (
const auto&
m : plan.
members) {
644 float travel =
length(
m.to -
m.from);
645 auto vertex = [&](V
pos, V
normal,
float u,
float v) {
649 auto quad = [&](V
a, V
b, V
c, V
d, V expected,
float u,
float v) {
650 auto base =
static_cast<std::uint32_t
>(
mesh.getVertexCount());
652 bool positive =
dot(geometric, expected) > 0.f;
653 V
normal =
unit(geometric) * (positive ? 1.f : -1.f);
659 mesh.addTriangle(base, base + 1, base + 2);
660 mesh.addTriangle(base, base + 2, base + 3);
662 mesh.addTriangle(base, base + 2, base + 1);
663 mesh.addTriangle(base, base + 3, base + 2);
666 auto box = [&](V
from, V
to,
float width,
float height,
float endWidth,
float endHeight) {
668 u1 =
up * (endHeight * .5f);
670 std::array<V, 4>
end = {
to - r1 - u1,
to + r1 - u1,
to + r1 + u1,
to - r1 + u1};
672 for (
int i = 0; i < 4; ++i)
681 float flange =
m.height * .16f,
offset = (
m.height - flange) * .5f;
684 box(
m.from,
m.to,
m.width * .18f,
m.height - 2.f * flange,
m.width * .18f,
m.height - 2.f * flange);
687 float a = 6.28318530718f *
static_cast<float>(i) /
static_cast<float>(plan.
cableSides);
688 float b = 6.28318530718f *
static_cast<float>(i + 1) /
static_cast<float>(plan.
cableSides);
689 V na =
right * std::cos(
a) +
up * std::sin(
a), nb =
right * std::cos(
b) +
up * std::sin(
b);
690 V ra = na * (
m.width * .5f), rb = nb * (
m.width * .5f);
691 auto base =
static_cast<std::uint32_t
>(
mesh.getVertexCount());
692 vertex(
m.from + ra, na, 0,
a *
m.width * .5f);
693 vertex(
m.to + ra, na, travel,
a *
m.width * .5f);
694 vertex(
m.to + rb, nb, travel,
b *
m.width * .5f);
695 vertex(
m.from + rb, nb, 0,
b *
m.width * .5f);
696 bool positive =
dot(
cross(
m.to -
m.from, rb - ra), na + nb) > 0.f;
698 mesh.addTriangle(base, base + 1, base + 2);
699 mesh.addTriangle(base, base + 2, base + 3);
701 mesh.addTriangle(base, base + 2, base + 1);
702 mesh.addTriangle(base, base + 3, base + 2);
704 auto cap = [&](V
center, V
x, V
y, V
n) {
705 auto index =
static_cast<std::uint32_t
>(
mesh.getVertexCount());
714 cap(
m.from,
m.from + ra,
m.from + rb,
forward * -1.f);
721 for (
int vertexIndex = 0; vertexIndex <
mesh.getVertexCount(); ++vertexIndex) {
722 if (!std::isfinite(
mesh.getNormalX(vertexIndex)) || !std::isfinite(
mesh.getNormalY(vertexIndex)) ||
723 !std::isfinite(
mesh.getNormalZ(vertexIndex)))
724 return invalid<MeshBuild>(
"section precision is insufficient at these world coordinates");
726 for (
int i = 0; i <
mesh.getIndexCount(); i += 3) {
727 const int a =
mesh.getIndex(i),
b =
mesh.getIndex(i + 1),
c =
mesh.getIndex(i + 2);
728 const double ux = double(
mesh.getPositionX(
b)) -
mesh.getPositionX(
a);
729 const double uy = double(
mesh.getPositionY(
b)) -
mesh.getPositionY(
a);
730 const double uz = double(
mesh.getPositionZ(
b)) -
mesh.getPositionZ(
a);
731 const double vx = double(
mesh.getPositionX(
c)) -
mesh.getPositionX(
a);
732 const double vy = double(
mesh.getPositionY(
c)) -
mesh.getPositionY(
a);
733 const double vz = double(
mesh.getPositionZ(
c)) -
mesh.getPositionZ(
a);
736 return invalid<MeshBuild>(
"section precision collapsed a generated triangle");
748 for (
const auto*
key : {
"piers",
"railings",
"markings",
"crossBracing",
"connectionDetails"}) {
750 return invalid<BridgeParameters>(
"bridge switches must be bool or exact numeric 0/1");
752 const auto type =
params.getString(
"bridgeType",
params.has(
"bridgeType") ?
"invalid" :
"beam");
754 for (
int i = 0; i < 10; ++i)
758 auto p = std::move(preset).takeValue();
759 p.start.x =
number(
"startX",
p.start.x);
760 p.start.y =
number(
"startY",
p.start.y);
761 p.start.z =
number(
"startZ",
p.start.z);
765 p.width =
number(
"deckWidth",
p.width);
766 p.sidewalkWidth =
number(
"sidewalkWidth",
p.sidewalkWidth);
767 p.deckThickness =
number(
"deckThickness",
p.deckThickness);
768 p.groundY =
number(
"groundY",
p.groundY);
769 p.memberWidth =
number(
"memberWidth",
p.memberWidth);
770 p.memberDepth =
number(
"memberDepth",
p.memberDepth);
771 p.girderHeight =
number(
"girderHeight",
p.girderHeight);
772 p.pierWidth =
number(
"pierWidth",
p.pierWidth);
773 p.pierDepth =
number(
"pierDepth",
p.pierDepth);
774 p.archRise =
number(
"archRise",
p.archRise);
775 p.archRibWidth =
number(
"archRibWidth",
p.archRibWidth);
776 p.archRibDepth =
number(
"archRibDepth",
p.archRibDepth);
777 p.towerHeight =
number(
"towerHeight",
p.towerHeight);
778 p.towerLegWidth =
number(
"towerLegWidth",
p.towerLegWidth);
779 p.trussHeight =
number(
"trussHeight",
p.trussHeight);
780 p.cableRadius =
number(
"cableRadius",
p.cableRadius);
781 p.cableSag =
number(
"cableSag",
p.cableSag);
782 p.towerInset =
number(
"towerInset",
p.towerInset);
783 p.towerTopWidthRatio =
number(
"towerTopWidthRatio",
p.towerTopWidthRatio);
784 p.railingHeight =
number(
"railingHeight",
p.railingHeight);
785 p.railingWidth =
number(
"railingWidth",
p.railingWidth);
786 p.foundationHeight =
number(
"foundationHeight",
p.foundationHeight);
787 p.foundationScale =
number(
"foundationScale",
p.foundationScale);
788 p.pierCapHeight =
number(
"pierCapHeight",
p.pierCapHeight);
789 p.abutmentDepth =
number(
"abutmentDepth",
p.abutmentDepth);
790 p.wingWallLength =
number(
"wingWallLength",
p.wingWallLength);
791 p.uvMeters =
number(
"uvMeters",
p.uvMeters);
792 p.portalInset =
number(
"portalInset",
p.portalInset);
793 p.cantileverCenterRatio =
number(
"cantileverCenterRatio",
p.cantileverCenterRatio);
794 p.spans =
count(
"spans",
p.spans);
795 p.panels =
count(
"panels",
p.panels);
796 p.curveSegments =
count(
"curveSegments",
p.curveSegments);
797 p.cableSides =
count(
"cableSides",
p.cableSides);
798 p.railingBars =
count(
"railingBars",
p.railingBars);
799 p.plankCount =
count(
"plankCount",
p.plankCount);
800 p.piers =
params.getBool(
"piers",
p.piers);
801 p.railings =
params.getBool(
"railings",
p.railings);
802 p.markings =
params.getBool(
"markings",
p.markings);
803 p.crossBracing =
params.getBool(
"crossBracing",
p.crossBracing);
804 p.connectionDetails =
params.getBool(
"connectionDetails",
p.connectionDetails);
805 if (
params.has(
"railingType")) {
806 auto name =
params.getString(
"railingType",
"invalid");
807 constexpr std::string_view names[] = {
"metal",
"concrete",
"masonry",
"timber"};
808 auto it = std::find(std::begin(names), std::end(names),
name);
809 if (it == std::end(names))
return invalid<BridgeParameters>(
"unknown railingType");
819 const auto&
p = decoded.value();
822 if (!candidate.
has(
"startX")) candidate.
setFloat(
"startX",
p.start.x);
823 if (!candidate.
has(
"startY")) candidate.
setFloat(
"startY",
p.start.y);
824 if (!candidate.
has(
"startZ")) candidate.
setFloat(
"startZ",
p.start.z);
825 if (!candidate.
has(
"endX")) candidate.
setFloat(
"endX",
p.end.x);
826 if (!candidate.
has(
"endY")) candidate.
setFloat(
"endY",
p.end.y);
827 if (!candidate.
has(
"endZ")) candidate.
setFloat(
"endZ",
p.end.z);
828 if (!candidate.
has(
"deckWidth")) candidate.
setFloat(
"deckWidth",
p.width);
829 if (!candidate.
has(
"sidewalkWidth")) candidate.
setFloat(
"sidewalkWidth",
p.sidewalkWidth);
830 if (!candidate.
has(
"deckThickness")) candidate.
setFloat(
"deckThickness",
p.deckThickness);
831 if (!candidate.
has(
"groundY")) candidate.
setFloat(
"groundY",
p.groundY);
832 if (!candidate.
has(
"memberWidth")) candidate.
setFloat(
"memberWidth",
p.memberWidth);
833 if (!candidate.
has(
"memberDepth")) candidate.
setFloat(
"memberDepth",
p.memberDepth);
834 if (!candidate.
has(
"girderHeight")) candidate.
setFloat(
"girderHeight",
p.girderHeight);
835 if (!candidate.
has(
"pierWidth")) candidate.
setFloat(
"pierWidth",
p.pierWidth);
836 if (!candidate.
has(
"pierDepth")) candidate.
setFloat(
"pierDepth",
p.pierDepth);
837 if (!candidate.
has(
"archRise")) candidate.
setFloat(
"archRise",
p.archRise);
838 if (!candidate.
has(
"archRibWidth")) candidate.
setFloat(
"archRibWidth",
p.archRibWidth);
839 if (!candidate.
has(
"archRibDepth")) candidate.
setFloat(
"archRibDepth",
p.archRibDepth);
840 if (!candidate.
has(
"towerHeight")) candidate.
setFloat(
"towerHeight",
p.towerHeight);
841 if (!candidate.
has(
"towerLegWidth")) candidate.
setFloat(
"towerLegWidth",
p.towerLegWidth);
842 if (!candidate.
has(
"trussHeight")) candidate.
setFloat(
"trussHeight",
p.trussHeight);
843 if (!candidate.
has(
"cableRadius")) candidate.
setFloat(
"cableRadius",
p.cableRadius);
844 if (!candidate.
has(
"cableSag")) candidate.
setFloat(
"cableSag",
p.cableSag);
845 if (!candidate.
has(
"towerInset")) candidate.
setFloat(
"towerInset",
p.towerInset);
846 if (!candidate.
has(
"towerTopWidthRatio")) candidate.
setFloat(
"towerTopWidthRatio",
p.towerTopWidthRatio);
847 if (!candidate.
has(
"railingHeight")) candidate.
setFloat(
"railingHeight",
p.railingHeight);
848 if (!candidate.
has(
"railingWidth")) candidate.
setFloat(
"railingWidth",
p.railingWidth);
849 if (!candidate.
has(
"foundationHeight")) candidate.
setFloat(
"foundationHeight",
p.foundationHeight);
850 if (!candidate.
has(
"foundationScale")) candidate.
setFloat(
"foundationScale",
p.foundationScale);
851 if (!candidate.
has(
"pierCapHeight")) candidate.
setFloat(
"pierCapHeight",
p.pierCapHeight);
852 if (!candidate.
has(
"abutmentDepth")) candidate.
setFloat(
"abutmentDepth",
p.abutmentDepth);
853 if (!candidate.
has(
"wingWallLength")) candidate.
setFloat(
"wingWallLength",
p.wingWallLength);
854 if (!candidate.
has(
"uvMeters")) candidate.
setFloat(
"uvMeters",
p.uvMeters);
855 if (!candidate.
has(
"portalInset")) candidate.
setFloat(
"portalInset",
p.portalInset);
856 if (!candidate.
has(
"cantileverCenterRatio")) candidate.
setFloat(
"cantileverCenterRatio",
p.cantileverCenterRatio);
857 if (!candidate.
has(
"spans")) candidate.
setInt(
"spans",
p.spans);
858 if (!candidate.
has(
"panels")) candidate.
setInt(
"panels",
p.panels);
859 if (!candidate.
has(
"curveSegments")) candidate.
setInt(
"curveSegments",
p.curveSegments);
860 if (!candidate.
has(
"cableSides")) candidate.
setInt(
"cableSides",
p.cableSides);
861 if (!candidate.
has(
"railingBars")) candidate.
setInt(
"railingBars",
p.railingBars);
862 if (!candidate.
has(
"plankCount")) candidate.
setInt(
"plankCount",
p.plankCount);
863 if (!candidate.
has(
"piers")) candidate.
setBool(
"piers",
p.piers);
864 if (!candidate.
has(
"railings")) candidate.
setBool(
"railings",
p.railings);
865 if (!candidate.
has(
"markings")) candidate.
setBool(
"markings",
p.markings);
866 if (!candidate.
has(
"crossBracing")) candidate.
setBool(
"crossBracing",
p.crossBracing);
867 if (!candidate.
has(
"connectionDetails")) candidate.
setBool(
"connectionDetails",
p.connectionDetails);
868 constexpr std::string_view railingNames[] = {
"metal",
"concrete",
"masonry",
"timber"};
869 if (!candidate.
has(
"railingType"))
870 candidate.
setString(
"railingType", std::string(railingNames[
static_cast<unsigned>(
p.railing)]));
871 params = std::move(candidate);
std::array< float, 3 > position
std::array< uint32_t, 16 > material
std::array< uint32_t, 9 > parameters
float(ui::Theme::* member)[4]
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
static Result success(T value)
Construct a successful result owning value.
static Result failure(Status status)
Construct a failed result from a structured status.
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
int setActiveGroup(const std::string &name)
Select/create the named group assigned to subsequently added triangles.
Owning, typed generation parameters.
void setInt(const std::string &key, int value)
Store an Int64 parameter, preserving its numeric Value kind.
void setBool(const std::string &key, bool value)
Stores a boolean generation parameter.
bool has(const std::string &key) const
Return whether a parameter or one of the three dimensions exists.
void setFloat(const std::string &key, float value)
Store a finite or non-finite floating parameter as Value::Double without text conversion.
void setString(const std::string &key, const std::string &value)
Store an owning string parameter as Value::String.
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
ForceVector add(ForceVector a, ForceVector b)
Result< int > invalid(std::string message)
Invalid.
V3 operator+(V3 a, V3 b)
Module-private road bake implementation helper.
V3 cross(V3 a, V3 b)
Module-private road bake implementation helper.
V3 operator-(V3 a, V3 b)
Module-private road bake implementation helper.
V3 operator*(V3 a, float s)
Module-private road bake implementation helper.
float dot(V3 a, V3 b)
Module-private road bake implementation helper.
BridgeSection
Section construction shared by all bridge topologies.
BridgeMaterial
Orthogonal surface classification carried by each generated member.
BridgeRailing
Editable edge protection rule; presets select the reference's construction.
Result< BridgePlan > planBridge(const BridgeParameters &p)
Plan the selected topology without renderer or terrain providers.
Result< BridgeParameters > bridgePreset(BridgeKind kind)
Return an owning reference-aligned preset; unsupported kinds fail without side effects.
Result< void > applyBridgeRecipeDefaults(Params ¶ms)
Atomically fill absent recipe parameters from the selected bridge preset.
Result< MeshBuild > bakeBridge(const BridgePlan &plan)
Bake a validated member plan into independent CPU geometry; upload separately.
Result< BridgeParameters > bridgeParametersFromParams(const Params ¶ms)
Decode recipe parameters into an owning typed authoring value.
std::string_view bridgeMaterialName(BridgeMaterial material) noexcept
Static surface name, or an empty view for an unknown enum; process-lifetime storage,...
std::string_view bridgePartName(BridgePart part) noexcept
Static semantic name, or an empty view for an unknown enum; process-lifetime storage,...
BridgePart
Semantic mesh groups, independent of graphics materials.
std::string_view bridgeKindName(BridgeKind kind) noexcept
Static protocol name, or an empty view for an unknown enum; process-lifetime storage,...
BridgeKind
Visual bridge topology presets; geometry generation performs no structural load analysis.
void validate(const RuntimeTensor &v)
Validate.
Owned bounded authoring parameters; all dimensions are metres, counts are deterministic.
Transient owning member plan; edit members to customize logic before baking. Not a persistent format.
std::vector< BridgeMember > members