Refactored campath translation point functions to make sure the order of execution is always the same.

This commit is contained in:
originalnicodr committed 2024-03-08 22:03:39 -03:00
1 parent 103e2fd40e
commit adbbf4eb75
2 files changed
+15 -8

No files matched your search

+12 -2
View File
@@ -424,7 +424,17 @@ namespace UnityExplorer.UI.Panels
}
}
public void TranslatePointsPositionToGlobal(){
public void TranslatePointsToGlobal(bool isFollowingRotation){
if (isFollowingRotation) TranslatePointsRotationToGlobal();
TranslatePointsPositionToGlobal();
}
public void TranslatePointsToLocal(bool isFollowingRotation){
TranslatePointsPositionToLocal();
if (isFollowingRotation) TranslatePointsRotationToLocal();
}
private void TranslatePointsPositionToGlobal(){
List<CatmullRom.CatmullRomPoint> newControlPoints = new List<CatmullRom.CatmullRomPoint>();
foreach(CatmullRom.CatmullRomPoint point in controlPoints){
Vector3 newPos = point.position + followObject.transform.position;
@@ -450,7 +460,7 @@ namespace UnityExplorer.UI.Panels
controlPoints = newControlPoints;
}
public void TranslatePointsPositionToLocal(){
private void TranslatePointsPositionToLocal(){
List<CatmullRom.CatmullRomPoint> newControlPoints = new List<CatmullRom.CatmullRomPoint>();
foreach(CatmullRom.CatmullRomPoint point in controlPoints){
Vector3 newPos = point.position - followObject.transform.position;
+3 -6
View File
@@ -448,8 +448,7 @@ namespace UnityExplorer.UI.Panels
CamPaths CamPathsPanel = UIManager.GetPanel<CamPaths>(UIManager.Panels.CamPaths);
if (followObject != null){
if (followRotationToggle.isOn) CamPathsPanel.TranslatePointsRotationToGlobal();
CamPathsPanel.TranslatePointsPositionToGlobal();
CamPathsPanel.TranslatePointsToGlobal(followRotationToggle.isOn);
}
followObject = obj;
@@ -459,8 +458,7 @@ namespace UnityExplorer.UI.Panels
CamPathsPanel.UpdatedFollowObject(obj);
CamPathsPanel.TranslatePointsPositionToLocal();
if (followRotationToggle.isOn) CamPathsPanel.TranslatePointsRotationToLocal();
CamPathsPanel.TranslatePointsToLocal(followRotationToggle.isOn);
CamPathsPanel.MaybeRedrawPath();
}
@@ -480,8 +478,7 @@ namespace UnityExplorer.UI.Panels
}
CamPaths CamPathsPanel = UIManager.GetPanel<CamPaths>(UIManager.Panels.CamPaths);
if (followRotationToggle.isOn) CamPathsPanel.TranslatePointsRotationToGlobal();
CamPathsPanel.TranslatePointsPositionToGlobal();
CamPathsPanel.TranslatePointsToGlobal(followRotationToggle.isOn);
CamPathsPanel.UpdatedFollowObject(null);
}