Skip to content

Commit c162a65

Browse files
committed
Simplify logic
1 parent 6ed24ac commit c162a65

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Assets/MRTK/Core/Providers/BaseEyeGazeDataProvider.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Microsoft.MixedReality.Toolkit.Input
1010
{
11+
/// <summary>
12+
/// Provides some predefined parameters for eye gaze smoothing and saccade detection.
13+
/// </summary>
1114
public abstract class BaseEyeGazeDataProvider : BaseInputDeviceManager, IMixedRealityEyeGazeDataProvider, IMixedRealityEyeSaccadeProvider
1215
{
1316
/// <summary>
@@ -106,7 +109,7 @@ protected Ray SmoothGaze(Ray? newGaze)
106109
// apart, we check for clusters of gaze points instead.
107110
// 1. If the user's gaze points are far enough apart, this may be a saccade, but also could be an outlier.
108111
// So, let's mark it as a potential saccade.
109-
if ((IsSaccading(oldGaze.Value, newGaze.Value) && (confidenceOfSaccade == 0)))
112+
if (IsSaccading(oldGaze.Value, newGaze.Value) && confidenceOfSaccade == 0)
110113
{
111114
confidenceOfSaccade++;
112115
saccade_initialGazePoint = oldGaze.Value;
@@ -115,7 +118,7 @@ protected Ray SmoothGaze(Ray? newGaze)
115118
}
116119
// 2. If we have a potential saccade marked, let's check if the new points are within the proximity of
117120
// the initial saccade point.
118-
else if ((confidenceOfSaccade > 0) && (confidenceOfSaccade < confidenceOfSaccadeThreshold))
121+
else if (confidenceOfSaccade > 0 && confidenceOfSaccade < confidenceOfSaccadeThreshold)
119122
{
120123
confidenceOfSaccade++;
121124

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public WindowsMixedRealityEyeGazeDataProvider(
8282
#region IMixedRealityCapabilityCheck Implementation
8383

8484
/// <inheritdoc />
85-
public bool CheckCapability(MixedRealityCapability capability) => eyesApiAvailable ? capability == MixedRealityCapability.EyeTracking : false;
85+
public bool CheckCapability(MixedRealityCapability capability) => eyesApiAvailable && capability == MixedRealityCapability.EyeTracking;
8686

8787
#endregion IMixedRealityCapabilityCheck Implementation
8888

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,18 @@ public override void Update()
7878

7979
Service?.EyeGazeProvider?.UpdateEyeTrackingStatus(this, true);
8080

81-
if (centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazeTracked, out bool gazeTracked) && gazeTracked)
81+
if (centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazeTracked, out bool gazeTracked) && gazeTracked
82+
&& centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazePosition, out Vector3 eyeGazePosition)
83+
&& centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazeRotation, out Quaternion eyeGazeRotation))
8284
{
83-
Vector3 eyeGazePosition;
84-
Quaternion eyeGazeRotation;
85-
if (centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazePosition, out eyeGazePosition) && centerEye.TryGetFeatureValue(WindowsMRUsages.EyeGazeRotation, out eyeGazeRotation))
86-
{
87-
Ray newGaze = new Ray(eyeGazePosition, eyeGazeRotation * Vector3.forward);
88-
89-
if (SmoothEyeTracking)
90-
{
91-
newGaze = SmoothGaze(newGaze);
92-
}
85+
Ray newGaze = new Ray(eyeGazePosition, eyeGazeRotation * Vector3.forward);
9386

94-
Service?.EyeGazeProvider?.UpdateEyeGaze(this, newGaze, DateTime.UtcNow);
87+
if (SmoothEyeTracking)
88+
{
89+
newGaze = SmoothGaze(newGaze);
9590
}
91+
92+
Service?.EyeGazeProvider?.UpdateEyeGaze(this, newGaze, DateTime.UtcNow);
9693
}
9794
}
9895
}

0 commit comments

Comments
 (0)