Skip to content

Commit a48f23b

Browse files
committed
Fixing a bug preventing in-plane slice from updating properly
1 parent 83ad994 commit a48f23b

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

Assets/Scripts/TrajectoryPlanner/Controllers/DefaultProbeController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,6 @@ 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));
787786
Vector3 tipCoordWorld = WorldT2WorldU(_probeTipT.position);
788787
Vector3 tipUpWorld = (WorldT2WorldU(_probeTipT.position + _probeTipT.up) - tipCoordWorld).normalized;
789788
Vector3 tipForwardWorld = (WorldT2WorldU(_probeTipT.position + _probeTipT.forward) - tipCoordWorld).normalized;

Assets/Scripts/TrajectoryPlanner/ProbeManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ private void Awake()
122122
visibleOtherColliders = new Dictionary<GameObject, Material>();
123123
}
124124

125+
private void Start()
126+
{
127+
Debug.Log(string.Format("New probe created with UUID: {0}", _uuid));
128+
}
129+
125130
/// <summary>
126131
/// Called by Unity when this object is destroyed.
127132
/// Unregisters the probe from tpmanager
@@ -176,6 +181,14 @@ public void SetUIVisibility(bool state)
176181
}
177182

178183

184+
public void OverrideUUID(string newUUID)
185+
{
186+
#if UNITY_EDITOR
187+
Debug.Log(string.Format("Override UUID to {0}", newUUID));
188+
#endif
189+
_uuid = newUUID;
190+
}
191+
179192
/// <summary>
180193
/// Update the size of the recording region.
181194
/// </summary>

Assets/Scripts/TrajectoryPlanner/TP_InPlaneSlice.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class TP_InPlaneSlice : MonoBehaviour
3131
private int zoomLevel = 0;
3232
private float zoomFactor = 1f;
3333

34-
private RectTransform rect;
34+
private RectTransform _rect;
3535

3636
private Texture3D annotationDatasetGPUTexture;
3737
private TaskCompletionSource<bool> gpuTextureLoadedSource;
@@ -44,7 +44,7 @@ public class TP_InPlaneSlice : MonoBehaviour
4444

4545
private void Awake()
4646
{
47-
rect = GetComponent<RectTransform>();
47+
_rect = GetComponent<RectTransform>();
4848

4949
gpuTextureLoadedSource = new TaskCompletionSource<bool>();
5050
gpuTextureLoadedTask = gpuTextureLoadedSource.Task;
@@ -116,7 +116,7 @@ public void UpdateInPlaneSlice()
116116
}
117117

118118
(Vector3 startCoordWorld, Vector3 endCoordWorld) = activeProbeManager.GetProbeController().GetRecordingRegionWorld();
119-
(_, Vector3 upWorld, Vector3 forwardWorld) = activeProbeManager.GetProbeController().GetTipWorld();
119+
(_, upWorld, forwardWorld) = activeProbeManager.GetProbeController().GetTipWorld();
120120

121121
#if UNITY_EDITOR
122122
// debug statements
@@ -171,22 +171,20 @@ public void InPlaneSliceHover(Vector2 pointerData)
171171
private Vector3 CalculateInPlanePosition(Vector2 pointerData)
172172
{
173173
Vector2 inPlanePosNorm = GetLocalRectPosNormalized(pointerData) * inPlaneScale / 2;
174-
175174
// Take the tip transform and go out according to the in plane percentage
176175
Vector3 inPlanePosition = recordingRegionCenterPosition + (annotationDataset.CoordinateSpace.World2SpaceAxisChange(forwardWorld) * -inPlanePosNorm.x + annotationDataset.CoordinateSpace.World2SpaceAxisChange(upWorld) * inPlanePosNorm.y);
177-
178176
return inPlanePosition;
179177
}
180178

181179
// Return the position within the local UI rectangle scaled to [-1, 1] on each axis
182180
private Vector2 GetLocalRectPosNormalized(Vector2 pointerData)
183181
{
184182
Vector2 inPlanePosNorm;
185-
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, pointerData, Camera.main, out inPlanePosNorm);
183+
RectTransformUtility.ScreenPointToLocalPointInRectangle(_rect, pointerData, Camera.main, out inPlanePosNorm);
186184

187-
inPlanePosNorm += new Vector2(rect.rect.width, rect.rect.height / 2);
188-
inPlanePosNorm.x = inPlanePosNorm.x / rect.rect.width * 2 - 1;
189-
inPlanePosNorm.y = inPlanePosNorm.y / rect.rect.height * 2 - 1;
185+
inPlanePosNorm += new Vector2(_rect.rect.width, _rect.rect.height / 2);
186+
inPlanePosNorm.x = inPlanePosNorm.x / _rect.rect.width * 2 - 1;
187+
inPlanePosNorm.y = inPlanePosNorm.y / _rect.rect.height * 2 - 1;
190188
return inPlanePosNorm;
191189
}
192190

Assets/Scripts/TrajectoryPlanner/TP_SliceRenderer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ private void Update()
149149
/// </summary>
150150
private void UpdateSlicePosition()
151151
{
152-
Debug.Log("Update slice called: " + Time.realtimeSinceStartup);
153152
ProbeManager activeProbeManager = tpmanager.GetActiveProbeManager();
154153
if (activeProbeManager == null) return;
155154

0 commit comments

Comments
 (0)