Skip to content

Commit f1cc8b8

Browse files
mrtk-bldMaxWang-MSCDiaz-MSdavidkline-msDavid Kline
authored
Branch synchronization: prerelease/2.6.0_stabilization --> mrtk_development (#9416)
* Fix issues associated with the new SU package * Update Interactive Element Docs * Remove Unity 2018 support for scene understanding * Update SceneUnderstandingExample.unity * Add comments * add versioning to the shader import logic * Update ReleaseNotes.md * add versioning comment to shader source files * Update SceneUnderstanding.md * add documentation on updating shaders * add doc comments * undo changes to project prefs * Update release notes * Fix links * Update TOC * Update Assets/MRTK/StandardAssets/EditorUtilities/OnLoadUtilities.cs Co-authored-by: Kurtis <[email protected]> * update TMP version * Explicitly set IsEnabled to false when the SU package is not present Co-Authored-By: Kurtis <[email protected]> * Update SceneUnderstanding.md * Add null check for XR not initialized * Update legacy and XR SDK implementation * Fixed articulated hands being classified as HP Motion Controllers (#9410) * Fixed articulated hands being classified as HP Motion Controllers * small modification to ensure we only name interaction sources of kind controller * small adjustment to the naming schemes * implement ignore support for shader update * update shader update documentation and images * fix code validation error (missing doc comment contents) * remove unneeded debug.log messages * Add Scene Understanding to the ignore list * fix test discovered error * Add Pulse Shader Graduation to Release Notes Co-authored-by: MaxWang-MS <[email protected]> Co-authored-by: Catherine Diaz <[email protected]> Co-authored-by: davidkline-ms <[email protected]> Co-authored-by: David Kline <[email protected]> Co-authored-by: Kurtis <[email protected]> Co-authored-by: Kurtis <[email protected]> Co-authored-by: RogPodge <[email protected]> Co-authored-by: CDiaz-MS <[email protected]>
1 parent 6d1e1ea commit f1cc8b8

File tree

88 files changed

+900
-199
lines changed

Some content is hidden

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

88 files changed

+900
-199
lines changed

Assets/MRTK/Examples/Demos/ReadingMode/Scripts/ReadingModeSceneBehavior.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@
33

44
using Microsoft.MixedReality.Toolkit.CameraSystem;
55
using Microsoft.MixedReality.Toolkit.UI;
6-
using UnityEngine;
7-
8-
#if UNITY_2019_3_OR_NEWER
96
using Microsoft.MixedReality.Toolkit.Utilities;
10-
#endif // UNITY_2019_3_OR_NEWER
11-
12-
#if !UNITY_2020_1_OR_NEWER
7+
using UnityEngine;
138
using UnityEngine.XR;
14-
#endif // !UNITY_2020_1_OR_NEWER
159

1610
namespace Microsoft.MixedReality.Toolkit.Examples.Demos.ReadingMode
1711
{
@@ -35,20 +29,10 @@ private void Update()
3529

3630
previousSliderValue = renderViewportScaleSlider.SliderValue;
3731

38-
#if UNITY_2019_3_OR_NEWER
39-
if (XRSubsystemHelpers.DisplaySubsystem != null)
40-
{
41-
XRSubsystemHelpers.DisplaySubsystem.scaleOfAllViewports = Mathf.Max(renderViewportScaleSlider.SliderValue, MinScale);
42-
return;
43-
}
44-
#endif // UNITY_2019_3_OR_NEWER
45-
46-
#if !UNITY_2020_1_OR_NEWER
47-
if (XRDevice.isPresent)
32+
if (DeviceUtility.IsPresent)
4833
{
4934
XRSettings.renderViewportScale = Mathf.Max(renderViewportScaleSlider.SliderValue, MinScale);
5035
}
51-
#endif // !UNITY_2020_1_OR_NEWER
5236
}
5337

5438
public void EnableReadingMode()

Assets/MRTK/Examples/Experimental/SceneUnderstanding/Scenes/SceneUnderstandingExample.unity

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,7 +3831,7 @@ MonoBehaviour:
38313831
m_OnCullStateChanged:
38323832
m_PersistentCalls:
38333833
m_Calls: []
3834-
m_text: HoloLens 2 Only
3834+
m_text: HoloLens 2 & Unity 2019.4+ Only
38353835
m_isRightToLeft: 0
38363836
m_fontAsset: {fileID: 11400000, guid: f137eba12ee10834cb19632437cfdb2e, type: 2}
38373837
m_sharedMaterial: {fileID: 21433621844796372, guid: f137eba12ee10834cb19632437cfdb2e,
@@ -3901,10 +3901,10 @@ MonoBehaviour:
39013901
m_margin: {x: -0.4731984, y: 0.000020836515, z: -0.99050045, w: 1.3652543}
39023902
m_textInfo:
39033903
textComponent: {fileID: 1155140273}
3904-
characterCount: 15
3904+
characterCount: 31
39053905
spriteCount: 0
3906-
spaceCount: 2
3907-
wordCount: 3
3906+
spaceCount: 5
3907+
wordCount: 6
39083908
linkCount: 0
39093909
lineCount: 1
39103910
pageCount: 1
@@ -4926,22 +4926,22 @@ PrefabInstance:
49264926
- target: {fileID: 2113875699234556495, guid: 18470d71939382448be2ecd06efa9662,
49274927
type: 3}
49284928
propertyPath: m_textInfo.characterCount
4929-
value: 699
4929+
value: 541
49304930
objectReference: {fileID: 0}
49314931
- target: {fileID: 2113875699234556495, guid: 18470d71939382448be2ecd06efa9662,
49324932
type: 3}
49334933
propertyPath: m_textInfo.spaceCount
4934-
value: 94
4934+
value: 76
49354935
objectReference: {fileID: 0}
49364936
- target: {fileID: 2113875699234556495, guid: 18470d71939382448be2ecd06efa9662,
49374937
type: 3}
49384938
propertyPath: m_textInfo.wordCount
4939-
value: 92
4939+
value: 76
49404940
objectReference: {fileID: 0}
49414941
- target: {fileID: 2113875699234556495, guid: 18470d71939382448be2ecd06efa9662,
49424942
type: 3}
49434943
propertyPath: m_textInfo.lineCount
4944-
value: 18
4944+
value: 13
49454945
objectReference: {fileID: 0}
49464946
- target: {fileID: 2113875699234556495, guid: 18470d71939382448be2ecd06efa9662,
49474947
type: 3}
@@ -4961,14 +4961,10 @@ PrefabInstance:
49614961
49624962
<size=24><b>Important - Required packages</b></size>
49634963
4964-
Use Nuget for Unity tool to get the Dot Net WinRT and SceneUnderstanding packages.
4965-
Please remember to Click Mixed Reality Toolkit -> Utilities -> Windows Mixed
4966-
Reality -> Check Configuration and Mixed Reality Toolkit -> Utilities -> Scene
4967-
Understanding -> Check Configuration after importing those two packages.
4968-
4969-
4970-
Uncheck ''Should Load From File'' in the DemoSceneUnderstandingObserverProfile
4971-
which can be accessed from MRTK''s Spatial Awareness profile.'
4964+
Use MixedReality Feature Tool to get the Dot Net WinRT and Scene Understanding
4965+
packages. The Scene Understanding package may not be available at MRTK 2.6
4966+
launch time but will be released soon after. Please check issue #9402 on the
4967+
MRTK-Unity GitHub repository for updates on its availability.'
49724968
objectReference: {fileID: 0}
49734969
- target: {fileID: 2113875699234556495, guid: 18470d71939382448be2ecd06efa9662,
49744970
type: 3}
@@ -6250,8 +6246,8 @@ Transform:
62506246
m_PrefabAsset: {fileID: 0}
62516247
m_GameObject: {fileID: 2139668523}
62526248
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
6253-
m_LocalPosition: {x: 0.11993182, y: 0.08893815, z: -0.018035235}
6254-
m_LocalScale: {x: 0.08666847, y: 0.016785234, z: 0.04809894}
6249+
m_LocalPosition: {x: 0.0793, y: 0.08893815, z: -0.018}
6250+
m_LocalScale: {x: 0.168, y: 0.016785234, z: 0.04809894}
62556251
m_Children: []
62566252
m_Father: {fileID: 615958088}
62576253
m_RootOrder: 1

Assets/MRTK/Providers/Experimental/WindowsSceneUnderstanding/Editor/MRTK.WSU.Editor.asmdef

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
"overrideReferences": false,
1616
"precompiledReferences": [],
1717
"autoReferenced": true,
18-
"defineConstraints": []
18+
"defineConstraints": [
19+
"UNITY_2019_4_OR_NEWER"
20+
],
21+
"versionDefines": [],
22+
"noEngineReferences": false
1923
}

Assets/MRTK/Providers/Experimental/WindowsSceneUnderstanding/Editor/WindowsSceneUnderstandingConfigChecker.cs

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

Assets/MRTK/Providers/Experimental/WindowsSceneUnderstanding/Editor/WindowsSceneUnderstandingConfigChecker.cs.meta

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

Assets/MRTK/Providers/Experimental/WindowsSceneUnderstanding/MRTK.WSU.asmdef

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"references": [
44
"Microsoft.MixedReality.Toolkit",
55
"Microsoft.MixedReality.Toolkit.Async",
6-
"Microsoft.MixedReality.Toolkit.Providers.WindowsMixedReality.Shared"
6+
"Microsoft.MixedReality.Toolkit.Providers.WindowsMixedReality.Shared",
7+
"Microsoft.MixedReality.SceneUnderstanding.Projections.Editor",
8+
"Microsoft.MixedReality.SceneUnderstanding.Projections.WSA"
79
],
810
"optionalUnityReferences": [],
911
"includePlatforms": [
@@ -15,5 +17,15 @@
1517
"overrideReferences": false,
1618
"precompiledReferences": [],
1719
"autoReferenced": true,
18-
"defineConstraints": []
20+
"defineConstraints": [
21+
"UNITY_2019_4_OR_NEWER"
22+
],
23+
"versionDefines": [
24+
{
25+
"name": "com.microsoft.mixedreality.sceneunderstanding",
26+
"expression": "",
27+
"define": "SCENE_UNDERSTANDING_PRESENT"
28+
}
29+
],
30+
"noEngineReferences": false
1931
}

Assets/MRTK/Providers/Experimental/WindowsSceneUnderstanding/WindowsSceneUnderstandingObserver.cs

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@
3131

3232
namespace Microsoft.MixedReality.Toolkit.WindowsSceneUnderstanding.Experimental
3333
{
34+
/// <summary>
35+
/// A Spatial Awareness observer with Scene Understanding capabilities.
36+
/// </summary>
37+
/// <remarks>
38+
/// Only works with HoloLens 2 and Unity 2019.4+
39+
/// </remarks>
3440
[MixedRealityDataProvider(
3541
typeof(IMixedRealitySpatialAwarenessSystem),
3642
SupportedPlatforms.WindowsUniversal,
3743
"Windows Scene Understanding Observer",
3844
"Experimental/WindowsSceneUnderstanding/Profiles/DefaultSceneUnderstandingObserverProfile.asset",
3945
"MixedRealityToolkit.Providers",
4046
true)]
47+
[HelpURL("https://docs.microsoft.com/windows/mixed-reality/mrtk-unity/features/spatial-awareness/scene-understanding")]
4148
public class WindowsSceneUnderstandingObserver :
4249
BaseSpatialObserver,
4350
IMixedRealitySceneUnderstandingObserver
@@ -97,25 +104,33 @@ private void ReadProfile()
97104
OrientScene = profile.OrientScene;
98105
}
99106

100-
#if SCENE_UNDERSTANDING_PRESENT
101-
102107
#region IMixedRealityService
103108

109+
#if SCENE_UNDERSTANDING_PRESENT
110+
104111
/// <inheritdoc />
105112
public override void Reset()
106113
{
107114
CleanupObserver();
108115
Initialize();
109116
}
110117

118+
#endif // SCENE_UNDERSTANDING_PRESENT
119+
111120
/// <inheritdoc />
112121
public override void Initialize()
113122
{
123+
#if !SCENE_UNDERSTANDING_PRESENT
124+
if (Application.isPlaying)
125+
{
126+
Debug.LogWarning("The required package Microsoft.MixedReality.SceneUnderstanding is not installed or properly configured. Please visit https://docs.microsoft.com/windows/mixed-reality/mrtk-unity/features/spatial-awareness/scene-understanding for more information.");
127+
}
128+
#else
114129
base.Initialize();
115130
sceneEventData = new MixedRealitySpatialAwarenessEventData<SpatialAwarenessSceneObject>(EventSystem.current);
116131
CreateQuadFromExtents(normalizedQuadMesh, 1, 1);
117132

118-
var accessStatus = SceneObserver.RequestAccessAsync().GetAwaiter().GetResult();
133+
SceneObserverAccessStatus accessStatus = Task.Run(RequestAccess).GetAwaiter().GetResult();
119134
if (accessStatus == SceneObserverAccessStatus.Allowed)
120135
{
121136
IsRunning = true;
@@ -131,20 +146,25 @@ public override void Initialize()
131146
{
132147
observerState = ObserverState.GetScene;
133148
}
149+
#endif // SCENE_UNDERSTANDING_PRESENT
134150
}
135151

136152
/// <inheritdoc />
137153
public override void Enable()
138154
{
155+
#if SCENE_UNDERSTANDING_PRESENT
156+
base.Enable();
139157
// Terminate the background thread when we stop in editor.
140158
cancelToken = cancelTokenSource.Token;
141159

142-
// there is odd behavior with WaitForBackgroundTask
143-
// it will sometimes run on the main thread unless we start it this way
144-
task = RunObserverAsync(cancelToken);
145-
task.ConfigureAwait(true);
160+
task = Task.Run(() => RunObserverAsync(cancelToken));
161+
#else
162+
IsEnabled = false;
163+
#endif // SCENE_UNDERSTANDING_PRESENT
146164
}
147165

166+
#if SCENE_UNDERSTANDING_PRESENT
167+
148168
/// <inheritdoc />
149169
public override void Update()
150170
{
@@ -171,8 +191,12 @@ public override void Destroy()
171191
CleanupObserver();
172192
}
173193

194+
#endif // SCENE_UNDERSTANDING_PRESENT
195+
174196
#endregion IMixedRealityService
175197

198+
#if SCENE_UNDERSTANDING_PRESENT
199+
176200
#region BaseService
177201

178202
/// <inheritdoc />
@@ -280,7 +304,7 @@ public IReadOnlyDictionary<int, SpatialAwarenessSceneObject> SceneObjects
280304
public void SaveScene(string filenamePrefix)
281305
{
282306
#if WINDOWS_UWP && SCENE_UNDERSTANDING_PRESENT
283-
SaveToFile(filenamePrefix);
307+
Task.Run(() => SaveToFile(filenamePrefix));
284308
#else // WINDOWS_UWP
285309
Debug.LogWarning("SaveScene() only supported at runtime! Ignoring request.");
286310
#endif // WINDOWS_UWP
@@ -523,6 +547,11 @@ protected virtual void SendSceneObjectRemoved(int id)
523547
SpatialAwarenessSystem?.HandleEvent(sceneEventData, OnSceneObjectRemoved);
524548
}
525549

550+
private async Task<SceneObserverAccessStatus> RequestAccess()
551+
{
552+
return await SceneObserver.RequestAccessAsync();
553+
}
554+
526555
/// <summary>
527556
/// Sets up and starts update timers
528557
/// </summary>
@@ -630,7 +659,7 @@ private async Task RunObserverAsync(CancellationToken cancellationToken)
630659
}
631660
await new WaitForBackgroundThread();
632661
{
633-
scene = GetSceneAsync(previousScene);
662+
scene = await GetSceneAsync(previousScene);
634663
previousScene = scene;
635664
sceneOriginId = scene.OriginSpatialGraphNodeId;
636665
}
@@ -761,7 +790,7 @@ private System.Numerics.Matrix4x4 GetSceneToWorldTransform()
761790
/// </summary>
762791
/// <param name="previousScene">The previous scene</param>
763792
/// <returns>The retrieved scene</returns>
764-
private Scene GetSceneAsync(Scene previousScene)
793+
private async Task<Scene> GetSceneAsync(Scene previousScene)
765794
{
766795
Scene scene = null;
767796

@@ -795,18 +824,13 @@ private Scene GetSceneAsync(Scene previousScene)
795824
RequestedMeshLevelOfDetail = LevelOfDetailToMeshLOD(WorldMeshLevelOfDetail)
796825
};
797826

798-
// Ideally you'd call SceneObserver.ComputeAsync() like this:
799-
// scene = await SceneObserver.ComputeAsync(...);
800-
// however this has been problematic (buggy?)
801-
// For the time being we force it to be synchronous with the ...GetAwaiter().GetResult() pattern
802-
803827
if (UsePersistentObjects && previousScene != null)
804828
{
805-
scene = SceneObserver.ComputeAsync(sceneQuerySettings, QueryRadius, previousScene).GetAwaiter().GetResult();
829+
scene = await SceneObserver.ComputeAsync(sceneQuerySettings, QueryRadius, previousScene);
806830
}
807831
else
808832
{
809-
scene = SceneObserver.ComputeAsync(sceneQuerySettings, QueryRadius).GetAwaiter().GetResult();
833+
scene = await SceneObserver.ComputeAsync(sceneQuerySettings, QueryRadius);
810834
}
811835
}
812836

@@ -1301,7 +1325,7 @@ private async void SaveToFile(string prefix)
13011325
RequestedMeshLevelOfDetail = LevelOfDetailToMeshLOD(WorldMeshLevelOfDetail)
13021326
};
13031327

1304-
var serializedScene = SceneObserver.ComputeSerializedAsync(sceneQuerySettings, QueryRadius).GetAwaiter().GetResult();
1328+
var serializedScene = await SceneObserver.ComputeSerializedAsync(sceneQuerySettings, QueryRadius);
13051329
var bytes = new byte[serializedScene.Size];
13061330
serializedScene.GetData(bytes);
13071331
var timestamp = DateTime.Now.ToString("yyyyMMdd_hhmmss");

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,13 @@ private BaseWindowsMixedRealitySource GetOrAddController(InteractionSource inter
720720

721721
}
722722

723-
string nameModifier = controllingHand == Handedness.None ? interactionSource.kind.ToString() : controllingHand.ToString();
724-
bool isHPController = !interactionSource.supportsTouchpad;
725-
string inputSourceName = isHPController ? $"HP Motion Controller {nameModifier}" : $"Mixed Reality Controller {nameModifier}";
723+
bool isHPController = !interactionSource.supportsTouchpad && interactionSource.kind == InteractionSourceKind.Controller;
724+
725+
string kindModifier = interactionSource.kind.ToString();
726+
string handednessModifier = controllingHand == Handedness.None ? string.Empty : controllingHand.ToString();
727+
728+
string inputSourceName = isHPController ? $"HP Motion {kindModifier} {handednessModifier}" : $"Mixed Reality {kindModifier} {handednessModifier}";
729+
726730
var inputSource = Service?.RequestNewGenericInputSource(inputSourceName, pointers, inputSourceType);
727731

728732
BaseWindowsMixedRealitySource detectedController;

0 commit comments

Comments
 (0)