Refactor profile row generation by pre-calculating row offsets and simplifying junction edge mesh data building
This commit is contained in:
@@ -452,37 +452,37 @@ export function resolveSplineCorridorJunctionRoadEdgeSeams(options: {
|
|||||||
|
|
||||||
const currentPoint = footprint.points[pointIndex]!;
|
const currentPoint = footprint.points[pointIndex]!;
|
||||||
const nextPoint = footprint.points[(pointIndex + 1) % footprint.points.length]!;
|
const nextPoint = footprint.points[(pointIndex + 1) % footprint.points.length]!;
|
||||||
const previousSegmentIndex =
|
const previousSegmentIndex =
|
||||||
(pointIndex - 1 + footprint.points.length) % footprint.points.length;
|
(pointIndex - 1 + footprint.points.length) % footprint.points.length;
|
||||||
const nextSegmentIndex = (pointIndex + 1) % footprint.points.length;
|
const nextSegmentIndex = (pointIndex + 1) % footprint.points.length;
|
||||||
|
|
||||||
if (isRoadMouthSegment(footprint.points, previousSegmentIndex)) {
|
if (isRoadMouthSegment(footprint.points, previousSegmentIndex)) {
|
||||||
pushRoadEdgeSeam({
|
pushRoadEdgeSeam({
|
||||||
seamsByPath,
|
seamsByPath,
|
||||||
junctionId: junction.id,
|
junctionId: junction.id,
|
||||||
point: currentPoint,
|
point: currentPoint,
|
||||||
outerOffset: getBoundaryPointOuterOffset({
|
outerOffset: getBoundaryPointOuterOffset({
|
||||||
points: footprint.points,
|
points: footprint.points,
|
||||||
pointIndex,
|
pointIndex,
|
||||||
paths: options.paths,
|
paths: options.paths,
|
||||||
edge: junction.edge
|
edge: junction.edge
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRoadMouthSegment(footprint.points, nextSegmentIndex)) {
|
if (isRoadMouthSegment(footprint.points, nextSegmentIndex)) {
|
||||||
pushRoadEdgeSeam({
|
pushRoadEdgeSeam({
|
||||||
seamsByPath,
|
seamsByPath,
|
||||||
junctionId: junction.id,
|
junctionId: junction.id,
|
||||||
point: nextPoint,
|
point: nextPoint,
|
||||||
outerOffset: getBoundaryPointOuterOffset({
|
outerOffset: getBoundaryPointOuterOffset({
|
||||||
points: footprint.points,
|
points: footprint.points,
|
||||||
pointIndex: nextSegmentIndex,
|
pointIndex: nextSegmentIndex,
|
||||||
paths: options.paths,
|
paths: options.paths,
|
||||||
edge: junction.edge
|
edge: junction.edge
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,66 +570,30 @@ export function buildSplineCorridorJunctionEdgeMeshData(options: {
|
|||||||
return rowOffset;
|
return rowOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rowOffsets = footprint.points.map((point, pointIndex) =>
|
||||||
|
pushProfileRow({
|
||||||
|
point,
|
||||||
|
outerOffset: getBoundaryPointOuterOffset({
|
||||||
|
points: footprint.points,
|
||||||
|
pointIndex,
|
||||||
|
paths: options.paths,
|
||||||
|
edge: options.edge
|
||||||
|
}),
|
||||||
|
perimeterDistance: perimeterDistances[pointIndex]!
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
for (let pointIndex = 0; pointIndex < footprint.points.length; pointIndex += 1) {
|
for (let pointIndex = 0; pointIndex < footprint.points.length; pointIndex += 1) {
|
||||||
if (isRoadMouthSegment(footprint.points, pointIndex)) {
|
if (isRoadMouthSegment(footprint.points, pointIndex)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentPoint = footprint.points[pointIndex]!;
|
const nextPointIndex = (pointIndex + 1) % footprint.points.length;
|
||||||
const nextPoint = footprint.points[(pointIndex + 1) % footprint.points.length]!;
|
|
||||||
const segmentDirection = normalizeXZ({
|
|
||||||
x: nextPoint.x - currentPoint.x,
|
|
||||||
z: nextPoint.z - currentPoint.z
|
|
||||||
});
|
|
||||||
const segmentOutwardNormal = getOutwardSegmentNormal(currentPoint, nextPoint);
|
|
||||||
const previousSegmentIndex =
|
const previousSegmentIndex =
|
||||||
(pointIndex - 1 + footprint.points.length) % footprint.points.length;
|
(pointIndex - 1 + footprint.points.length) % footprint.points.length;
|
||||||
const nextSegmentIndex = (pointIndex + 1) % footprint.points.length;
|
const nextSegmentIndex = (pointIndex + 1) % footprint.points.length;
|
||||||
const startEdgeWidth =
|
const currentRow = rowOffsets[pointIndex]!;
|
||||||
isRoadMouthSegment(footprint.points, previousSegmentIndex)
|
const nextRow = rowOffsets[nextPointIndex]!;
|
||||||
? getPathEdgeWidth({
|
|
||||||
paths: options.paths,
|
|
||||||
point: currentPoint
|
|
||||||
}) ?? options.edge.width
|
|
||||||
: options.edge.width;
|
|
||||||
const endEdgeWidth =
|
|
||||||
isRoadMouthSegment(footprint.points, nextSegmentIndex)
|
|
||||||
? getPathEdgeWidth({
|
|
||||||
paths: options.paths,
|
|
||||||
point: nextPoint
|
|
||||||
}) ?? options.edge.width
|
|
||||||
: options.edge.width;
|
|
||||||
const startOuterOffset = isRoadMouthSegment(
|
|
||||||
footprint.points,
|
|
||||||
previousSegmentIndex
|
|
||||||
)
|
|
||||||
? getConnectionMiterOuterOffset({
|
|
||||||
point: currentPoint,
|
|
||||||
segmentStart: currentPoint,
|
|
||||||
segmentDirection,
|
|
||||||
segmentNormal: segmentOutwardNormal,
|
|
||||||
edgeWidth: startEdgeWidth
|
|
||||||
})
|
|
||||||
: multiplyXZVector(segmentOutwardNormal, options.edge.width);
|
|
||||||
const endOuterOffset = isRoadMouthSegment(footprint.points, nextSegmentIndex)
|
|
||||||
? getConnectionMiterOuterOffset({
|
|
||||||
point: nextPoint,
|
|
||||||
segmentStart: currentPoint,
|
|
||||||
segmentDirection,
|
|
||||||
segmentNormal: segmentOutwardNormal,
|
|
||||||
edgeWidth: endEdgeWidth
|
|
||||||
})
|
|
||||||
: multiplyXZVector(segmentOutwardNormal, options.edge.width);
|
|
||||||
const currentRow = pushProfileRow({
|
|
||||||
point: currentPoint,
|
|
||||||
outerOffset: startOuterOffset,
|
|
||||||
perimeterDistance: perimeterDistances[pointIndex]!
|
|
||||||
});
|
|
||||||
const nextRow = pushProfileRow({
|
|
||||||
point: nextPoint,
|
|
||||||
outerOffset: endOuterOffset,
|
|
||||||
perimeterDistance: perimeterDistances[pointIndex + 1]!
|
|
||||||
});
|
|
||||||
|
|
||||||
addProfileStrip({
|
addProfileStrip({
|
||||||
indices,
|
indices,
|
||||||
|
|||||||
Reference in New Issue
Block a user