Skip to content

Commit bcced33

Browse files
committed
Fixing a really bad bug in InPlaneSlice
- Bug was causing the forward direction to be incorrectly calculated because you can't pass normalized vectors through W2T or T2W!! - Fixed by calculating a point in TransformedWorld space to represent the up and forward directions and then returning those in normalized UnityWorld coordinates
1 parent be76164 commit bcced33

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

Assets/Scripts/TrajectoryPlanner/Controllers/DefaultProbeController.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,11 @@ public override void SetProbePosition(ProbeInsertion localInsertion)
783783
/// <returns></returns>
784784
public override (Vector3 tipCoordWorld, Vector3 tipUpWorld, Vector3 tipForwardWorld) GetTipWorld()
785785
{
786+
Debug.Log((_probeTipT.up, _probeTipT.forward));
786787
Vector3 tipCoordWorld = WorldT2WorldU(_probeTipT.position);
787-
//Vector3 tipUpWorld = (WorldT2WorldU(probeTipTop.transform.position) - tipCoordWorld).normalized;
788-
Vector3 tipUpWorld = WorldT2WorldU(_probeTipT.up).normalized;
789-
Vector3 tipForwardWorld = WorldT2WorldU(_probeTipT.forward).normalized;
788+
Vector3 tipUpWorld = (WorldT2WorldU(_probeTipT.position + _probeTipT.up) - tipCoordWorld).normalized;
789+
Vector3 tipForwardWorld = (WorldT2WorldU(_probeTipT.position + _probeTipT.forward) - tipCoordWorld).normalized;
790+
790791
return (tipCoordWorld, tipUpWorld, tipForwardWorld);
791792
}
792793

@@ -823,7 +824,7 @@ public override (Vector3 startCoordWorld, Vector3 endCoordWorld) GetRecordingReg
823824
}
824825
else
825826
{
826-
return (WorldT2WorldU(tipTransform.position), WorldT2WorldU(tipTransform.position));
827+
return (WorldT2WorldU(tipTransform.position), WorldT2WorldU(tipTransform.position + tipTransform.up * 10f));
827828
}
828829
}
829830

Assets/Scripts/TrajectoryPlanner/TP_InPlaneSlice.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ public void UpdateInPlaneVisibility()
103103
inPlaneSliceUIGO.SetActive(localPrefs.GetInplane());
104104
}
105105

106-
private void Update()
107-
{
108-
UpdateInPlaneSlice();
109-
}
110-
111106
public void UpdateInPlaneSlice()
112107
{
113108
if (!localPrefs.GetInplane()) return;
@@ -122,8 +117,6 @@ public void UpdateInPlaneSlice()
122117

123118
(Vector3 startCoordWorld, Vector3 endCoordWorld) = activeProbeManager.GetProbeController().GetRecordingRegionWorld();
124119
(_, Vector3 upWorld, Vector3 forwardWorld) = activeProbeManager.GetProbeController().GetTipWorld();
125-
upWorld = (endCoordWorld - startCoordWorld).normalized;
126-
forwardWorld = Quaternion.Euler(-90f, 0f, 0f) * upWorld;
127120

128121
#if UNITY_EDITOR
129122
// debug statements

0 commit comments

Comments
 (0)