载入中...
搜索中...
未找到
RoadTypes.h
浏览该文件的文档.
1#pragma once
2
3#include <optional>
6#include "common/Result.h"
8
9#include <cstdint>
10#include <string>
11#include <vector>
12
13namespace eve::procgen::road {
14
16enum class RoadPathControl : std::uint8_t { Spline = 0, StraightXZ = 1, StraightXYZ = 2, Circular = 3 };
17
20 float x = 0.f;
21 float y = 0.f;
22 float z = 0.f;
23 float widthScale =
24 1.f;
26 0.f;
27 float splineStrength = .5f;
29 bool alignStraightStart = true,
31 false;
32 bool circularFromEnd = false;
33 float rollCenterOffset = 0.f;
34};
35
37enum class RoadMaterial : std::uint8_t {
38 Asphalt = 0,
39 Curb,
41 Deck,
42 Pier,
43 Marking,
45 Nav,
48 Tunnel,
50};
51
58
60enum class RoadStructureKind : std::uint8_t { Bridge = 0, Tunnel = 1 };
61
70
73 float x = 0.f, y = 0.f, z = 0.f;
74 float nx = 0.f, ny = 1.f, nz = 0.f;
75 float u = 0.f, v = 0.f;
76};
79 std::uint32_t a = 0, b = 0, c = 0;
81 std::uint32_t smoothingGroup =
82 0;
83};
86 std::string assetId;
87 float length = 1.f;
88 std::vector<RoadPrefabVertex> vertices;
89 std::vector<RoadPrefabTriangle> triangles;
90};
96 int middleCopies = 1;
99 false;
100 bool averageSpacing = true;
103 false;
105 0.f;
106 std::string assetId;
107 float length = 1.f, sourceStart = 0.f, sourceEnd = 1.f;
108 std::vector<RoadPrefabVertex> vertices;
109 std::vector<RoadPrefabTriangle> triangles;
110};
114 std::uint32_t id = 1;
115 float start = 0.f, end = 1.f;
116 float lateralOffset = 0.f;
117 float verticalOffset = 0.f;
118 std::vector<RoadProfilePoint> profile;
119 bool capStart = true, capEnd = true;
120 float uvMeters = 2.f;
121};
122
125enum class RoadSideTerrainMode : std::uint8_t { None = 0, Center = 1, Lowest = 2, Highest = 3, Average = 4 };
127enum class RoadSideAlignment : std::uint8_t { None = 0, TerrainNormal = 1, PathForward = 2, PathNormal = 3 };
147
149enum class RoadWidthInterpolation : std::uint8_t { Linear = 0, CatmullRom = 1 };
151enum class RoadFrameOrientation : std::uint8_t { ParallelTransport = 0, WorldUp = 1 };
153enum class RoadRollInterpolation : std::uint8_t { Linear = 0, SmoothStep = 1 };
158enum class RoadSideDistribution : std::uint8_t { LegacyCentered = 0, Fixed = 1, Average = 2 };
160enum class RoadSideReference : std::uint8_t { LegacyOutside = 0, AsphaltEdges = 1, Center = 2 };
162enum class RoadSidePathSampling : std::uint8_t { Analytic = 0, SurfaceSegments = 1 };
179enum class RoadSamplingPolicy : std::uint8_t { MaximumIntervals = 0, ParametricDistanceTurn = 1 };
180
182struct RoadStyle {
192 std::vector<RoadProfilePoint> crossSection;
193 bool crossSectionClosed = false;
195 std::vector<RoadStructureInterval>
197 std::vector<RoadContinuousFacility> facilities;
198
199 float laneWidth = 3.5f;
200 float curbWidth = 0.45f;
201 float curbHeight = 0.55f;
202 float sidewalkWidth = 1.5f;
203 float sidewalkHeight = 0.14f;
204 float deckThickness = 0.70f;
205 float pierWidth = 1.35f;
206 float pierDepth = 1.35f;
207 float pierSpacing = 11.f;
208 float pierClearance = 1.5f;
209 float markingWidth = 0.22f;
210 float dashLength = 3.5f;
211 float dashGap = 3.f;
212 float uvMeters = 8.f;
213 float speedLimitMps = 13.8889f;
219 bool sideObjectsLeft = true;
220 bool sideObjectsRight = true;
222 2.f;
223 float samplingAngleDegrees = 45.f;
229};
230
232enum class RoadJunctionControl : std::uint8_t {
233 Uncontrolled = 0,
234 Yield,
235 Stop,
236 Signal,
237};
238
241 float x = 0.f, y = 0.f, z = 0.f;
242 float nx = 0.f, ny = 1.f, nz = 0.f;
243 float u = 0.f, v = 0.f;
244};
247 std::uint32_t a = 0, b = 0, c = 0;
249};
252 std::uint32_t id = 1, edgeId = 0;
253 float x = 0.f, y = 0.f, z = 0.f;
254 float forwardX = 1.f, forwardY = 0.f, forwardZ = 0.f;
255 float upX = 0.f, upY = 1.f, upZ = 0.f;
256 bool sectionClosed = false;
257 std::vector<RoadProfilePoint> section;
258};
263 std::uint32_t firstEdge = 0, firstFacility = 0, secondEdge = 0, secondFacility = 0;
264};
267 std::vector<RoadFacilityRoute> facilityRoutes;
268 std::string assetId;
269 float yawDegrees = 0.f;
270 std::vector<RoadConnectionVertex> vertices;
271 std::vector<RoadConnectionTriangle> triangles;
272 std::vector<RoadConnectionPort> ports;
273};
275struct RoadNode {
276 std::uint32_t id = 0;
277 float x = 0.f;
278 float y = 0.f;
279 float z = 0.f;
280 float junctionRadius = 6.f;
283};
284
286struct RoadEdge {
287 std::uint32_t id = 0;
288 std::uint32_t from = 0;
289 std::uint32_t to = 0;
290 std::vector<RoadControlPoint> controlPoints;
294};
295
298 std::uint32_t nodeId = 0;
299 std::uint32_t firstEdgeId = 0;
300 std::uint32_t secondEdgeId = 0;
301};
302
304enum class RoadLaneDirection : std::uint8_t {
305 Forward = 0,
306 Backward,
307};
308
323
326 std::vector<float> xyz;
327 float r = 0.2f, g = 0.85f, b = 1.f, a = 1.f;
328 float width = 0.08f;
329 bool closed = false;
330 std::uint32_t inEdge = 0;
331 std::uint32_t outEdge = 0;
332 int inLane = -1;
333 int outLane = -1;
336 float speedLimitMps = 0.f;
338};
339
342 std::vector<RoadPolyline> lanes;
343 std::vector<RoadPolyline> turns;
344};
345
348 std::vector<RoadProfilePoint> points;
349 float halfWidth = 0.f;
350 bool closed = false;
351 bool explicitMaterials = false;
352};
353
362[[nodiscard]] EVENGINE_API_DOMAINS Result<RoadProfile> makeRoadProfile(const RoadStyle& style, int lanesForward,
363 int lanesBackward);
364
370[[nodiscard]] EVENGINE_API_DOMAINS const char* roadMaterialGroup(RoadMaterial material) noexcept;
371
372} // namespace eve::procgen::road
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::array< uint32_t, 16 > material
Strong asset, definition, object and generic resource references.
Move-only, checked operation results for the common layer.
Stable asset identity backed by PersistentId.
Definition ResourceRef.h:53
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Id128 public API.
Definition Identity.h:111
RoadSideTerrainMode
Height-only ground projection of generic side-object anchors; bounds are local horizontal footprint m...
Definition RoadTypes.h:125
Result< RoadProfile > makeRoadProfile(const RoadStyle &style, int lanesForward, int lanesBackward)
Build a mathematical road cross-section for the given lane counts.
RoadJunctionControl
Authoritative traffic-control policy applied to every approach of one junction node.
Definition RoadTypes.h:232
@ Signal
Every incoming approach is controlled by a traffic signal.
@ Stop
Every incoming approach receives a stop control.
@ Uncontrolled
Edge trafficPriority resolves right-of-way without a mandatory stop.
@ Yield
Lower-priority approaches yield; equal-priority approaches all yield.
const char * roadMaterialGroup(RoadMaterial material) noexcept
Map a material tag to the MeshBuild group name used by the baker. @ownership borrowed — returns a poi...
RoadRollInterpolation
Crossfall interpolation between authored markers.
Definition RoadTypes.h:153
RoadSideReference
Lateral origin for rigid facilities; LegacyOutside retains historical bake-option offsets.
Definition RoadTypes.h:160
RoadSidePathSampling
Facility path policy; SurfaceSegments follows the road's retained section centers and segment directi...
Definition RoadTypes.h:162
RoadPathControl
Outgoing road span controller; StraightXZ retains smooth height, StraightXYZ is fully linear.
Definition RoadTypes.h:16
RoadSideAlignment
Owned side-instance orientation rule; height selection remains independently authored.
Definition RoadTypes.h:127
RoadWidthInterpolation
Cross-section and structural style for one road edge.
Definition RoadTypes.h:149
RoadSideDistribution
Rigid side-anchor distribution; historical snapshots retain the half-spacing phase....
Definition RoadTypes.h:158
RoadStructureKind
Explicit structural treatment of a bounded road interval.
Definition RoadTypes.h:60
RoadLaneDirection
Travel direction of a lane relative to the authored edge centerline.
Definition RoadTypes.h:304
@ Forward
Travels from RoadEdge::from to RoadEdge::to.
@ Backward
Travels from RoadEdge::to to RoadEdge::from.
RoadSamplingPolicy
Owning metric sampling semantics; absent snapshot fields retain MaximumIntervals.
Definition RoadTypes.h:179
RoadFrameOrientation
Cross-section orientation before authored roll; snapshots missing this field retain transport.
Definition RoadTypes.h:151
RoadMaterial
Profile material tags used when lofting a road cross-section.
Definition RoadTypes.h:37
@ TunnelPortalAsphalt
Driving surface inside an authored tunnel portal footprint.
PrefabRootPose
Immutable prefab placement convention shared by geometry bounds and renderer preparation....
Asset port with outward orthonormal frame, full seam section and network-local edge binding.
Definition RoadTypes.h:251
bool sectionClosed
Closed seam topology must match the attached road profile.
Definition RoadTypes.h:256
std::vector< RoadProfilePoint > section
Outward-facing section; must coincide with mesh boundary vertices.
Definition RoadTypes.h:257
std::uint32_t edgeId
Zero edgeId leaves an unused asset port unbound.
Definition RoadTypes.h:252
Material-qualified indexed triangle owned by a custom connection.
Definition RoadTypes.h:246
Owning renderer-neutral custom connection vertex in node-local space.
Definition RoadTypes.h:240
Owning custom junction asset snapshot; all geometry/ports share one node-local transform.
Definition RoadTypes.h:266
std::vector< RoadConnectionVertex > vertices
Definition RoadTypes.h:270
std::vector< RoadConnectionPort > ports
Empty selects the procedural junction, with no custom mesh.
Definition RoadTypes.h:272
std::vector< RoadFacilityRoute > facilityRoutes
Explicit routes override automatic two-arm continuation.
Definition RoadTypes.h:267
std::vector< RoadConnectionTriangle > triangles
Definition RoadTypes.h:271
Continuous facility over an authored edge interval; all profiles and prefab meshes are owned values.
Definition RoadTypes.h:112
RoadFacilityPrefab prefab
Empty source mesh selects section sweep; profile remains the socket envelope.
Definition RoadTypes.h:113
float lateralOffset
Metres from the authored centerline, signed along its side axis.
Definition RoadTypes.h:116
std::vector< RoadProfilePoint > profile
Closed simple section; outgoing segment material.
Definition RoadTypes.h:118
One authored control point on a road centerline (world space, Y-up).
Definition RoadTypes.h:19
float splineStrength
Outgoing Catmull span tangent strength in [0.01,1]; .5 preserves classic Catmull.
Definition RoadTypes.h:27
bool circularFromEnd
Derive circular geometry from the following endpoint tangent after reversal.
Definition RoadTypes.h:32
bool alignStraightEnd
Straight-adjacent XZ alignment with zero vertical derivative; reversal swaps ends.
Definition RoadTypes.h:30
RoadPathControl pathControl
Controller of this marker to the next marker.
Definition RoadTypes.h:28
float rollDegrees
Unwrapped crossfall in [-360,360] degrees; interpolation preserves the authored rotation direction.
Definition RoadTypes.h:25
float rollCenterOffset
Signed width fraction of the roll axis: -.5 left, 0 center, .5 right.
Definition RoadTypes.h:33
float widthScale
Positive driving-surface width multiplier in [0.05,16]; curb/sidewalk widths stay in metres.
Definition RoadTypes.h:23
Stable identities produced by one atomic edge split.
Definition RoadTypes.h:297
std::uint32_t firstEdgeId
Original edge identity retained by the first half.
Definition RoadTypes.h:299
std::uint32_t secondEdgeId
Newly allocated continuation edge.
Definition RoadTypes.h:300
Directed centerline edge with optional reverse lanes.
Definition RoadTypes.h:286
std::vector< RoadControlPoint > controlPoints
Definition RoadTypes.h:290
Owned prefab mesh; local Z in [0,length] deforms along the facility arc. Source range preserves cut g...
Definition RoadTypes.h:94
std::vector< RoadPrefabVertex > vertices
Definition RoadTypes.h:108
std::vector< RoadPrefabTriangle > triangles
Definition RoadTypes.h:109
int middleCopies
Bounded authored repetitions; segment lengths determine their relative arc lengths.
Definition RoadTypes.h:96
bool reverseRepeatSequence
Retained placement orientation for exact-spacing partial segments after reversal.
Definition RoadTypes.h:102
bool weldCompatibleVertices
Share indices only when position, normal and UV agree within 1e-5.
Definition RoadTypes.h:97
bool automaticSpacing
Fit the nearest positive number of middle segments, averaging spacing over the arc.
Definition RoadTypes.h:98
float repeatSourceLength
Zero derives the full source arc; split fragments retain the original metre span.
Definition RoadTypes.h:104
One explicit undirected facility route through a node; endpoints belong to incident edges....
Definition RoadTypes.h:262
One legal lane-to-lane connection inside a junction.
Definition RoadTypes.h:315
Junction node owned by a road network.
Definition RoadTypes.h:275
RoadJunctionControl junctionControl
Definition RoadTypes.h:281
Owning bake-time overlay snapshot (no pointers into the network).
Definition RoadTypes.h:341
std::vector< RoadPolyline > turns
Definition RoadTypes.h:343
std::vector< RoadPolyline > lanes
Definition RoadTypes.h:342
One renderer-neutral polyline chunk for navigation / marking overlays.
Definition RoadTypes.h:325
std::vector< float > xyz
Packed xyz samples.
Definition RoadTypes.h:326
RoadLaneDirection outDirection
Definition RoadTypes.h:335
RoadLaneDirection inDirection
Definition RoadTypes.h:334
Optional owned source segment for a prefab's start or end. Empty mesh omits the segment.
Definition RoadTypes.h:85
std::vector< RoadPrefabTriangle > triangles
Definition RoadTypes.h:89
std::vector< RoadPrefabVertex > vertices
Definition RoadTypes.h:88
Indexed source-prefab triangle with renderer-neutral material.
Definition RoadTypes.h:78
std::uint32_t smoothingGroup
Zero preserves authored normals; equal positive groups smooth coincident positions.
Definition RoadTypes.h:81
Owned source vertex in prefab-local (side, up, forward) axes, with normal and UV.
Definition RoadTypes.h:72
One 2D profile sample in the edge local (side, up) plane.
Definition RoadTypes.h:53
Owning open profile polyline for one edge style and lane layout.
Definition RoadTypes.h:347
std::vector< RoadProfilePoint > points
Definition RoadTypes.h:348
Stable asset link at an exact admitted package build; stale resolution fails without substituting new...
Definition RoadTypes.h:130
eve::PrefabRootPose rootPose
New road placements replace the source root pose.
Definition RoadTypes.h:133
Owning rigid-facility placement settings, copied with the road style. Explicit references ignore bake...
Definition RoadTypes.h:170
float lateralOffset
Signed path-right metres, bounded to +/-10000.
Definition RoadTypes.h:172
float yawDegrees
Additional world-Y rotation, bounded to +/-360.
Definition RoadTypes.h:174
RoadSidePathSampling pathSampling
Explicit sampled-surface opt-in; missing fields retain Analytic.
Definition RoadTypes.h:175
float verticalOffset
World-up metres, bounded to +/-10000; reference default is .02.
Definition RoadTypes.h:173
Owned side-object ground rule; None height retains road height, while TerrainNormal alignment indepen...
Definition RoadTypes.h:138
int samplesPerAxis
Uniform inclusive footprint grid in [2,17]; Center performs one query.
Definition RoadTypes.h:141
std::optional< RoadSideAssetBinding > asset
Absent uses explicit footprint; present resolves admitted prefab bounds.
Definition RoadTypes.h:145
RoadSideAlignment alignment
None keeps yaw only; other modes produce full Euler orientation.
Definition RoadTypes.h:142
Normalized arc-distance interval; nonoverlapping, sorted, owned by RoadNetwork.
Definition RoadTypes.h:63
float portalEndLength
Hole footprint depths in metres; zero omits a portal.
Definition RoadTypes.h:68
float tunnelHeight
Interior roof height above the centerline.
Definition RoadTypes.h:66
float wallThickness
Positive tunnel wall/roof thickness in metres.
Definition RoadTypes.h:67
Owning cross-section, width policy and structural authoring for one road edge.
Definition RoadTypes.h:182
std::vector< RoadProfilePoint > crossSection
Empty selects the standard road; custom segment tags are explicit.
Definition RoadTypes.h:192
bool sideObjectsRight
Emit anchors on the authored centerline's right side.
Definition RoadTypes.h:220
float sideObjectEndOffset
Empty distance after the last side-object anchor.
Definition RoadTypes.h:218
float samplingSpacingMeters
New roads use the measured 2m trigger; explicit zero keeps legacy fixed counts.
Definition RoadTypes.h:221
bool crossSectionClosed
Close the final-to-first section segment.
Definition RoadTypes.h:193
float speedLimitMps
Navigation speed limit in metres per second.
Definition RoadTypes.h:213
int crossSectionSubdivisions
Subdivide every authored section segment, bounded to [1,32].
Definition RoadTypes.h:224
float uvMeters
World-space metres per texture repeat.
Definition RoadTypes.h:212
float curbWidth
Jersey-barrier thickness.
Definition RoadTypes.h:200
std::vector< RoadStructureInterval > structures
Explicit normalized arc intervals; nonempty disables legacy automatic structures.
Definition RoadTypes.h:196
RoadSideTerrainRule sideTerrain
Terrain height selection for side.left/right anchors only.
Definition RoadTypes.h:184
std::vector< RoadContinuousFacility > facilities
Continuous swept facilities, clipped by sockets.
Definition RoadTypes.h:197
RoadFrameOrientation frameOrientation
New roads retain horizontal unbanked sections.
Definition RoadTypes.h:187
RoadRollInterpolation rollInterpolation
New roads ease crossfall per spline span; old snapshots retain Linear.
Definition RoadTypes.h:185
bool sideObjectsLeft
Emit anchors on the authored centerline's left side.
Definition RoadTypes.h:219
RoadSideDistribution sideObjectDistribution
Explicit rigid-anchor spacing policy.
Definition RoadTypes.h:216
RoadSidePlacement sidePlacement
Single source for rigid-facility origin and transform offsets.
Definition RoadTypes.h:183
float curbHeight
Raised barrier height (readable asphalt channel).
Definition RoadTypes.h:201
RoadSamplingPolicy samplingPolicy
Definition RoadTypes.h:225
bool automaticStructures
Empty intervals retain legacy decks/piers unless explicitly disabled.
Definition RoadTypes.h:194
float samplingAngleDegrees
New roads match the reference 45 degree target; scan requires >=1.
Definition RoadTypes.h:223
float sideObjectStartOffset
Empty distance before the first side-object anchor.
Definition RoadTypes.h:215
RoadWidthInterpolation widthInterpolation
Definition RoadTypes.h:189
RoadTerrainPolicy terrainPolicy
Authoritative ground-channel policy; execution remains explicit.
Definition RoadTypes.h:228
int trafficPriority
Higher incoming-road values win uncontrolled junction priority.
Definition RoadTypes.h:214
Owning per-road terrain author policy; copied with styles, presets and history. Owner-thread value wi...