Skip to content

Commit 332012c

Browse files
author
David Kline
authored
Merge pull request #2709 from Microsoft/mrtk_development
Merge development -> spatial awareness
2 parents 4614372 + 9463dfc commit 332012c

34 files changed

+384
-193
lines changed

Assets/MixedRealityToolkit-SDK/Features/Boundary/System/MixedRealityBoundarySystem.cs renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/MixedRealityBoundaryManager.cs

File renamed without changes.

Assets/MixedRealityToolkit-SDK/Features/Boundary/System/MixedRealityBoundarySystem.cs.meta renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/MixedRealityBoundaryManager.cs.meta

File renamed without changes.

Assets/MixedRealityToolkit-SDK/Features/Boundary/System/README.md renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Mixed Reality Toolkit - SDK - Boundary - System
1+
# Mixed Reality Toolkit - SDK - Boundary
22

33
Default implementation of the Mixed Reality Toolkit boundary system.

Assets/MixedRealityToolkit-SDK/Features/Boundary/System/README.md.meta renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/README.md.meta

File renamed without changes.

Assets/MixedRealityToolkit-SDK/Features/Boundary/System.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Assets/MixedRealityToolkit-SDK/Features/Input/FocusProvider.cs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ private void Awake()
231231
"To create a UIRaycastCamera in your scene, find this Focus Provider GameObject and add one there.");
232232
CreateUiRaycastCamera();
233233
}
234+
235+
foreach (var inputSource in InputSystem.DetectedInputSources)
236+
{
237+
RegisterPointers(inputSource);
238+
}
234239
}
235240

236241
private void Update()
@@ -432,6 +437,23 @@ public bool RegisterPointer(IMixedRealityPointer pointer)
432437
return true;
433438
}
434439

440+
private void RegisterPointers(IMixedRealityInputSource inputSource)
441+
{
442+
// If our input source does not have any pointers, then skip.
443+
if (inputSource.Pointers == null) { return; }
444+
445+
for (int i = 0; i < inputSource.Pointers.Length; i++)
446+
{
447+
RegisterPointer(inputSource.Pointers[i]);
448+
449+
// Special Registration for Gaze
450+
if (inputSource.SourceId == InputSystem.GazeProvider.GazeInputSource.SourceId && gazeProviderPointingData == null)
451+
{
452+
gazeProviderPointingData = new PointerData(inputSource.Pointers[i]);
453+
}
454+
}
455+
}
456+
435457
/// <inheritdoc />
436458
public bool UnregisterPointer(IMixedRealityPointer pointer)
437459
{
@@ -816,30 +838,13 @@ private void UpdateFocusedObjects()
816838

817839
#region ISourceState Implementation
818840

841+
/// <inheritdoc />
819842
public void OnSourceDetected(SourceStateEventData eventData)
820843
{
821-
// If our input source does not have any pointers, then skip.
822-
if (eventData.InputSource.Pointers == null) { return; }
823-
824-
for (var i = 0; i < eventData.InputSource.Pointers.Length; i++)
825-
{
826-
RegisterPointer(eventData.InputSource.Pointers[i]);
827-
828-
// Special Registration for Gaze
829-
if (eventData.InputSource.SourceId == InputSystem.GazeProvider.GazeInputSource.SourceId)
830-
{
831-
Debug.Assert(gazeProviderPointingData == null, "Gaze Provider Pointer Data was already registered!");
832-
833-
if (gazeProviderPointingData == null)
834-
{
835-
gazeProviderPointingData = new PointerData(eventData.InputSource.Pointers[i]);
836-
}
837-
838-
Debug.Assert(gazeProviderPointingData != null);
839-
}
840-
}
844+
RegisterPointers(eventData.InputSource);
841845
}
842846

847+
/// <inheritdoc />
843848
public void OnSourceLost(SourceStateEventData eventData)
844849
{
845850
// If the input source does not have pointers, then skip.

Assets/MixedRealityToolkit-SDK/Features/Input/GazeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ protected override void OnEnable()
268268
}
269269
}
270270

271-
private void Start()
271+
protected void Start()
272272
{
273273
if (cursorPrefab != null)
274274
{

Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/ControllerPoseSynchronizer.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,26 @@ public virtual void OnSourceLost(SourceStateEventData eventData)
119119
}
120120

121121
/// <inheritdoc />
122-
public virtual void OnSourcePoseChanged(SourcePoseEventData eventData)
122+
public virtual void OnSourcePoseChanged(SourcePoseEventData<TrackingState> eventData)
123+
{
124+
if (eventData.SourceData != TrackingState)
125+
{
126+
IsTracked = eventData.SourceData == TrackingState.Tracked;
127+
TrackingState = eventData.SourceData;
128+
}
129+
}
130+
131+
/// <inheritdoc />
132+
public virtual void OnSourcePoseChanged(SourcePoseEventData<Vector2> eventData) { }
133+
134+
/// <inheritdoc />
135+
public virtual void OnSourcePoseChanged(SourcePoseEventData<Vector3> eventData) { }
136+
137+
/// <inheritdoc />
138+
public virtual void OnSourcePoseChanged(SourcePoseEventData<Quaternion> eventData) { }
139+
140+
/// <inheritdoc />
141+
public virtual void OnSourcePoseChanged(SourcePoseEventData<MixedRealityPose> eventData)
123142
{
124143
if (Controller == null ||
125144
eventData.Controller == null ||
@@ -128,16 +147,10 @@ public virtual void OnSourcePoseChanged(SourcePoseEventData eventData)
128147
return;
129148
}
130149

131-
if (eventData.TrackingState != TrackingState)
132-
{
133-
IsTracked = eventData.TrackingState == TrackingState.Tracked;
134-
TrackingState = eventData.TrackingState;
135-
}
136-
137150
if (UseSourcePoseData && TrackingState == TrackingState.Tracked)
138151
{
139-
transform.localPosition = eventData.MixedRealityPose.Position;
140-
transform.localRotation = eventData.MixedRealityPose.Rotation;
152+
transform.localPosition = eventData.SourceData.Position;
153+
transform.localRotation = eventData.SourceData.Rotation;
141154
}
142155
}
143156

Assets/MixedRealityToolkit-SDK/Features/Input/MixedRealityInputManager.cs

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
using Microsoft.MixedReality.Toolkit.InputSystem.Sources;
54
using Microsoft.MixedReality.Toolkit.Core.Definitions.Devices;
65
using Microsoft.MixedReality.Toolkit.Core.Definitions.InputSystem;
76
using Microsoft.MixedReality.Toolkit.Core.Definitions.Utilities;
@@ -12,6 +11,7 @@
1211
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem.Handlers;
1312
using Microsoft.MixedReality.Toolkit.Core.Managers;
1413
using Microsoft.MixedReality.Toolkit.Core.Utilities;
14+
using Microsoft.MixedReality.Toolkit.InputSystem.Sources;
1515
using System;
1616
using System.Collections.Generic;
1717
using UnityEngine;
@@ -50,7 +50,11 @@ public class MixedRealityInputManager : MixedRealityEventManager, IMixedRealityI
5050
private int disabledRefCount;
5151

5252
private SourceStateEventData sourceStateEventData;
53-
private SourcePoseEventData sourcePoseEventData;
53+
private SourcePoseEventData<TrackingState> sourceTrackingEventData;
54+
private SourcePoseEventData<Vector2> sourceVector2EventData;
55+
private SourcePoseEventData<Vector3> sourcePositionEventData;
56+
private SourcePoseEventData<Quaternion> sourceRotationEventData;
57+
private SourcePoseEventData<MixedRealityPose> sourcePoseEventData;
5458

5559
private FocusEventData focusEventData;
5660

@@ -63,13 +67,9 @@ public class MixedRealityInputManager : MixedRealityEventManager, IMixedRealityI
6367
private InputEventData<Quaternion> rotationInputEventData;
6468
private InputEventData<MixedRealityPose> poseInputEventData;
6569

66-
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
67-
6870
private SpeechEventData speechEventData;
6971
private DictationEventData dictationEventData;
7072

71-
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
72-
7373
/// <summary>
7474
/// Current Speech Input Source.
7575
/// </summary>
@@ -184,7 +184,12 @@ private void InitializeInternal()
184184
}
185185

186186
sourceStateEventData = new SourceStateEventData(EventSystem.current);
187-
sourcePoseEventData = new SourcePoseEventData(EventSystem.current);
187+
188+
sourceTrackingEventData = new SourcePoseEventData<TrackingState>(EventSystem.current);
189+
sourceVector2EventData = new SourcePoseEventData<Vector2>(EventSystem.current);
190+
sourcePositionEventData = new SourcePoseEventData<Vector3>(EventSystem.current);
191+
sourceRotationEventData = new SourcePoseEventData<Quaternion>(EventSystem.current);
192+
sourcePoseEventData = new SourcePoseEventData<MixedRealityPose>(EventSystem.current);
188193

189194
focusEventData = new FocusEventData(EventSystem.current);
190195

@@ -197,13 +202,9 @@ private void InitializeInternal()
197202
rotationInputEventData = new InputEventData<Quaternion>(EventSystem.current);
198203
poseInputEventData = new InputEventData<MixedRealityPose>(EventSystem.current);
199204

200-
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
201-
202205
speechEventData = new SpeechEventData(EventSystem.current);
203206
dictationEventData = new DictationEventData(EventSystem.current);
204207

205-
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
206-
207208
if (MixedRealityManager.Instance.ActiveProfile.IsSpeechCommandsEnabled)
208209
{
209210
SpeechInputSource = new SpeechInputSource(
@@ -578,42 +579,70 @@ public void RaiseSourceLost(IMixedRealityInputSource source, IMixedRealityContro
578579
public void RaiseSourceTrackingStateChanged(IMixedRealityInputSource source, IMixedRealityController controller, TrackingState state)
579580
{
580581
// Create input event
581-
sourcePoseEventData.Initialize(source, controller, state);
582+
sourceTrackingEventData.Initialize(source, controller, state);
582583

583584
// Pass handler through HandleEvent to perform modal/fallback logic
584-
HandleEvent(sourcePoseEventData, OnSourcePoseChangedEventHandler);
585+
HandleEvent(sourceTrackingEventData, OnSourceTrackingChangedEventHandler);
585586
}
586587

588+
private static readonly ExecuteEvents.EventFunction<IMixedRealitySourcePoseHandler> OnSourceTrackingChangedEventHandler =
589+
delegate (IMixedRealitySourcePoseHandler handler, BaseEventData eventData)
590+
{
591+
var casted = ExecuteEvents.ValidateEventData<SourcePoseEventData<TrackingState>>(eventData);
592+
handler.OnSourcePoseChanged(casted);
593+
};
594+
587595
/// <inheritdoc />
588596
public void RaiseSourcePositionChanged(IMixedRealityInputSource source, IMixedRealityController controller, Vector2 position)
589597
{
590598
// Create input event
591-
sourcePoseEventData.Initialize(source, controller, position);
599+
sourceVector2EventData.Initialize(source, controller, position);
592600

593601
// Pass handler through HandleEvent to perform modal/fallback logic
594-
HandleEvent(sourcePoseEventData, OnSourcePoseChangedEventHandler);
602+
HandleEvent(sourceVector2EventData, OnSourcePoseVector2ChangedEventHandler);
595603
}
596604

605+
private static readonly ExecuteEvents.EventFunction<IMixedRealitySourcePoseHandler> OnSourcePoseVector2ChangedEventHandler =
606+
delegate (IMixedRealitySourcePoseHandler handler, BaseEventData eventData)
607+
{
608+
var casted = ExecuteEvents.ValidateEventData<SourcePoseEventData<Vector2>>(eventData);
609+
handler.OnSourcePoseChanged(casted);
610+
};
611+
597612
/// <inheritdoc />
598613
public void RaiseSourcePositionChanged(IMixedRealityInputSource source, IMixedRealityController controller, Vector3 position)
599614
{
600615
// Create input event
601-
sourcePoseEventData.Initialize(source, controller, position);
616+
sourcePositionEventData.Initialize(source, controller, position);
602617

603618
// Pass handler through HandleEvent to perform modal/fallback logic
604-
HandleEvent(sourcePoseEventData, OnSourcePoseChangedEventHandler);
619+
HandleEvent(sourcePositionEventData, OnSourcePositionChangedEventHandler);
605620
}
606621

622+
private static readonly ExecuteEvents.EventFunction<IMixedRealitySourcePoseHandler> OnSourcePositionChangedEventHandler =
623+
delegate (IMixedRealitySourcePoseHandler handler, BaseEventData eventData)
624+
{
625+
var casted = ExecuteEvents.ValidateEventData<SourcePoseEventData<Vector3>>(eventData);
626+
handler.OnSourcePoseChanged(casted);
627+
};
628+
607629
/// <inheritdoc />
608630
public void RaiseSourceRotationChanged(IMixedRealityInputSource source, IMixedRealityController controller, Quaternion rotation)
609631
{
610632
// Create input event
611-
sourcePoseEventData.Initialize(source, controller, rotation);
633+
sourceRotationEventData.Initialize(source, controller, rotation);
612634

613635
// Pass handler through HandleEvent to perform modal/fallback logic
614-
HandleEvent(sourcePoseEventData, OnSourcePoseChangedEventHandler);
636+
HandleEvent(sourceRotationEventData, OnSourceRotationChangedEventHandler);
615637
}
616638

639+
private static readonly ExecuteEvents.EventFunction<IMixedRealitySourcePoseHandler> OnSourceRotationChangedEventHandler =
640+
delegate (IMixedRealitySourcePoseHandler handler, BaseEventData eventData)
641+
{
642+
var casted = ExecuteEvents.ValidateEventData<SourcePoseEventData<Quaternion>>(eventData);
643+
handler.OnSourcePoseChanged(casted);
644+
};
645+
617646
/// <inheritdoc />
618647
public void RaiseSourcePoseChanged(IMixedRealityInputSource source, IMixedRealityController controller, MixedRealityPose position)
619648
{
@@ -627,7 +656,7 @@ public void RaiseSourcePoseChanged(IMixedRealityInputSource source, IMixedRealit
627656
private static readonly ExecuteEvents.EventFunction<IMixedRealitySourcePoseHandler> OnSourcePoseChangedEventHandler =
628657
delegate (IMixedRealitySourcePoseHandler handler, BaseEventData eventData)
629658
{
630-
var casted = ExecuteEvents.ValidateEventData<SourcePoseEventData>(eventData);
659+
var casted = ExecuteEvents.ValidateEventData<SourcePoseEventData<MixedRealityPose>>(eventData);
631660
handler.OnSourcePoseChanged(casted);
632661
};
633662

@@ -1449,8 +1478,6 @@ public void RaiseManipulationCanceled(IMixedRealityInputSource source, Handednes
14491478

14501479
#endregion Gestures
14511480

1452-
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
1453-
14541481
#region Speech Keyword Events
14551482

14561483
private static readonly ExecuteEvents.EventFunction<IMixedRealitySpeechHandler> OnSpeechKeywordRecognizedEventHandler =
@@ -1544,8 +1571,6 @@ public void RaiseDictationError(IMixedRealityInputSource source, string dictatio
15441571

15451572
#endregion Dictation Events
15461573

1547-
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
1548-
15491574
#endregion Input Events
15501575
}
15511576
}

Assets/MixedRealityToolkit-SDK/Profiles/DefaultMixedRealityCameraProfile.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ MonoBehaviour:
1111
m_Script: {fileID: 11500000, guid: a4a1c93114e9437cb75d8b3ee4e0e1ba, type: 3}
1212
m_Name: DefaultMixedRealityCameraProfile
1313
m_EditorClassIdentifier:
14+
isCameraPersistent: 0
1415
nearClipPlaneOpaqueDisplay: 0.1
1516
cameraClearFlagsOpaqueDisplay: 1
1617
backgroundColorOpaqueDisplay: {r: 0, g: 0, b: 0, a: 1}

0 commit comments

Comments
 (0)