Refactor junction influence calculation to use path shoulder width for falloff distance
This commit is contained in:
@@ -364,34 +364,22 @@ export function createSplineRoadTerrainPatch(options: {
|
|||||||
: patch;
|
: patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJunctionInfluence(
|
function getJunctionTerrainFalloffDistance(
|
||||||
distance: number,
|
|
||||||
junction: SplineCorridorJunction,
|
junction: SplineCorridorJunction,
|
||||||
paths: readonly ScenePath[]
|
paths: readonly ScenePath[]
|
||||||
): number {
|
): number {
|
||||||
if (distance > junction.radius) {
|
return Math.max(
|
||||||
return 0;
|
0.001,
|
||||||
}
|
...junction.connections.map((connection) => {
|
||||||
|
const path = paths.find((candidate) => candidate.id === connection.pathId);
|
||||||
|
|
||||||
const coreRadius = Math.min(
|
if (path === undefined) {
|
||||||
junction.radius,
|
return 0;
|
||||||
Math.max(
|
}
|
||||||
0.1,
|
|
||||||
...junction.connections.map((connection) => {
|
return Math.max(path.road.shoulderWidth, junction.radius * 0.25);
|
||||||
const path = paths.find((candidate) => candidate.id === connection.pathId);
|
})
|
||||||
return path === undefined ? 0 : path.road.width * 0.5;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (distance <= coreRadius) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const falloffDistance = Math.max(0.001, junction.radius - coreRadius);
|
|
||||||
const progress = clamp((distance - coreRadius) / falloffDistance, 0, 1);
|
|
||||||
|
|
||||||
return Math.pow(1 - progress, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAverageJunctionTargetHeight(options: {
|
function getAverageJunctionTargetHeight(options: {
|
||||||
|
|||||||
Reference in New Issue
Block a user