Skip to content

Commit bb04b1b

Browse files
committed
Fixing a bug that caused slice renderer shader properties to activate even when disabled
1 parent f060226 commit bb04b1b

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

Assets/Scripts/TrajectoryPlanner/TP_SliceRenderer.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,28 @@ private void Update()
144144
/// </summary>
145145
public void UpdateSlicePosition()
146146
{
147-
ProbeManager activeProbeManager = tpmanager.GetActiveProbeManager();
148-
if (activeProbeManager == null) return;
147+
if (localPrefs.GetSlice3D() > 0)
148+
{
149+
ProbeManager activeProbeManager = tpmanager.GetActiveProbeManager();
150+
if (activeProbeManager == null) return;
149151

150-
// the actual tip
151-
Vector3 probeTipWorld = activeProbeManager.GetProbeController().ProbeTipT.position;
152-
// position the slices along the real tip in world space
153-
coronalSliceGO.transform.position = new Vector3(0f, 0f, probeTipWorld.z);
154-
sagittalSliceGO.transform.position = new Vector3(probeTipWorld.x, 0f, 0f);
152+
// the actual tip
153+
Vector3 probeTipWorld = activeProbeManager.GetProbeController().ProbeTipT.position;
154+
// position the slices along the real tip in world space
155+
coronalSliceGO.transform.position = new Vector3(0f, 0f, probeTipWorld.z);
156+
sagittalSliceGO.transform.position = new Vector3(probeTipWorld.x, 0f, 0f);
155157

156-
// for CCF coordinates
157-
(Vector3 tipCoordWorld, _, _) = activeProbeManager.GetProbeController().GetTipWorldU();
158+
// for CCF coordinates
159+
(Vector3 tipCoordWorld, _, _) = activeProbeManager.GetProbeController().GetTipWorldU();
158160

159-
apWorldmm = tipCoordWorld.z + 6.6f;
160-
coronalSliceMaterial.SetFloat("_SlicePosition", apWorldmm / 13.2f);
161+
apWorldmm = tipCoordWorld.z + 6.6f;
162+
coronalSliceMaterial.SetFloat("_SlicePosition", apWorldmm / 13.2f);
161163

162-
mlWorldmm = -(tipCoordWorld.x - 5.7f);
163-
saggitalSliceMaterial.SetFloat("_SlicePosition", mlWorldmm / 11.4f);
164+
mlWorldmm = -(tipCoordWorld.x - 5.7f);
165+
saggitalSliceMaterial.SetFloat("_SlicePosition", mlWorldmm / 11.4f);
164166

165-
UpdateNodeModelSlicing();
167+
UpdateNodeModelSlicing();
168+
}
166169
}
167170

168171
private void UpdateCameraPosition()
@@ -193,7 +196,7 @@ private void UpdateCameraPosition()
193196
UpdateNodeModelSlicing();
194197
}
195198

196-
private void UpdateNodeModelSlicing()
199+
private void UpdateNodeModelSlicing()
197200
{
198201
// Update the renderers on the node objects
199202
foreach (CCFTreeNode node in modelControl.GetDefaultLoadedNodes())
@@ -224,6 +227,7 @@ private void ClearNodeModelSlicing()
224227

225228
public void ToggleSliceVisibility(int sliceType)
226229
{
230+
Debug.Log(sliceType);
227231
localPrefs.SetSlice3D(sliceType);
228232

229233
if (sliceType==0)

0 commit comments

Comments
 (0)