Skip to content

Commit 5489c4b

Browse files
committed
Rotate grip pose to align palm pose with other joints
1 parent 143d27a commit 5489c4b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

0 commit comments

Comments
 (0)