Skip to content

Commit ca81bcc

Browse files
Fixed loading cam path relative to the camera with a different rotation.
1 parent b951787 commit ca81bcc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/UI/Panels/CamPaths.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ private void LoadPath(){
559559
ExplorerCore.LogWarning("Loaded a path on a different scene than the one it was saved on. Spawning it starting from the current camera state.");
560560
}
561561

562-
// loadPathOnCamToggle check
563562
if (loadPathOnCamToggle.isOn) {
564563

565564
// We enable the freecam so we can use it to spawn the camera path relative to it
@@ -579,8 +578,10 @@ private void LoadPath(){
579578

580579
foreach (CatmullRom.CatmullRomPoint point in deserializedObj.points.Skip(1)) {
581580
CatmullRom.CatmullRomPoint newPoint = point;
582-
newPoint.position = startingPoint.position - originalStartingPoint.position + newPoint.position;
583-
newPoint.rotation = startingPoint.rotation * Quaternion.Inverse(originalStartingPoint.rotation) * newPoint.rotation;
581+
582+
Quaternion offsetRot = startingPoint.rotation * Quaternion.Inverse(originalStartingPoint.rotation);
583+
newPoint.position = offsetRot * (newPoint.position - originalStartingPoint.position) + startingPoint.position;
584+
newPoint.rotation = offsetRot * newPoint.rotation;
584585

585586
controlPoints.Add(newPoint);
586587
}

0 commit comments

Comments
 (0)