Description

MyVirtualGrasp is a public script inherited from VG_MainScript, which encodes the main functionality of VirtualGrasp.

In contrast to MyVirtualGrasp, this component uses Burst Jobs to isolate VG updates on seperate threads.

Burst Configuration

The only additional element to to the standard GUI elements is the “Burst Parameters” section.

VG_MyVirtualGraspBurst Settings.
"Save Debug Files" must be enabled Debug Settings to prepare the files.

As you can see in the MyVirtualGraspBurst.cs script, you can control the behavior by selecting your number of threads as follows:

  • If the number of threads is 0, VirtualGrasp will run on the MainThread. That means the behavior is exactly equal to MyVirtualGrasp.cs.
  • If the number of threads is 1, VirtualGrasp will spawn a SingleWorkerThread with Burst. You need to have Burst installed and the define enabled in MyVirtualGraspBurst.cs.
  • If the number of threads is N>1, VirtualGrasp will spawn N MultipleWorkerThreads with Burst. You need to have Burst installed and the define enabled in MyVirtualGraspBurst.cs.

Burst Communication with VG

VirtualGrasp works in mainly three steps:

  1. send incoming data from Unity to VirtualGrasp,
  2. compute the hand and object animations in VirtualGrasp,
  3. send outgoing data from VirtualGrasp back to Unity and reflect it there.

Therefore, the API offers isolated functions specifically for multi-threading for those three steps:

  1. IsolatedUpdateDataIn
  2. IsolatedUpdate
  3. IsolatedUpdateDataOut

While 1. and 3. are merely data transfer tasks, 2. is the “heavy” lifting and the main blocker on Unity’s main thread.

In MyVirtualGraspBurst.cs 1. and 3. are therefore called in the FixedUpdate() loop, while 2. is placed on a separate thread.