Skip to content

Commit 6957444

Browse files
Merge remote-tracking branch 'public/prerelease/2.3.0_stabilization' into user/bethalha/bc_example_patch
2 parents bbdb572 + 3e1e9b2 commit 6957444

File tree

76 files changed

+3340
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3340
-347
lines changed

Assets/MixedRealityToolkit.Examples/Demos/Input/Scenes/InputActions/InputActions.MixedRealityControllerMappingProfile.asset

Lines changed: 468 additions & 3 deletions
Large diffs are not rendered by default.

Assets/MixedRealityToolkit.Providers/OpenVR/OpenVRDeviceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace Microsoft.MixedReality.Toolkit.OpenVR.Input
1212
{
1313
/// <summary>
14-
/// Manages Open VR Devices using unity's input system.
14+
/// Manages Open VR devices using Unity's input system.
1515
/// </summary>
1616
[MixedRealityDataProvider(
1717
typeof(IMixedRealityInputSystem),

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/Shared/Extensions.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
5+
using Microsoft.MixedReality.Toolkit.Utilities;
6+
#if WINDOWS_UWP
7+
using Windows.UI.Input.Spatial;
8+
#elif DOTNETWINRT_PRESENT
9+
using Microsoft.Windows.UI.Input.Spatial;
10+
#endif
11+
#endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
12+
13+
namespace Microsoft.MixedReality.Toolkit.WindowsMixedReality
14+
{
15+
/// <summary>
16+
/// Provides useful extensions for Windows-defined types.
17+
/// </summary>
18+
public static class WindowsExtensions
19+
{
20+
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
21+
/// <summary>
22+
/// Converts a platform <see cref="SpatialInteractionSourceHandedness"/> into
23+
/// the equivalent value in MRTK's defined <see cref="Handedness"/>.
24+
/// </summary>
25+
/// <param name="handedness">The handedness value to convert.</param>
26+
/// <returns>The converted value in the new type.</returns>
27+
public static Handedness ToMRTKHandedness(this SpatialInteractionSourceHandedness handedness)
28+
{
29+
switch (handedness)
30+
{
31+
case SpatialInteractionSourceHandedness.Left:
32+
return Handedness.Left;
33+
case SpatialInteractionSourceHandedness.Right:
34+
return Handedness.Right;
35+
case SpatialInteractionSourceHandedness.Unspecified:
36+
default:
37+
return Handedness.None;
38+
}
39+
}
40+
#endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
41+
}
42+
}

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/Shared/Extensions/WindowsExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/Shared/Profiles/DefaultWindowsMixedRealityCameraSettingsProfile.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ MonoBehaviour:
1414
m_EditorClassIdentifier:
1515
isCustomProfile: 0
1616
renderFromPVCameraForMixedRealityCapture: 0
17+
reprojectionMethod: 0

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XR2018/WindowsMixedRealityArticulatedHand.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
namespace Microsoft.MixedReality.Toolkit.WindowsMixedReality.Input
2828
{
2929
/// <summary>
30-
/// A Windows Mixed Reality Controller Instance.
30+
/// A Windows Mixed Reality articulated hand instance.
3131
/// </summary>
3232
[MixedRealityController(
3333
SupportedControllerType.ArticulatedHand,
@@ -73,6 +73,7 @@ public bool TryGetJoint(TrackedHandJoint joint, out MixedRealityPose pose)
7373

7474
#endregion IMixedRealityHand Implementation
7575

76+
/// <inheritdoc/>
7677
public override bool IsInPointingPose
7778
{
7879
get
@@ -170,8 +171,6 @@ protected void InitializeUVs(Vector3[] neutralPoseVertices)
170171
float minY = neutralPoseVertices[0].y;
171172
float maxY = minY;
172173

173-
float maxMagnitude = 0.0f;
174-
175174
for (int ix = 1; ix < neutralPoseVertices.Length; ix++)
176175
{
177176
Vector3 p = neutralPoseVertices[ix];
@@ -184,11 +183,8 @@ protected void InitializeUVs(Vector3[] neutralPoseVertices)
184183
{
185184
maxY = p.y;
186185
}
187-
float d = p.x * p.x + p.y * p.y;
188-
if (d > maxMagnitude) maxMagnitude = d;
189186
}
190187

191-
maxMagnitude = Mathf.Sqrt(maxMagnitude);
192188
float scale = 1.0f / (maxY - minY);
193189

194190
handMeshUVs = new Vector2[neutralPoseVertices.Length];
@@ -231,7 +227,14 @@ private void UpdateHandData(InteractionSourceState interactionSourceState)
231227
HandPose handPose = sourceState.TryGetHandPose();
232228

233229
#if WINDOWS_UWP
234-
if (CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.EnableHandMeshVisualization)
230+
MixedRealityHandTrackingProfile handTrackingProfile = null;
231+
MixedRealityInputSystemProfile inputSystemProfile = CoreServices.InputSystem?.InputSystemProfile;
232+
if (inputSystemProfile != null)
233+
{
234+
handTrackingProfile = inputSystemProfile.HandTrackingProfile;
235+
}
236+
237+
if (handTrackingProfile != null && handTrackingProfile.EnableHandMeshVisualization)
235238
{
236239
// Accessing the hand mesh data involves copying quite a bit of data, so only do it if application requests it.
237240
if (handMeshObserver == null && !hasRequestedHandMeshObserver)

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XR2018/WindowsMixedRealityUtilitiesProvider.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
namespace Microsoft.MixedReality.Toolkit.WindowsMixedReality
1212
{
13+
/// <summary>
14+
/// An implementation of <see cref="IWindowsMixedRealityUtilitiesProvider"/> for Unity's in-box XR pipeline.
15+
/// </summary>
1316
public class WindowsMixedRealityUtilitiesProvider : IWindowsMixedRealityUtilitiesProvider
1417
{
1518
/// <inheritdoc />

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XRSDK/Controllers.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.MixedReality.Toolkit.Input;
5+
using Microsoft.MixedReality.Toolkit.Utilities;
6+
using Microsoft.MixedReality.Toolkit.XRSDK.Input;
7+
using UnityEngine;
8+
using UnityEngine.XR;
9+
10+
#if WMR_ENABLED
11+
using Unity.XR.WindowsMR;
12+
#endif // WMR_ENABLED
13+
14+
namespace Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality
15+
{
16+
/// <summary>
17+
/// A Windows Mixed Reality source instance.
18+
/// </summary>
19+
public abstract class BaseWindowsMixedRealityXRSDKSource : GenericXRSDKController
20+
{
21+
/// <summary>
22+
/// Constructor.
23+
/// </summary>
24+
protected BaseWindowsMixedRealityXRSDKSource(TrackingState trackingState, Handedness sourceHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
25+
: base(trackingState, sourceHandedness, inputSource, interactions) { }
26+
27+
#if WMR_ENABLED
28+
private Vector3 currentPointerPosition = Vector3.zero;
29+
private Quaternion currentPointerRotation = Quaternion.identity;
30+
private MixedRealityPose currentPointerPose = MixedRealityPose.ZeroIdentity;
31+
32+
/// <summary>
33+
/// Update spatial pointer and spatial grip data.
34+
/// </summary>
35+
protected override void UpdatePoseData(MixedRealityInteractionMapping interactionMapping, InputDevice inputDevice)
36+
{
37+
Debug.Assert(interactionMapping.AxisType == AxisType.SixDof);
38+
39+
base.UpdatePoseData(interactionMapping, inputDevice);
40+
41+
// Update the interaction data source
42+
switch (interactionMapping.InputType)
43+
{
44+
case DeviceInputType.SpatialPointer:
45+
if (inputDevice.TryGetFeatureValue(WindowsMRUsages.PointerPosition, out currentPointerPosition))
46+
{
47+
currentPointerPose.Position = MixedRealityPlayspace.TransformPoint(currentPointerPosition);
48+
}
49+
50+
if (inputDevice.TryGetFeatureValue(WindowsMRUsages.PointerRotation, out currentPointerRotation))
51+
{
52+
currentPointerPose.Rotation = MixedRealityPlayspace.Rotation * currentPointerRotation;
53+
}
54+
55+
interactionMapping.PoseData = currentPointerPose;
56+
57+
// If our value changed raise it.
58+
if (interactionMapping.Changed)
59+
{
60+
// Raise input system event if it's enabled
61+
CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.PoseData);
62+
}
63+
break;
64+
default:
65+
return;
66+
}
67+
}
68+
#endif // WMR_ENABLED
69+
}
70+
}

0 commit comments

Comments
 (0)