Skip to content

Commit 6942af5

Browse files
committed
Bug fixes due to asynchronous annotation dataset loading
1 parent 7f74a94 commit 6942af5

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14169,7 +14169,7 @@ MonoBehaviour:
1416914169
m_Name:
1417014170
m_EditorClassIdentifier:
1417114171
m_Material: {fileID: 0}
14172-
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
14172+
m_Color: {r: 1, g: 1, b: 1, a: 1}
1417314173
m_RaycastTarget: 0
1417414174
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
1417514175
m_Maskable: 1
@@ -17873,6 +17873,7 @@ MonoBehaviour:
1787317873
recRegionSlider: {fileID: 353300833}
1787417874
ccfCollider: {fileID: 1859818792}
1787517875
inPlaneSlice: {fileID: 672548778}
17876+
sliceRenderer: {fileID: 379075881}
1787617877
searchControl: {fileID: 1369876173}
1787717878
searchInput: {fileID: 1047957689}
1787817879
localPrefs: {fileID: 2108153956}
@@ -18256,7 +18257,7 @@ MonoBehaviour:
1825618257
m_Name:
1825718258
m_EditorClassIdentifier:
1825818259
m_Material: {fileID: 0}
18259-
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
18260+
m_Color: {r: 1, g: 1, b: 1, a: 0}
1826018261
m_RaycastTarget: 1
1826118262
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
1826218263
m_Maskable: 1

Assets/Scripts/TP_Search.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@ public void ClickArea(GameObject target)
7878
else
7979
{
8080
if (!targetNode.IsLoaded())
81-
targetNode.loadNodeModel(false);
82-
83-
targetNode.SetNodeModelVisibility(true);
84-
modelControl.ChangeMaterial(targetNode, "lit");
81+
targetNode.loadNodeModel(false, handle => {
82+
targetNode.SetNodeModelVisibility(true);
83+
modelControl.ChangeMaterial(targetNode, "lit");
84+
});
85+
else
86+
{
87+
targetNode.SetNodeModelVisibility(true);
88+
modelControl.ChangeMaterial(targetNode, "lit");
89+
}
8590
}
8691
activeBrainAreas.Add(targetNode);
8792
}

Assets/Scripts/TP_SliceRenderer.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class TP_SliceRenderer : MonoBehaviour
2121
private int apIdx = 0;
2222

2323
bool needToRender = false;
24+
bool loaded = false;
2425

2526
private bool camXLeft;
2627
private bool camYBack;
@@ -42,10 +43,13 @@ void Start()
4243
public void AsyncStart()
4344
{
4445
annotationDataset = tpmanager.GetAnnotationDataset();
46+
loaded = true;
47+
ToggleSliceVisibility(localPrefs.GetSlice3D());
4548
}
4649

4750
private void Update()
4851
{
52+
4953
if (localPrefs.GetSlice3D())
5054
{
5155
// Check if the camera moved such that we have to flip the slice quads
@@ -68,6 +72,7 @@ private void Update()
6872
private void UpdateSlicePosition()
6973
{
7074
ProbeController activeProbeController = tpmanager.GetActiveProbeController();
75+
if (activeProbeController == null) return;
7176
Transform activeProbeTipT = activeProbeController.GetTipTransform();
7277
Vector3 tipPosition = activeProbeTipT.position + activeProbeTipT.up * 0.2f; // add 200 um to get to the start of the recording region
7378

@@ -132,6 +137,9 @@ private bool UpdateCameraPosition()
132137
/// </summary>
133138
private void RenderAnnotationLayer()
134139
{
140+
// prevent use of annotation dataset until it is loaded properly
141+
if (!loaded) return;
142+
135143
// Render sagittal slice
136144
for (int x = 0; x < baseSize[0]; x++)
137145
{
@@ -159,9 +167,12 @@ public void ToggleSliceVisibility(bool visible)
159167
localPrefs.SetSlice3D(visible);
160168
sagittalSliceGO.SetActive(visible);
161169
coronalSliceGO.SetActive(visible);
162-
// Force everything to render
163-
UpdateCameraPosition();
164-
UpdateSlicePosition();
165-
RenderAnnotationLayer();
170+
if (visible)
171+
{
172+
// Force everything to render
173+
UpdateCameraPosition();
174+
UpdateSlicePosition();
175+
RenderAnnotationLayer();
176+
}
166177
}
167178
}

Assets/Scripts/TrajectoryPlannerManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private void LoadAnnotationDatasetCompleted()
145145
datasetIndexes_bytes = null;
146146
inPlaneSlice.StartAnnotationDataset();
147147

148-
localPrefs.AsyncStart();
148+
//localPrefs.AsyncStart();
149149
sliceRenderer.AsyncStart();
150150
}
151151

Assets/vbl-core

0 commit comments

Comments
 (0)