Skip to content

Commit

Permalink
Improve scene cleanup after turning off VR
Browse files Browse the repository at this point in the history
  • Loading branch information
smlpt committed Nov 18, 2024
1 parent 0263305 commit 2c82070
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ open class CellTrackingBase(

Thread.sleep((1000.0f/volumesPerSecond).toLong())
}
logger.info("CellTracking updater thread has stopped.")
}
}

Expand Down Expand Up @@ -445,10 +446,6 @@ open class CellTrackingBase(
trackFileWriter.write("$tp\t${p.x()}\t${p.y()}\t${p.z()}\t${hedgehogId}\t$parentId\t0\t0\n")
}
}


// mainTrack.let { sciview.addNode(it, parent = volume) }

trackFileWriter.close()
}

Expand All @@ -457,8 +454,6 @@ open class CellTrackingBase(
* This method should be overridden to extend
*/
open fun stop() {
hmd.close()
logger.info("Shut down HMD and keybindings.")
}

}
16 changes: 6 additions & 10 deletions src/main/kotlin/sc/iview/commands/demo/advanced/EyeTracking.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ class EyeTracking(
hmd.addKeyBinding("toggle_tracking", keybindingTracking)

volume.visible = true
// volume.runRecursive { it.visible = true }
playing = true
}

Expand Down Expand Up @@ -258,39 +257,36 @@ class EyeTracking(
val direction = (pointWorld - headCenter).normalize()

if (tracking) {
// log.info("Starting spine from $headCenter to $pointWorld")
addSpine(headCenter, direction, volume, gaze.confidence, volume.viewerState.currentTimepoint)
}
}
}

// else -> {gaze-> }
}

logger.info("Calibration routine done.")
}

// bind calibration start to menu key on controller

}
}
hmd.addBehaviour("start_calibration", startCalibration)
hmd.addKeyBinding("start_calibration", keybindingCalibration)
}

/** Toggles the VR rendering, cleans up eyetracking-related scene objects and removes the light tetrahedron
* that was created for the calibration routine. */
override fun stop() {
hmd.close()
logger.info("Shut down HMD and keybindings.")
sciview.toggleVRRendering()
logger.info("Shut down eye tracking environment and disabled VR.")
pupilTracker.unsubscribeFrames()
cellTrackingActive = false
logger.info("Stopped volume and hedgehog updater thread.")
lightTetrahedron.forEach { sciview.deleteNode(it) }
sciview.deleteNode(sciview.find("Shell"))
sciview.deleteNode(sciview.find("eyeFrames"))
listOf(referenceTarget, calibrationTarget, laser, debugBoard, hedgehogs).forEach {
sciview.deleteNode(it)
}
logger.info("Successfully cleaned up eye tracking environemt.")
sciview.toggleVRRendering()
logger.info("Shut down eye tracking environment and disabled VR.")
}

}

0 comments on commit 2c82070

Please sign in to comment.