Skip to content

Commit d2d5651

Browse files
committed
Don't overwrite the actual tracking state
This introduced a bug in the XRI3 migration, because the old base class (ActionBasedController) read this value from the action every frame. The new base class (TrackedPoseDriver) only reads the events when the action state changes.
1 parent 4f5b465 commit d2d5651

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

org.mixedrealitytoolkit.input/Tracking/HandPoseDriver.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,23 @@ public class HandPoseDriver : TrackedPoseDriver
3333
private bool m_firstUpdate = true;
3434
private InputAction m_boundTrackingAction = null;
3535
private InputTrackingState m_trackingState = InputTrackingState.None;
36+
private const InputTrackingState m_polyfillTrackingState = InputTrackingState.Position | InputTrackingState.Rotation;
3637

3738
/// <summary>
3839
/// Expose the tracking state for the hand pose driver, to allow <see cref="TrackedPoseDriverExtensions"/> to query it.
3940
/// </summary>
4041
/// <remarks>
4142
/// Avoid exposing this publicly as this <see cref="HandPoseDriver"/> is a workaround solution to support hand tracking on devices without interaction profiles.
4243
/// </remarks>
43-
internal InputTrackingState CachedTrackingState => m_trackingState;
44+
internal InputTrackingState CachedTrackingState => IsPolyfillDevicePose ? m_polyfillTrackingState : m_trackingState;
4445

4546
/// <summary>
4647
/// Get if the last pose set was from a polyfill device pose. That is, if the last pose originated from the <see cref="XRSubsystemHelpers.HandsAggregator "/>.
4748
/// </summary>
4849
internal bool IsPolyfillDevicePose { get; private set; }
4950

5051
#region Serialized Fields
52+
5153
[Header("Hand Pose Driver Settings")]
5254

5355
[SerializeField, Tooltip("The XRNode associated with this Hand Controller. Expected to be XRNode.LeftHand or XRNode.RightHand.")]
@@ -58,9 +60,11 @@ public class HandPoseDriver : TrackedPoseDriver
5860
/// </summary>
5961
/// <remarks>Expected to be XRNode.LeftHand or XRNode.RightHand.</remarks>
6062
public XRNode HandNode => handNode;
63+
6164
#endregion Serialized Fields
6265

6366
#region TrackedPoseDriver Overrides
67+
6468
/// <inheritdoc />
6569
protected override void PerformUpdate()
6670
{
@@ -94,7 +98,6 @@ protected override void PerformUpdate()
9498
if ((missingPositionController || missingRotationController || IsTrackingNone()) &&
9599
TryGetPolyfillDevicePose(out Pose devicePose))
96100
{
97-
m_trackingState = InputTrackingState.Position | InputTrackingState.Rotation;
98101
IsPolyfillDevicePose = true;
99102
ForceSetLocalTransform(devicePose.position, devicePose.rotation);
100103
}
@@ -103,9 +106,11 @@ protected override void PerformUpdate()
103106
IsPolyfillDevicePose = false;
104107
}
105108
}
109+
106110
#endregion TrackedPoseDriver Overrides
107111

108112
#region Private Functions
113+
109114
/// <summary>
110115
/// Check the tracking state here to account for a bound but untracked interaction profile.
111116
/// This could show up on runtimes where a controller is disconnected, hand tracking spins up,
@@ -278,6 +283,7 @@ private void OnTrackingStateInputCanceled(InputAction.CallbackContext context)
278283
m_trackingState = InputTrackingState.None;
279284
}
280285
}
286+
281287
#endregion Private Functions
282288
}
283289
}

0 commit comments

Comments
 (0)