载入中...
搜索中...
未找到
RoadNetworkRecipes.cpp
浏览该文件的文档.
54 network.addEdge(incomingStart.value(), hub.value(), {P(-9.f, 0.f, -3.f), P(0.f, 0.f, 0.f)}, lanes, 0, style);
56 network.addEdge(hub.value(), outgoingEnd.value(), {P(0.f, 0.f, 0.f), P(-9.f, 0.f, 3.f)}, lanes, 0, style);
60 {incoming.value(), 0, outgoing.value(), 0, RoadLaneDirection::Forward, RoadLaneDirection::Forward});
84 auto incoming = network.addEdge(stem.value(), hub.value(), {P(0.f, 0.f, 24.f), P(0.f, 0.f, 0.f)}, lanes,
86 auto west = network.addEdge(hub.value(), left.value(), {P(0.f, 0.f, 0.f), P(-18.f, 0.f, yJunction ? -18.f : 0.f)},
88 auto east = network.addEdge(hub.value(), right.value(), {P(0.f, 0.f, 0.f), P(18.f, 0.f, yJunction ? -18.f : 0.f)},
101 DiagnosticCode::InvalidArgument, "lanes in [1,4] required", curved ? "curve-uphill" : "sloped-t"));
113 curved ? std::vector<RoadControlPoint>{P(-22.f, 0.f, 12.f), P(-13.f, 1.4f, 14.f), P(-6.f, 3.f, 7.f),
117 curved ? std::vector<RoadControlPoint>{P(-20.f, 7.f, -14.f), P(-12.f, 6.4f, -16.f), P(-5.f, 5.f, -7.f),
122 auto exitEdge = network.addEdge(hub.value(), exit.value(), {P(0.f, 4.f, 0.f), P(24.f, 4.f, 0.f)},
137 Diagnostic::error(DiagnosticCode::InvalidArgument, "length>=8, lanes in [1,4] required", "straight"));
153 Diagnostic::error(DiagnosticCode::InvalidArgument, "radius>=8, lanes in [1,4] required", "curve"));
168 if (!std::isfinite(length) || length < 12.f || !std::isfinite(height) || height < 2.f || lanes < 1 || lanes > 4)
189 Diagnostic::error(DiagnosticCode::InvalidArgument, "span>=16, lanes in [1,4] required", "cross"));
212 auto e1 = network.addEdge(nN.value(), nC.value(), {P(0.f, 0.f, -half), P(0.f, 0.f, 0.f)}, lanes, 0, style);
213 auto e2 = network.addEdge(nC.value(), nS.value(), {P(0.f, 0.f, 0.f), P(0.f, 0.f, half)}, lanes, 0, style);
214 auto e3 = network.addEdge(nW.value(), nC.value(), {P(-half, 0.f, 0.f), P(0.f, 0.f, 0.f)}, lanes, 0, style);
227 Diagnostic::error(DiagnosticCode::InvalidArgument, "span>=16, lanes in [1,4] required", "tee"));
267 Diagnostic::error(DiagnosticCode::InvalidArgument, "span>=16, lanes in [1,4] required", "fan"));
270 Diagnostic::error(DiagnosticCode::InvalidArgument, "fan needs at least two arm angles", "fan"));
273 Diagnostic::error(DiagnosticCode::InvalidArgument, "intoHub size must match armAnglesDeg", "fan"));
292 for (std::size_t index = 0; index < specs.size(); ++index) specs[index].intoHub = index % 2u == 0u;
296 if (unique.empty() || std::fabs(spec.degrees - unique.back().degrees) > 1.f) unique.push_back(spec);
297 if (unique.size() >= 2u && std::fabs(unique.front().degrees + 360.f - unique.back().degrees) <= 1.f)
301 Diagnostic::error(DiagnosticCode::InvalidArgument, "fan needs at least two distinct arm angles", "fan"));
331Result<RoadNetwork> RoadNetwork::makeFork(float span, int lanes) { return makeFan(span, lanes, {60.f, 120.f, 270.f}); }
333Result<RoadNetwork> RoadNetwork::makeSkew(float span, int lanes) { return makeFan(span, lanes, {0.f, 135.f, 270.f}); }
338 Diagnostic::error(DiagnosticCode::InvalidArgument, "span>=32, lanes in [1,3] required", "roundabout"));
350 auto node = network.addNode(std::cos(angle) * ringRadius, 0.f, std::sin(angle) * ringRadius, seamRadius);
378 auto outer = network.addNode(std::cos(angle) * outerRadius, 0.f, std::sin(angle) * outerRadius, 2.f);
394Result<RoadNetwork> RoadNetwork::makeScene(const std::string& scene, float span, float bridgeHeight, int lanes,
409 if (scene == "interchange" || scene.empty()) return makeInterchange(span, bridgeHeight, lanes, seed);
418Result<RoadNetwork> RoadNetwork::makeInterchange(float span, float bridgeHeight, int lanes, std::uint32_t seed) {
419 if (!std::isfinite(span) || span < 16.f || !std::isfinite(bridgeHeight) || bridgeHeight < 1.f || lanes < 1 ||
422 DiagnosticCode::InvalidArgument, "span>=16, bridgeHeight>=1, lanes in [1,4] required", "interchange"));
464 auto add = [&](std::uint32_t a, std::uint32_t b, std::vector<RoadControlPoint> pts, const RoadStyle& style) {
486 {P(0.f, 0.f, -half), P(-half * 0.35f, h * 0.2f, -half), P(-half * 0.75f, h * 0.75f, -half), P(-half, h, -half)},
490 {P(-half, 0.f, 0.f), P(-half, h * 0.2f, -half * 0.35f), P(-half, h * 0.75f, -half * 0.75f), P(-half, h, -half)},
494 {P(half, h, half), P(half * 0.75f, h * 0.75f, half), P(half * 0.35f, h * 0.2f, half), P(0.f, 0.f, half)}, 1, 1,
498 {P(half, h, half), P(half, h * 0.75f, half * 0.75f), P(half, h * 0.2f, half * 0.35f), P(half, 0.f, 0.f)}, 1, 1,
509 for (const auto node : {nN.value(), nW.value(), nBridgeNW.value(), nBridgeSE.value(), nS.value(), nE.value()}) {
Stable, structured diagnostics shared by engine modules.
std::vector< std::vector< CompiledStatement > > lanes
Parallel lane bodies (parallel { lane {…} lane {…} }).
Definition DnutCompiler.cpp:36
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Owning directed road graph with lane connectivity.
Definition RoadNetwork.h:19
static Result< RoadNetwork > makeStraight(float length=36.f, int lanes=2)
Scene 1: single flat straight segment (no junction).
Definition RoadNetworkRecipes.cpp:134
static Result< RoadNetwork > makeCross(float span=32.f, int lanes=2)
Scene 4: simple ground-level 4-way cross (one junction disc).
Definition RoadNetworkRecipes.cpp:186
static Result< RoadNetwork > makeInterchange(float span=48.f, float bridgeHeight=8.f, int lanes=2, std::uint32_t seed=1)
Build a multi-level interchange demo graph (ground cross + elevated loop + ramps).
Definition RoadNetworkRecipes.cpp:418
static Result< RoadNetwork > makeBridge(float length=36.f, float height=6.f, int lanes=2)
Scene 3: elevated straight with piers.
Definition RoadNetworkRecipes.cpp:167
static Result< RoadNetwork > makeY(float span=32.f, int lanes=2)
Ground-level Y-junction with three arms separated by 120 degrees.
Definition RoadNetworkRecipes.cpp:256
static Result< RoadNetwork > makeFork(float span=32.f, int lanes=2)
Three-way scene with a 60-degree acute fork.
Definition RoadNetworkRecipes.cpp:331
static Result< RoadNetwork > makeSkew(float span=32.f, int lanes=2)
Three-way scene with 135-degree skew corners.
Definition RoadNetworkRecipes.cpp:333
Result< void > setNodeJunctionControl(std::uint32_t nodeId, RoadJunctionControl control)
Replace one node's authoritative traffic-control policy.
Definition RoadNetwork.cpp:553
Result< std::uint32_t > addEdge(std::uint32_t from, std::uint32_t to, std::vector< RoadControlPoint > controlPoints, int lanesForward=2, int lanesBackward=0, RoadStyle style={})
Insert a non-degenerate directed edge between two distinct live nodes.
Definition RoadNetwork.cpp:170
static Result< RoadNetwork > makeRoundabout(float span=48.f, int lanes=1)
Build a four-entry roundabout from ordinary nodes, curved edges and lane links.
Definition RoadNetworkRecipes.cpp:335
static Result< RoadNetwork > makeScene(const std::string &scene, float span=36.f, float bridgeHeight=6.f, int lanes=2, std::uint32_t seed=1)
Dispatch a named debug/demo scene.
Definition RoadNetworkRecipes.cpp:394
static Result< RoadNetwork > makeFan(float span, int lanes, std::vector< float > armAnglesDeg, std::vector< bool > intoHub={})
Build a ground-level N-way fan from absolute arm angles in degrees.
Definition RoadNetworkRecipes.cpp:263
Result< int > connectAllTurns(std::uint32_t nodeId)
Auto-connect all forward and backward lane ports at one node.
Definition RoadNetwork.cpp:351
Result< std::uint32_t > addNode(float x, float y, float z, float junctionRadius=6.f)
Insert a junction node after validating finite coordinates.
Definition RoadNetwork.cpp:136
static Result< RoadNetwork > makeTee(float span=32.f, int lanes=2)
Ground-level T-junction with an east-west through road and south stem.
Definition RoadNetworkRecipes.cpp:224
static Result< RoadNetwork > makeCurve(float radius=18.f, int lanes=2)
Scene 2: gentle horizontal curve (no junction).
Definition RoadNetworkRecipes.cpp:150
Definition TerrainWorldWorkspace.h:12
@ Yield
Lower-priority approaches yield; equal-priority approaches all yield.
@ InvalidArgument
One authored control point on a road centerline (world space, Y-up).
Definition RoadTypes.h:19
Owning cross-section, width policy and structural authoring for one road edge.
Definition RoadTypes.h:182
int trafficPriority
Higher incoming-road values win uncontrolled junction priority.
Definition RoadTypes.h:214