Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue where Controller Visuals weren't initialized before OnSourceDetected #10625

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,23 @@ protected override bool TryRenderControllerModel(System.Type controllerType, Inp
}
}

private async void TryRenderControllerModelFromOculus()
private void TryRenderControllerModelFromOculus()
{
await WaitForOculusVisuals();
OculusXRSDKDeviceManager deviceManager = CoreServices.GetInputSystemDataProvider<OculusXRSDKDeviceManager>();
RogPodge marked this conversation as resolved.
Show resolved Hide resolved

if(deviceManager.IsNotNull())
{
GameObject platformVisualization = null;
if (ControllerHandedness == Handedness.Left)
{
platformVisualization = deviceManager.leftControllerHelper.gameObject;
}
else if (ControllerHandedness == Handedness.Right)
{
platformVisualization = deviceManager.rightControllerHelper.gameObject;
}
RegisterControllerVisualization(platformVisualization);
}

if (this != null)
{
Expand All @@ -127,18 +141,7 @@ private async void TryRenderControllerModelFromOculus()
}
}

private const int ControllerInitializationTimeout = 1000;
private async Task WaitForOculusVisuals()
{
int timeWaited = 0;
while (OculusControllerVisualization == null || timeWaited > ControllerInitializationTimeout)
{
await Task.Delay(100);
timeWaited += 100;
}
}

internal void RegisterControllerVisualization(GameObject visualization)
private void RegisterControllerVisualization(GameObject visualization)
{
OculusControllerVisualization = visualization;
if (GetControllerVisualizationProfile() != null &&
Expand Down
32 changes: 2 additions & 30 deletions Assets/MRTK/Providers/Oculus/XRSDK/OculusXRSDKDeviceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public override void Initialize()
private readonly Dictionary<Handedness, OculusHand> trackedHands = new Dictionary<Handedness, OculusHand>();

private OVRCameraRig cameraRig;
private OVRControllerHelper leftControllerHelper;
private OVRControllerHelper rightControllerHelper;
internal OVRControllerHelper leftControllerHelper;
internal OVRControllerHelper rightControllerHelper;

private OVRHand rightHand;
private OVRSkeleton rightSkeleton;
Expand Down Expand Up @@ -93,34 +93,6 @@ public override bool CheckCapability(MixedRealityCapability capability)

#region Controller Utilities

#if OCULUSINTEGRATION_PRESENT
/// <inheritdoc />
protected override GenericXRSDKController GetOrAddController(InputDevice inputDevice)
{
GenericXRSDKController controller = base.GetOrAddController(inputDevice);

if (!cameraRig.IsNull() && controller is OculusXRSDKTouchController oculusTouchController && oculusTouchController.OculusControllerVisualization == null)
{
GameObject platformVisualization = null;
if (oculusTouchController.ControllerHandedness == Handedness.Left)
{
platformVisualization = leftControllerHelper.gameObject;
}
if (oculusTouchController.ControllerHandedness == Handedness.Right)
{
platformVisualization = rightControllerHelper.gameObject;
}

if(platformVisualization != null)
{
oculusTouchController.RegisterControllerVisualization(platformVisualization);
}
}

return controller;
}
#endif

/// <inheritdoc />
protected override Type GetControllerType(SupportedControllerType supportedControllerType)
{
Expand Down