Skip to content

Commit 0ff88b0

Browse files
MaxWang-MSkeveleigh
andcommitted
Logging and SpatialAwarenessSurfaceTypes fix for Scene Understanding
Co-Authored-By: Kurtis <[email protected]>
1 parent cf87ff2 commit 0ff88b0

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Assets/MRTK/Core/Definitions/SpatialAwareness/SpatialAwarenessSurfaceTypes.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public enum SpatialAwarenessSurfaceTypes
4343
/// </remarks>
4444
Platform = 1 << 4,
4545

46-
// Insert additional surface types here.
47-
4846
/// <summary>
4947
/// A surface that does not fit one of the defined surface types.
5048
/// </summary>
@@ -53,16 +51,16 @@ public enum SpatialAwarenessSurfaceTypes
5351
/// <para>Background should not be confused with Unknown. There is sufficient data to
5452
/// classify the surface and it has been found to not correspond to a defined type.</para>
5553
/// </remarks>
56-
Background = 1 << 29,
54+
Background = 1 << 5,
5755

5856
/// <summary>
5957
/// A boundless world mesh.
6058
/// </summary>
61-
World = 1 << 30,
59+
World = 1 << 6,
6260

6361
/// <summary>
6462
/// Objects for which we have no observations
6563
/// </summary>
66-
Inferred = 1 << 31
64+
Inferred = 1 << 7
6765
}
6866
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ public override void Enable()
166166
// Terminate the background thread when we stop in editor.
167167
cancelToken = cancelTokenSource.Token;
168168

169-
task = Task.Run(() => RunObserverAsync(cancelToken));
169+
task = Task.Run(() => RunObserverAsync(cancelToken)).ContinueWith(t =>
170+
{
171+
Debug.LogError($"{t.Exception.InnerException.GetType().Name}: {t.Exception.InnerException.Message} {t.Exception.InnerException.StackTrace}");
172+
}, TaskContinuationOptions.OnlyOnFaulted);
170173
#else
171174
IsEnabled = false;
172175
#endif // SCENE_UNDERSTANDING_PRESENT && UNITY_WSA
@@ -180,7 +183,7 @@ public override void Update()
180183
if (instantiationQueue.Count > 0)
181184
{
182185
// Make our new objects in batches and tell observers about it
183-
int batchCount = Math.Min(InstantiationBatchRate, instantiationQueue.Count);
186+
int batchCount = CreateGameObjects ? Math.Min(InstantiationBatchRate, instantiationQueue.Count) : instantiationQueue.Count;
184187

185188
for (int i = 0; i < batchCount; ++i)
186189
{
@@ -313,7 +316,10 @@ public IReadOnlyDictionary<int, SpatialAwarenessSceneObject> SceneObjects
313316
public void SaveScene(string filenamePrefix)
314317
{
315318
#if WINDOWS_UWP && SCENE_UNDERSTANDING_PRESENT
316-
Task.Run(() => SaveToFile(filenamePrefix));
319+
Task.Run(() => SaveToFile(filenamePrefix)).ContinueWith(t =>
320+
{
321+
Debug.LogError($"{t.Exception.InnerException.GetType().Name}: {t.Exception.InnerException.Message} {t.Exception.InnerException.StackTrace}");
322+
}, TaskContinuationOptions.OnlyOnFaulted);
317323
#else // WINDOWS_UWP && SCENE_UNDERSTANDING_PRESENT
318324
Debug.LogWarning("SaveScene() only supported at runtime! Ignoring request.");
319325
#endif // WINDOWS_UWP && SCENE_UNDERSTANDING_PRESENT
@@ -660,7 +666,7 @@ private async Task RunObserverAsync(CancellationToken cancellationToken)
660666

661667
case ObserverState.GetScene:
662668
observerState = ObserverState.Working;
663-
if (CreateGameObjects && instantiationQueue.Count > 0)
669+
while (CreateGameObjects && instantiationQueue.Count > 0)
664670
{
665671
await new WaitForUpdate();
666672
}

0 commit comments

Comments
 (0)