载入中...
搜索中...
未找到
RoadFacilityPrefab.cpp
浏览该文件的文档.
16 return {std::lerp(a.x, b.x, t), std::lerp(a.y, b.y, t), std::lerp(a.z, b.z, t), std::lerp(a.nx, b.nx, t),
17 std::lerp(a.ny, b.ny, t), std::lerp(a.nz, b.nz, t), std::lerp(a.u, b.u, t), std::lerp(a.v, b.v, t)};
19std::vector<RoadPrefabVertex> clip(const std::vector<RoadPrefabVertex>& polygon, float plane, bool above) {
26 if (inside != wasInside) out.push_back(mix(previous, current, (plane - previous.z) / (current.z - previous.z)));
33V3 position(const SplineFrameSample& a, const SplineFrameSample& b, const RoadPrefabVertex& v, float t) {
35 normalize(V3{std::lerp(a.sideX, b.sideX, t), std::lerp(a.sideY, b.sideY, t), std::lerp(a.sideZ, b.sideZ, t)});
36 const V3 up = normalize(V3{std::lerp(a.upX, b.upX, t), std::lerp(a.upY, b.upY, t), std::lerp(a.upZ, b.upZ, t)});
43 if (!std::isfinite(p.repeatSourceLength) || p.repeatSourceLength < 0.f || p.repeatSourceLength > 10000000.f)
45 if (!std::isfinite(p.length) || p.length <= 1e-4f || p.length > 10000.f || !std::isfinite(p.sourceStart) ||
46 !std::isfinite(p.sourceEnd) || p.sourceStart < 0.f || p.sourceEnd > 1.f || p.sourceStart >= p.sourceEnd)
52 p.weldCompatibleVertices || p.automaticSpacing || !p.averageSpacing || p.reverseRepeatSequence ||
57 if (p.middleCopies < 1 || p.middleCopies > 4096 || p.assetId.empty() || p.assetId.size() > 256u ||
58 p.vertices.size() > 65536u || p.triangles.empty() || p.triangles.size() > 131072u || !std::isfinite(p.length) ||
59 p.length <= 1e-4f || p.length > 10000.f || !std::isfinite(p.sourceStart) || !std::isfinite(p.sourceEnd) ||
63 if (!std::isfinite(v.x) || !std::isfinite(v.y) || !std::isfinite(v.z) || std::fabs(v.x) > 10000.f ||
64 std::fabs(v.y) > 10000.f || v.z < 0.f || v.z > p.length || !std::isfinite(v.nx) || !std::isfinite(v.ny) ||
65 !std::isfinite(v.nz) || std::fabs(length(V3{v.nx, v.ny, v.nz}) - 1.f) > 1e-3f || !std::isfinite(v.u) ||
98 if (frames.size() < 2 || sourceHigh - sourceLow <= 1e-5f) return invalidPrefab("degenerate deformation interval");
102 const float span = prefab.repeatSourceLength > 0.f ? prefab.repeatSourceLength : fullSourceLength;
108 const double count = std::max(1.0, prefab.averageSpacing ? std::round(ratio) : std::ceil(ratio));
117 return bakeFail<void>(DiagnosticCode::PreconditionViolation, "prefab tessellation exceeds work budget",
119 const float begin = frames.front().sample.normalizedDistance, end = frames.back().sample.normalizedDistance;
128 parts.push_back({&prefab.startMesh.vertices, &prefab.startMesh.triangles, total, prefab.startMesh.length,
142 parts.push_back({&prefab.endMesh.vertices, &prefab.endMesh.triangles, total, prefab.endMesh.length,
155 if (length(V3{b.sample.x - a.sample.x, b.sample.y - a.sample.y, b.sample.z - a.sample.z}) <= 1e-5f) continue;
157 std::lerp(sourceLow, sourceHigh, (a.sample.normalizedDistance - begin) / (end - begin)) * total;
159 std::lerp(sourceLow, sourceHigh, (b.sample.normalizedDistance - begin) / (end - begin)) * total;
242 if (length(smooth.sum) <= 1e-7f) return invalidPrefab("smoothing group has cancelling face normals");
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
Definition MeshBuild.h:20
Result< void > bakeFacilityPrefab(MeshBuild &mesh, const RoadFacilityPrefab &prefab, const std::vector< SplineFrameSample > &frames, float sourceLow, float sourceHigh, float fullSourceLength, std::size_t budget)
Clip source triangles into frame slabs and deform their positions and inverse-transpose normals.
Definition RoadFacilityPrefab.cpp:93
Result< void > validateFacilityPrefab(const RoadFacilityPrefab &prefab)
Validate finite source mesh topology and bounded source ranges.
Definition RoadFacilityPrefab.cpp:42
const char * roadMaterialGroup(RoadMaterial material) noexcept
Map a material tag to the MeshBuild group name used by the baker. @ownership borrowed — returns a poi...
Definition RoadProfile.cpp:37
@ TunnelPortalAsphalt
Driving surface inside an authored tunnel portal footprint.
@ InvalidArgument
@ PreconditionViolation
Owned prefab mesh; local Z in [0,length] deforms along the facility arc. Source range preserves cut g...
Definition RoadTypes.h:94
Owned source vertex in prefab-local (side, up, forward) axes, with normal and UV.
Definition RoadTypes.h:72