Skip to content

Commit 666b0d4

Browse files
committed
Properly transform eye gaze position by MixedRealityPlayspace
1 parent a2d8f8a commit 666b0d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Assets/MRTK/Providers/WindowsMixedReality/XRSDK/WindowsMixedRealityEyeGazeDataProvider.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public override void Update()
129129
centerEye = InputDevices.GetDeviceAtXRNode(XRNode.CenterEye);
130130
if (!centerEye.isValid)
131131
{
132+
Service?.EyeGazeProvider?.UpdateEyeTrackingStatus(this, false);
132133
return;
133134
}
134135
}
@@ -141,11 +142,15 @@ public override void Update()
141142

142143
Service?.EyeGazeProvider?.UpdateEyeTrackingStatus(this, true);
143144

144-
if (centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazeTracked, out bool gazeTracked) && gazeTracked
145+
if (centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazeTracked, out bool gazeTracked)
146+
&& gazeTracked
145147
&& centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazePosition, out Vector3 eyeGazePosition)
146148
&& centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazeRotation, out Quaternion eyeGazeRotation))
147149
{
148-
Ray newGaze = new Ray(eyeGazePosition, eyeGazeRotation * Vector3.forward);
150+
Vector3 worldPosition = MixedRealityPlayspace.TransformPoint(eyeGazePosition);
151+
Vector3 worldRotation = MixedRealityPlayspace.TransformDirection(eyeGazeRotation * Vector3.forward);
152+
153+
Ray newGaze = new Ray(worldPosition, worldRotation);
149154

150155
if (SmoothEyeTracking)
151156
{

0 commit comments

Comments
 (0)