Skip to content

Commit 52c8c2d

Browse files
authored
Merge pull request #7227 from keveleigh/xr-sdk-input-palm-rotation
Add offset for correct palm rotation on XR SDK
2 parents 143d27a + de1b1ef commit 52c8c2d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ MSBuildForUnity.Common.props
100100
/*.msb4u.sln.meta
101101
*.msb4u.sln.meta
102102
Dependencies*
103+
Nuget.config*

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XRSDK/Controllers/WindowsMixedRealityXRSDKArticulatedHand.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public WindowsMixedRealityXRSDKArticulatedHand(TrackingState trackingState, Hand
4444
private static readonly HandFinger[] handFingers = Enum.GetValues(typeof(HandFinger)) as HandFinger[];
4545
private readonly List<Bone> fingerBones = new List<Bone>();
4646

47+
// The rotation offset between the reported grip pose of a hand and the palm joint orientation.
48+
// These values were calculated by comparing the platform's reported grip pose and palm pose.
49+
private static readonly Quaternion rightPalmOffset = new Quaternion(Mathf.Sqrt(0.125f), Mathf.Sqrt(0.125f), -Mathf.Sqrt(1.5f) / 2.0f, Mathf.Sqrt(1.5f) / 2.0f);
50+
private static readonly Quaternion leftPalmOffset = new Quaternion(Mathf.Sqrt(0.125f), -Mathf.Sqrt(0.125f), Mathf.Sqrt(1.5f) / 2.0f, Mathf.Sqrt(1.5f) / 2.0f);
51+
4752
#if WINDOWS_UWP && WMR_ENABLED
4853
private readonly List<object> states = new List<object>();
4954
#endif // WINDOWS_UWP && WMR_ENABLED
@@ -126,7 +131,9 @@ private void UpdateHandData(InputDevice inputDevice)
126131
}
127132

128133
// Unity doesn't provide a palm joint, so we synthesize one here
129-
unityJointPoses[TrackedHandJoint.Palm] = CurrentControllerPose;
134+
MixedRealityPose palmPose = CurrentControllerPose;
135+
palmPose.Rotation *= (ControllerHandedness == Handedness.Left ? leftPalmOffset : rightPalmOffset);
136+
unityJointPoses[TrackedHandJoint.Palm] = palmPose;
130137
}
131138
}
132139

Assets/MixedRealityToolkit/Definitions/Utilities/ArticulatedHandPose.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static ArticulatedHandPose GetGesturePose(GestureId gesture)
215215
return null;
216216
}
217217

218-
#if UNITY_EDITOR
218+
#if UNITY_EDITOR
219219
/// <summary>
220220
/// Load pose data from files.
221221
/// </summary>
@@ -247,7 +247,7 @@ public static void ResetGesturePoses()
247247
{
248248
handPoses.Clear();
249249
}
250-
#endif
250+
#endif
251251

252252
/// Utility class to serialize hand pose as a dictionary with full joint names
253253
[Serializable]

0 commit comments

Comments
 (0)