Skip to content

Commit d99042c

Browse files
Merge branch 'MRTK-Version-Next' into vNext-WMRController_Position
# Conflicts: # Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealityController.cs
2 parents 3f80fb6 + 22eae0a commit d99042c

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealityController.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,35 @@ public void UpdateController(InteractionSourceState interactionSourceState)
112112
private void UpdateControllerData(InteractionSourceState interactionSourceState)
113113
{
114114
var lastState = TrackingState;
115+
var sourceKind = interactionSourceState.source.kind;
115116

116-
IsPositionAvailable = interactionSourceState.sourcePose.TryGetPosition(out currentControllerPosition);
117-
118-
if (IsPositionAvailable)
117+
if ((sourceKind == InteractionSourceKind.Hand) ||
118+
((sourceKind == InteractionSourceKind.Controller) && interactionSourceState.source.supportsPointing))
119119
{
120-
TrackingState = TrackingState.Tracked;
121-
IsPositionApproximate = interactionSourceState.sourcePose.positionAccuracy == InteractionSourcePositionAccuracy.Approximate;
120+
// The source is either a hand or a controller that supports pointing.
121+
// We can now check for position and rotation.
122+
IsPositionAvailable = interactionSourceState.sourcePose.TryGetPosition(out currentControllerPosition);
123+
124+
if (IsPositionAvailable)
125+
{
126+
IsPositionApproximate = (interactionSourceState.sourcePose.positionAccuracy == InteractionSourcePositionAccuracy.Approximate);
127+
}
128+
else
129+
{
130+
IsPositionApproximate = false;
131+
}
132+
133+
IsRotationAvailable = interactionSourceState.sourcePose.TryGetRotation(out currentControllerRotation);
134+
135+
// Devices are considered tracked if we receive position OR rotation data from the sensors.
136+
TrackingState = (IsPositionAvailable || IsRotationAvailable) ? TrackingState.Tracked : TrackingState.NotTracked;
122137
}
123138
else
124139
{
125-
TrackingState = TrackingState.NotTracked;
126-
IsPositionApproximate = true;
140+
// The input source does not support tracking.
141+
TrackingState = TrackingState.NotApplicable;
127142
}
128143

129-
IsRotationAvailable = interactionSourceState.sourcePose.TryGetRotation(out currentControllerRotation);
130-
131144
lastControllerPose = currentControllerPose;
132145
currentControllerPose.Position = currentControllerPosition;
133146
currentControllerPose.Rotation = currentControllerRotation;

0 commit comments

Comments
 (0)