Integrate spline corridor junction support for terrain patching and scene building
This commit is contained in:
@@ -7,7 +7,11 @@ import {
|
|||||||
getTerrains,
|
getTerrains,
|
||||||
type Terrain
|
type Terrain
|
||||||
} from "../document/terrains";
|
} from "../document/terrains";
|
||||||
import { createSplineRoadTerrainPatch } from "../geometry/spline-road-terrain";
|
import {
|
||||||
|
createSplineCorridorJunctionTerrainPatch,
|
||||||
|
createSplineRoadTerrainPatch
|
||||||
|
} from "../geometry/spline-road-terrain";
|
||||||
|
import { getSplineCorridorJunctionsConnectedToPath } from "../spline-corridor/spline-corridor-junctions";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
applyTerrainBrushPatchToDocument,
|
applyTerrainBrushPatchToDocument,
|
||||||
@@ -71,10 +75,26 @@ function createAppliedTerrainRoads(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const before = cloneTerrain(terrain);
|
const before = cloneTerrain(terrain);
|
||||||
const terrainWithMaterialLayer =
|
let terrainWithMaterialLayer =
|
||||||
path.road.materialId === null
|
path.road.materialId === null
|
||||||
? terrain
|
? terrain
|
||||||
: ensureTerrainMaterialLayer(terrain, path.road.materialId).terrain;
|
: ensureTerrainMaterialLayer(terrain, path.road.materialId).terrain;
|
||||||
|
const connectedJunctions = getSplineCorridorJunctionsConnectedToPath({
|
||||||
|
junctions: document.splineCorridorJunctions,
|
||||||
|
pathId
|
||||||
|
}).filter((junction) => junction.enabled);
|
||||||
|
|
||||||
|
for (const junction of connectedJunctions) {
|
||||||
|
if (junction.materialId === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
terrainWithMaterialLayer = ensureTerrainMaterialLayer(
|
||||||
|
terrainWithMaterialLayer,
|
||||||
|
junction.materialId
|
||||||
|
).terrain;
|
||||||
|
}
|
||||||
|
|
||||||
let tempDocument = {
|
let tempDocument = {
|
||||||
...document,
|
...document,
|
||||||
terrains: {
|
terrains: {
|
||||||
@@ -82,20 +102,44 @@ function createAppliedTerrainRoads(
|
|||||||
[terrain.id]: cloneTerrain(terrainWithMaterialLayer)
|
[terrain.id]: cloneTerrain(terrainWithMaterialLayer)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let changed = false;
|
||||||
const patch = createSplineRoadTerrainPatch({
|
const patch = createSplineRoadTerrainPatch({
|
||||||
path,
|
path,
|
||||||
terrain: tempDocument.terrains[terrain.id]!
|
terrain: tempDocument.terrains[terrain.id]!
|
||||||
});
|
});
|
||||||
|
|
||||||
if (patch === null || isTerrainBrushPatchEmpty(patch)) {
|
if (patch !== null && !isTerrainBrushPatchEmpty(patch)) {
|
||||||
|
tempDocument = applyTerrainBrushPatchToDocument(
|
||||||
|
tempDocument,
|
||||||
|
patch,
|
||||||
|
"forward"
|
||||||
|
);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const junction of connectedJunctions) {
|
||||||
|
const junctionPatch = createSplineCorridorJunctionTerrainPatch({
|
||||||
|
junction,
|
||||||
|
paths: Object.values(document.paths),
|
||||||
|
terrain: tempDocument.terrains[terrain.id]!
|
||||||
|
});
|
||||||
|
|
||||||
|
if (junctionPatch === null || isTerrainBrushPatchEmpty(junctionPatch)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempDocument = applyTerrainBrushPatchToDocument(
|
||||||
|
tempDocument,
|
||||||
|
junctionPatch,
|
||||||
|
"forward"
|
||||||
|
);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!changed) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tempDocument = applyTerrainBrushPatchToDocument(
|
|
||||||
tempDocument,
|
|
||||||
patch,
|
|
||||||
"forward"
|
|
||||||
);
|
|
||||||
appliedTerrains.push({
|
appliedTerrains.push({
|
||||||
terrainId: terrain.id,
|
terrainId: terrain.id,
|
||||||
before,
|
before,
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ import {
|
|||||||
type ScenePathRoadSettings,
|
type ScenePathRoadSettings,
|
||||||
type ScenePathPoint
|
type ScenePathPoint
|
||||||
} from "../document/paths";
|
} from "../document/paths";
|
||||||
|
import {
|
||||||
|
getSplineCorridorJunctions,
|
||||||
|
type SplineCorridorJunction
|
||||||
|
} from "../document/spline-corridor-junctions";
|
||||||
import {
|
import {
|
||||||
cloneTerrain,
|
cloneTerrain,
|
||||||
createEmptyTerrainFoliageBlockerMask,
|
createEmptyTerrainFoliageBlockerMask,
|
||||||
@@ -86,6 +90,7 @@ import {
|
|||||||
deriveSplineCorridorBoxColliders,
|
deriveSplineCorridorBoxColliders,
|
||||||
type SplineCorridorBoxCollider
|
type SplineCorridorBoxCollider
|
||||||
} from "../spline-corridor/spline-corridor-colliders";
|
} from "../spline-corridor/spline-corridor-colliders";
|
||||||
|
import { resolveSplineCorridorJunctionClipIntervals } from "../spline-corridor/spline-corridor-junctions";
|
||||||
import {
|
import {
|
||||||
cloneWorldSettings,
|
cloneWorldSettings,
|
||||||
type WorldSettings
|
type WorldSettings
|
||||||
|
|||||||
Reference in New Issue
Block a user