Integrate road edge settings into spline corridor junctions

This commit is contained in:
2026-05-13 17:14:33 +02:00
parent 1d09b76263
commit dde048f41c

View File

@@ -1,10 +1,12 @@
import type { Vec3 } from "../core/vector"; import type { Vec3 } from "../core/vector";
import { import {
createScenePathRoadEdgeSettings,
resolveScenePath, resolveScenePath,
sampleResolvedScenePathPosition, sampleResolvedScenePathPosition,
type ResolvedScenePath, type ResolvedScenePath,
type ResolvedScenePathSegment, type ResolvedScenePathSegment,
type ScenePath type ScenePath,
type ScenePathRoadEdgeSettings
} from "../document/paths"; } from "../document/paths";
import { import {
createSplineCorridorJunction, createSplineCorridorJunction,
@@ -30,6 +32,7 @@ export interface SplineCorridorJunctionCandidate {
center: Vec3; center: Vec3;
radius: number; radius: number;
materialId: string | null; materialId: string | null;
edge: ScenePathRoadEdgeSettings;
connections: SplineCorridorJunctionCandidateConnection[]; connections: SplineCorridorJunctionCandidateConnection[];
} }
@@ -62,6 +65,23 @@ function getCandidateRadius(paths: readonly ScenePath[]): number {
); );
} }
function getCandidateEdge(paths: readonly ScenePath[]): ScenePathRoadEdgeSettings {
const edges = paths.flatMap((path) => [
path.road.edges.left,
path.road.edges.right
]);
const inheritedEdge =
edges.find((edge) => edge.enabled && edge.kind !== "softShoulder") ??
edges.find((edge) => edge.enabled) ??
null;
if (inheritedEdge === null) {
return createScenePathRoadEdgeSettings();
}
return createScenePathRoadEdgeSettings(inheritedEdge);
}
function createCandidateId( function createCandidateId(
connections: readonly SplineCorridorJunctionCandidateConnection[] connections: readonly SplineCorridorJunctionCandidateConnection[]
): string { ): string {
@@ -190,6 +210,7 @@ function createCandidateFromConnections(options: {
materialId: materialId:
options.paths.find((path) => path.road.materialId !== null)?.road options.paths.find((path) => path.road.materialId !== null)?.road
.materialId ?? null, .materialId ?? null,
edge: getCandidateEdge(options.paths),
connections connections
}; };
} }
@@ -473,6 +494,7 @@ export function createSplineCorridorJunctionFromCandidate(
center: candidate.center, center: candidate.center,
radius: candidate.radius, radius: candidate.radius,
materialId: candidate.materialId, materialId: candidate.materialId,
edge: candidate.edge,
connections: candidate.connections connections: candidate.connections
}); });
} }
@@ -534,4 +556,3 @@ export function getSplineCorridorJunctionsConnectedToPath(options: {
junction.connections.some((connection) => connection.pathId === options.pathId) junction.connections.some((connection) => connection.pathId === options.pathId)
); );
} }