Improve path point position command to handle spline corridor junction state
This commit is contained in:
@@ -7,8 +7,13 @@ import {
|
|||||||
getScenePathPointIndex,
|
getScenePathPointIndex,
|
||||||
type ScenePath
|
type ScenePath
|
||||||
} from "../document/paths";
|
} from "../document/paths";
|
||||||
|
import type { SplineCorridorJunctionRegistry } from "../document/spline-corridor-junctions";
|
||||||
|
|
||||||
import type { EditorCommand } from "./command";
|
import type { EditorCommand } from "./command";
|
||||||
|
import {
|
||||||
|
cloneSplineCorridorJunctionRegistry,
|
||||||
|
setScenePathAndReattachJunctions
|
||||||
|
} from "./path-junction-maintenance";
|
||||||
|
|
||||||
export interface PathPointPositionUpdate {
|
export interface PathPointPositionUpdate {
|
||||||
pointId: string;
|
pointId: string;
|
||||||
@@ -85,6 +90,7 @@ export function createSetPathPointPositionsCommand(
|
|||||||
position: cloneVec3(update.position)
|
position: cloneVec3(update.position)
|
||||||
}));
|
}));
|
||||||
let previousPath: ScenePath | null = null;
|
let previousPath: ScenePath | null = null;
|
||||||
|
let previousJunctions: SplineCorridorJunctionRegistry | null = null;
|
||||||
let previousSelection: EditorSelection | null = null;
|
let previousSelection: EditorSelection | null = null;
|
||||||
let previousToolMode: ToolMode | null = null;
|
let previousToolMode: ToolMode | null = null;
|
||||||
|
|
||||||
@@ -115,13 +121,18 @@ export function createSetPathPointPositionsCommand(
|
|||||||
previousToolMode = context.getToolMode();
|
previousToolMode = context.getToolMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
context.setDocument({
|
if (previousJunctions === null) {
|
||||||
...currentDocument,
|
previousJunctions = cloneSplineCorridorJunctionRegistry(
|
||||||
paths: {
|
currentDocument.splineCorridorJunctions
|
||||||
...currentDocument.paths,
|
);
|
||||||
[path.id]: applyPathPointUpdates(path, updates)
|
}
|
||||||
}
|
|
||||||
});
|
context.setDocument(
|
||||||
|
setScenePathAndReattachJunctions(
|
||||||
|
currentDocument,
|
||||||
|
applyPathPointUpdates(path, updates)
|
||||||
|
)
|
||||||
|
);
|
||||||
context.setSelection(
|
context.setSelection(
|
||||||
createPathPointSelection(
|
createPathPointSelection(
|
||||||
options.pathId,
|
options.pathId,
|
||||||
@@ -142,7 +153,11 @@ export function createSetPathPointPositionsCommand(
|
|||||||
paths: {
|
paths: {
|
||||||
...currentDocument.paths,
|
...currentDocument.paths,
|
||||||
[previousPath.id]: cloneScenePath(previousPath)
|
[previousPath.id]: cloneScenePath(previousPath)
|
||||||
}
|
},
|
||||||
|
splineCorridorJunctions:
|
||||||
|
previousJunctions === null
|
||||||
|
? currentDocument.splineCorridorJunctions
|
||||||
|
: cloneSplineCorridorJunctionRegistry(previousJunctions)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (previousSelection !== null) {
|
if (previousSelection !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user