载入中...
搜索中...
未找到
RoadBakePlacements.cpp
浏览该文件的文档.
24Result<void> bakePlacementPoints(PointSet& placements, const RoadNetwork& network, const RoadBakeOptions& options,
27 const bool needsTerrain = std::any_of(network.edges().begin(), network.edges().end(), [](const RoadEdge& edge) {
35 return bakeFail<void>(DiagnosticCode::Unsupported, "side-object terrain snapping requires IProcgenWorldQuery",
39 const bool needsAssets = std::any_of(network.edges().begin(), network.edges().end(), [](const RoadEdge& edge) {
40 return edge.style.sideTerrain.asset.has_value() && (edge.style.sideObjectsLeft || edge.style.sideObjectsRight);
44 return bakeFail<void>(DiagnosticCode::Unsupported, "side-object prefab bounds require IProcgenAssetBounds",
46 std::map<std::tuple<eve::PersistentId, eve::PersistentId, eve::PrefabRootPose>, std::array<float, 6>>
56 auto resolved = assetBounds->localBounds(rule.asset->asset, rule.asset->buildId, rule.asset->rootPose);
77 !std::isfinite(options.sideObjectOffset) || options.sideObjectOffset < 0.f || options.maximumPlacements < 1)
78 return bakeFail<void>(DiagnosticCode::InvalidArgument, "road placement options are invalid", "placements");
96 for (const auto& node : network.nodes()) adjacency.emplace(node.id, std::vector<std::uint32_t>{});
199 const int arcSamples = edge.style.sideObjectDistribution == RoadSideDistribution::LegacyCentered ? 32 : 512;
205 const bool followsSurface = edge.style.sidePlacement.pathSampling == RoadSidePathSampling::SurfaceSegments;
225 sideEnd = std::min(sideEnd, length - junctionSocketDistance(network, node.value(), edge, length));
231 // Geometry intentionally omitted the whole edge inside its sockets; no visible facilities exist.
241 if ((edge.style.sideObjectsLeft || edge.style.sideObjectsRight) && placementLength > firstSideDistance) {
250 integral + ((fraction > .5f || (fraction == .5f && std::fmod(integral, 2.f) != 0.f)) ? 1.f : 0.f);
268 sources.push_back({&edge, std::move(spline).takeValue(), length, profile.value().halfWidth, sideStart, sideEnd,
287 std::count_if(cycle.begin(), cycle.end(), [&](std::uint32_t id) { return adjacency[id].size() == 3u; }));
294 placements.setPointSeed(row, deriveSeed(roundaboutId, std::string(role) + std::to_string(node.id)));
305 return placements.trySetVectorAttribute(row, "road_direction", heading.x, heading.y, heading.z);
312 auto status = appendRoundaboutPoint(center, V3{0.f, 0.f, 1.f}, "junction.roundabout.center", 1u);
325 status = appendRoundaboutPoint(node, normalize(heading), "junction.roundabout.entry", entryOrdinal++);
380 auto status = placements.trySetPointId(row, derivePointId(0x4a554e4300000000ull | node.id, 1u));
386 status = placements.trySetIntAttribute(row, "road_arm_count", static_cast<std::int64_t>(directions.size()));
390 status = placements.trySetVectorAttribute(row, "road_direction", heading.x, heading.y, heading.z);
396 placements.add(node.x + heading.x * islandDistance, node.y, node.z + heading.z * islandDistance);
401 status = placements.trySetPointId(islandRow, derivePointId(0x4a554e4300000000ull | node.id, 2u));
411 status = placements.trySetVectorAttribute(islandRow, "road_direction", heading.x, heading.y, heading.z);
439 V3 point{f.sample.x + f.sideX * lateral, f.sample.y + f.sideY * lateral, f.sample.z + f.sideZ * lateral};
442 sampleSurfaceProfilePoint(*source.surface, distance, profileSide, asphaltHalfWidth(*source.edge));
484 const V3 up0{std::sin(yaw) * std::sin(pitch), std::cos(pitch), std::cos(yaw) * std::sin(pitch)};
506 auto closest = other.surface ? closestSurfacePolyline(*other.surface, point.x, point.y, point.z)
517 if (length(point - accepted) < options.sideObjectClearance) return Result<bool>::success(false);
535 placements.setPointSeed(row, deriveSeed(source.edge->id, std::string(role) + std::to_string(ordinal)));
546 auto clearance = placements.trySetFloatAttribute(row, "road_clearance", options.sideObjectClearance);
566 const bool legacy = source.edge->style.sideObjectDistribution == RoadSideDistribution::LegacyCentered;
570 // Preserve historical cumulative float additions and its open end, including its budget upper bound.
Stable, structured diagnostics shared by engine modules.
std::map< std::string, std::vector< size_t > > adjacency
Definition McpArchitectureTools.cpp:26
std::vector< std::pair< std::uint64_t, OceanBoatReceipt > > sources
Definition OceanSprayBindings.cpp:21
const T & value() const &
Borrow the value from a const lvalue after checking success.
Definition Result.h:339
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Owning multi-segment 3D spline with deterministic bounded sampling.
Definition SplinePath.h:118
Owning directed road graph with lane connectivity.
Definition RoadNetwork.h:19
float asphaltHalfWidth(const RoadEdge &edge)
Module-private road bake implementation helper.
Definition RoadBake.cpp:100
float scaledProfileSide(float side, float asphaltHalf, float scale)
Module-private transverse width transform preserving fixed-width shoulders.
Definition RoadBake.cpp:114
Result< SplineSample > closestSurfacePolyline(const RoadSurfacePolyline &path, float x, float y, float z)
Closest owned center sample for collision checks, linear in retained road rows.
Definition RoadSurfacePath.cpp:102
Result< SplinePath > edgeToSpline(const RoadEdge &edge)
Module-private road bake implementation helper.
Definition RoadBake.cpp:62
Result< SplineFrameSample > sampleSurfacePolyline(const RoadSurfacePolyline &path, float distance)
Sample one owned frame by segment direction; endpoints extrapolate, widths clamp to endpoint values....
Definition RoadSurfacePath.cpp:34
Result< V3 > sideTerrainNormal(eve::IProcgenWorldQuery &query, float x, float z, const RoadBakeOptions &options, std::size_t &work)
Borrow the center surface normal with the same network-wide projection budget; no retained provider.
Definition RoadPlacementTerrain.cpp:7
float junctionSocketDistance(const RoadNetwork &network, const RoadNode &node, const RoadEdge &edge, float pathLength)
Module-private road bake implementation helper.
Definition RoadBake.cpp:146
Result< V3 > sampleSurfaceProfilePoint(const RoadSurfacePolyline &path, float distance, float side, float asphaltHalf)
Sample a profile-side offset from actual retained row vectors and widths, not a reconstructed normal....
Definition RoadSurfacePath.cpp:82
Result< void > bakeTrafficControlPoints(PointSet &placements, const RoadNetwork &network, const RoadBakeOptions &options)
Definition RoadTraffic.cpp:35
Result< void > bakePlacementPoints(PointSet &placements, const RoadNetwork &network, const RoadBakeOptions &options, const std::unordered_set< std::uint32_t > &activeJunctionNodes, RoadFrameCache &frameCache)
Module-private road bake implementation helper.
Definition RoadBakePlacements.cpp:24
Result< RoadSurfacePolyline > prepareSurfacePolyline(std::span< const SplineFrameSample > frames)
Prepare a bounded piecewise road-center metric; rejects degenerate segments without publishing output...
Definition RoadSurfacePath.cpp:7
Result< float > sideTerrainHeight(const RoadSideTerrainRule &rule, eve::IProcgenWorldQuery &query, float x, float z, const ProcgenPoint &pose, const std::array< float, 6 > *assetBounds, const RoadBakeOptions &options, std::size_t &work)
Bounded height-only projection; provider and options are borrowed synchronously, no callbacks retaine...
Definition RoadPlacementTerrain.cpp:31
Result< RoadProfile > makeRoadProfile(const RoadStyle &style, int lanesForward, int lanesBackward)
Build a mathematical road cross-section for the given lane counts.
Definition RoadProfile.cpp:55
@ AsphaltEdges
@ SurfaceSegments
@ PathForward
@ TerrainNormal
@ LegacyCentered
std::uint64_t derivePointId(std::uint64_t namespaceId, std::uint64_t ordinal)
Deterministically derive a non-zero stable point identity.
Definition PointSet.cpp:470
uint32_t deriveSeed(uint32_t parent, const std::string &scope)
Stable label-based seed derivation; independent pipeline branches do not perturb each other.
Definition PointSet.cpp:460
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:870
@ InvalidArgument
@ PreconditionViolation
@ Unsupported
@ Authored
Definition Container.h:602
Options for baking a road network into mesh + navigation overlays.
Definition RoadBake.h:50
Directed centerline edge with optional reverse lanes.
Definition RoadTypes.h:286