From 982b39631c8d9ff3b042e198f3b3480c2d62bae8 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 7 Feb 2020 12:18:17 -0500 Subject: [PATCH] Fixes for changes made in V13 - Hand ray transform not being well aligned to tracking origin - Corrected changes to hand joint rotations - Updated version number to 0.4.4 --- .../Input/Controllers/OculusQuestController.cs | 14 ++++++-------- .../Scripts/Input/Controllers/OculusQuestHand.cs | 14 +++++++++----- .../Scripts/Input/OculusQuestInputManager.cs | 4 ++-- Assets/Resources/OVRBuildConfig.asset | 2 +- ProjectSettings/ProjectSettings.asset | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestController.cs b/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestController.cs index 9f10b6a..6bbf28f 100644 --- a/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestController.cs +++ b/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestController.cs @@ -81,9 +81,9 @@ public override void SetupDefaultInteractions(Handedness controllerHandedness) /// Update the controller data from the provided platform state /// /// The InteractionSourceState retrieved from the platform - public void UpdateController(OVRCameraRig ovrRigRoot, OVRInput.Controller ovrController) + public void UpdateController(OVRInput.Controller ovrController, Transform trackingRoot) { - if (!Enabled || ovrRigRoot == null) + if (!Enabled || trackingRoot == null) { return; } @@ -91,22 +91,20 @@ public void UpdateController(OVRCameraRig ovrRigRoot, OVRInput.Controller ovrCon IsPositionAvailable = OVRInput.GetControllerPositionValid(ovrController); IsRotationAvailable = OVRInput.GetControllerOrientationValid(ovrController); - Transform playSpaceTransform = ovrRigRoot.transform; - // Update transform Vector3 localPosition = OVRInput.GetLocalControllerPosition(ovrController); - Vector3 worldPosition = playSpaceTransform.TransformPoint(localPosition); + Vector3 worldPosition = trackingRoot.TransformPoint(localPosition); // Debug.Log("Controller " + Handedness + " - local: " + localPosition + " - world: " + worldPosition); Quaternion localRotation = OVRInput.GetLocalControllerRotation(ovrController); - Quaternion worldRotation = playSpaceTransform.rotation * localRotation; + Quaternion worldRotation = trackingRoot.rotation * localRotation; // Update velocity Vector3 localVelocity = OVRInput.GetLocalControllerVelocity(ovrController); - Velocity = playSpaceTransform.TransformDirection(localVelocity); + Velocity = trackingRoot.TransformDirection(localVelocity); Vector3 localAngularVelocity = OVRInput.GetLocalControllerAngularVelocity(ovrController); - AngularVelocity = playSpaceTransform.TransformDirection(localAngularVelocity); + AngularVelocity = trackingRoot.TransformDirection(localAngularVelocity); UpdateJointPoses(); diff --git a/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestHand.cs b/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestHand.cs index 9bec08c..fb8d234 100644 --- a/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestHand.cs +++ b/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/Controllers/OculusQuestHand.cs @@ -84,7 +84,7 @@ public override bool IsInPointingPose /// Update the controller data from the provided platform state /// /// The InteractionSourceState retrieved from the platform - public void UpdateController(OVRHand hand, OVRSkeleton ovrSkeleton) + public void UpdateController(OVRHand hand, OVRSkeleton ovrSkeleton, Transform trackingOrigin) { if (!Enabled || hand == null || ovrSkeleton == null) { @@ -101,8 +101,12 @@ public void UpdateController(OVRHand hand, OVRSkeleton ovrSkeleton) if (isTracked) { // Leverage Oculus Platform Hand Ray - instead of simulating it in a crummy way - currentPointerPose.Position = hand.PointerPose.position; - currentPointerPose.Rotation = hand.PointerPose.rotation; + currentPointerPose.Position = trackingOrigin.TransformPoint(hand.PointerPose.position); + + Vector3 pointerForward = trackingOrigin.TransformDirection(hand.PointerPose.forward); + Vector3 pointerUp = trackingOrigin.TransformDirection(hand.PointerPose.up); + + currentPointerPose.Rotation = Quaternion.LookRotation(pointerForward, pointerUp); currentGripPose = jointPoses[TrackedHandJoint.Palm]; @@ -237,14 +241,14 @@ protected void UpdateBone(OVRBone bone) boneRotation *= Quaternion.Euler(180f, 0f, 0f); // Rotate palm 90 degrees on y to align x with right - boneRotation *= Quaternion.Euler(0f, 90f, 0f); + boneRotation *= Quaternion.Euler(0f, -90, 0f); } else { // Right Up direction is correct // Rotate palm 90 degrees on y to align x with right - boneRotation *= Quaternion.Euler(0f, -90f, 0f); + boneRotation *= Quaternion.Euler(0f, 90f, 0f); } UpdateJointPose(joint, boneTransform.position, boneRotation); diff --git a/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/OculusQuestInputManager.cs b/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/OculusQuestInputManager.cs index 0d78023..31918d5 100644 --- a/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/OculusQuestInputManager.cs +++ b/Assets/MixedRealityToolkit.ThirdParty/OculusQuestInput/Scripts/Input/OculusQuestInputManager.cs @@ -156,7 +156,7 @@ protected void UpdateController(OVRInput.Controller controller, Handedness hande if (OVRInput.IsControllerConnected(controller) && OVRInput.GetControllerPositionTracked(controller)) { var touchController = GetOrAddController(handedness); - touchController.UpdateController(cameraRig, controller); + touchController.UpdateController(controller, cameraRig.trackingSpace); } else { @@ -239,7 +239,7 @@ protected void UpdateHand(OVRHand ovrHand, OVRSkeleton ovrSkeleton, Handedness h if (ovrHand.IsTracked) { var hand = GetOrAddHand(handedness); - hand.UpdateController(ovrHand, ovrSkeleton); + hand.UpdateController(ovrHand, ovrSkeleton, cameraRig.trackingSpace); } else { diff --git a/Assets/Resources/OVRBuildConfig.asset b/Assets/Resources/OVRBuildConfig.asset index e880639..cf5cd6c 100644 --- a/Assets/Resources/OVRBuildConfig.asset +++ b/Assets/Resources/OVRBuildConfig.asset @@ -12,6 +12,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20553fac56ec59645857c0732b787431, type: 3} m_Name: OVRBuildConfig m_EditorClassIdentifier: - androidSDKPath: C:\Users\eprov\AppData\Local\Android\sdk + androidSDKPath: gradlePath: jdkPath: diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index d1a5588..de53480 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -118,7 +118,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 0.4 + bundleVersion: 0.4.4 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0