Skip to content

Commit fea8060

Browse files
committed
fix: fixing probe panel issue, also fixing some ugly code
1 parent 0f26775 commit fea8060

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Assets/Scripts/Pinpoint/Probes/UI/ProbePanelManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public void RecalculateProbePanels()
102102
ReOrderProbePanels();
103103
}
104104

105+
public IEnumerator RecalculateProbePanels_Delayed()
106+
{
107+
yield return new WaitForEndOfFrame();
108+
RecalculateProbePanels();
109+
}
110+
105111
/// <summary>
106112
/// Re-order probe panels to make sure that 4-shank probes are grouped together in the top row first, followed by single shanks
107113
/// </summary>

Assets/Scripts/Pinpoint/TrajectoryPlannerManager.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,20 @@ public void DestroyProbe(ProbeManager probeManager)
357357
/// Handle TPManager cleanup after a probe was destroyed
358358
/// </summary>
359359
private void PostDestroyHandler(bool wasActiveProbe, IEnumerable<ProbeManager> remainingProbes)
360-
{
361-
// Cleanup UI if this was last probe in scene
360+
{
362361

363362
if (remainingProbes.Count() > 0)
364363
{
365364
if (wasActiveProbe)
366365
{
367366
SetActiveProbe(remainingProbes.Last());
367+
368+
StartCoroutine(_probePanelManager.RecalculateProbePanels_Delayed());
368369
}
369370
}
370371
else
371372
{
373+
// Cleanup UI if this was last probe in scene
372374
// Invalidate ProbeManager.ActiveProbeManager
373375
if (wasActiveProbe)
374376
{
@@ -954,12 +956,17 @@ public void SetProbeTipPosition2AreaID(int atlasID)
954956
if (ProbeManager.ActiveProbeManager == null) return;
955957
(Vector3 leftCoordU, Vector3 rightCoordU) = BrainAtlasManager.ActiveReferenceAtlas.MeshCenters[atlasID];
956958

959+
957960
// switch to right side if needed
958-
prevTipSideLeft = atlasID == prevTipID && prevTipSideLeft;
961+
if (atlasID == prevTipID)
962+
prevTipSideLeft = !prevTipSideLeft;
959963

960964
// transform the coordinate
965+
961966
Vector3 coordT = BrainAtlasManager.ActiveAtlasTransform.U2T(
962967
(prevTipSideLeft ? leftCoordU : rightCoordU) - BrainAtlasManager.ActiveReferenceAtlas.AtlasSpace.ReferenceCoord);
968+
969+
Debug.Log(coordT);
963970
ProbeManager.ActiveProbeManager.ProbeController.SetProbePosition(coordT);
964971

965972
prevTipID = atlasID;

0 commit comments

Comments
 (0)