Skip to content

Commit 69dbd40

Browse files
author
David Kline
authored
Merge pull request #3000 from StephenHodgson/vNEXT-SpatialFixes
Fixed a few things with SpatialAwarenessSystem implementation
2 parents 9c3e4cf + 93369d8 commit 69dbd40

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

Assets/MixedRealityToolkit-SDK/Features/SpatialAwareness/System/MixedRealitySpatialAwarenessSystem.cs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace Microsoft.MixedReality.Toolkit.SDK.SpatialAwarenessSystem
1616
{
1717
/// <summary>
18-
/// Class poviding the default implementation of the <see cref="IMixedRealitySpatialAwarenessSystem"/> interface.
18+
/// Class providing the default implementation of the <see cref="IMixedRealitySpatialAwarenessSystem"/> interface.
1919
/// </summary>
2020
public class MixedRealitySpatialAwarenessSystem : MixedRealityEventManager, IMixedRealitySpatialAwarenessSystem
2121
{
@@ -24,32 +24,29 @@ public class MixedRealitySpatialAwarenessSystem : MixedRealityEventManager, IMix
2424
/// <summary>
2525
/// Parent <see cref="GameObject"/> which will encapsulate all of the spatial awareness system created scene objects.
2626
/// </summary>
27-
private GameObject SpatialAwarenessParent => spatialAwarenessParent ?? (spatialAwarenessParent = CreateSpatialAwarenessParent());
27+
private GameObject SpatialAwarenessParent => spatialAwarenessParent != null ? spatialAwarenessParent : (spatialAwarenessParent = CreateSpatialAwarenessParent);
2828

2929
/// <summary>
3030
/// Creates the parent for spatial awareness objects so that the scene hierarchy does not get overly cluttered.
3131
/// </summary>
3232
/// <returns>
3333
/// The <see cref="GameObject"/> to which spatial awareness created objects will be parented.
3434
/// </returns>
35-
private GameObject CreateSpatialAwarenessParent()
36-
{
37-
return new GameObject("Spatial Awareness System");
38-
}
35+
private GameObject CreateSpatialAwarenessParent => new GameObject("Spatial Awareness System");
3936

4037
private GameObject meshParent = null;
4138

4239
/// <summary>
4340
/// Parent <see cref="GameObject"/> which will encapsulate all of the system created mesh objects.
4441
/// </summary>
45-
private GameObject MeshParent => meshParent ?? (meshParent = CreateSecondGenerationParent("Meshes"));
42+
private GameObject MeshParent => meshParent != null ? meshParent : (meshParent = CreateSecondGenerationParent("Meshes"));
4643

4744
private GameObject surfaceParent = null;
4845

4946
/// <summary>
5047
/// Parent <see cref="GameObject"/> which will encapsulate all of the system created mesh objects.
5148
/// </summary>
52-
private GameObject SurfaceParent => surfaceParent ?? (surfaceParent = CreateSecondGenerationParent("Surfaces"));
49+
private GameObject SurfaceParent => surfaceParent != null ? surfaceParent : (surfaceParent = CreateSecondGenerationParent("Surfaces"));
5350

5451
/// <summary>
5552
/// Creates the a parent, that is a child if the Spatial Awareness System parent so that the scene hierarchy does not get overly cluttered.
@@ -312,7 +309,7 @@ public void RaiseSurfaceRemoved(int surfaceId)
312309
MixedRealitySpatialAwarenessEventData spatialEventData = ExecuteEvents.ValidateEventData<MixedRealitySpatialAwarenessEventData>(eventData);
313310
handler.OnSurfaceRemoved(spatialEventData);
314311
};
315-
312+
316313
#endregion Surface Finding Events
317314

318315
#endregion IMixedRealityManager Implementation
@@ -398,15 +395,13 @@ public bool IsObserverRunning
398395
/// <inheritdoc />
399396
public void ResumeObserver()
400397
{
401-
if (SpatialAwarenessObserver == null) { return; }
402-
SpatialAwarenessObserver.StartObserving();
398+
SpatialAwarenessObserver?.StartObserving();
403399
}
404400

405401
/// <inheritdoc />
406402
public void SuspendObserver()
407403
{
408-
if (SpatialAwarenessObserver == null) { return; }
409-
SpatialAwarenessObserver.StopObserving();
404+
SpatialAwarenessObserver?.StopObserving();
410405
}
411406

412407
#region Mesh Handling implementation
@@ -426,7 +421,7 @@ public void SuspendObserver()
426421
public SpatialAwarenessMeshLevelOfDetail MeshLevelOfDetail
427422
{
428423
get
429-
{
424+
{
430425
return meshLevelOfDetail;
431426
}
432427

@@ -461,14 +456,8 @@ public SpatialAwarenessMeshLevelOfDetail MeshLevelOfDetail
461456
public Material MeshOcclusionMaterial { get; set; } = null;
462457

463458
/// <inheritdoc />
464-
public IDictionary<int, GameObject> Meshes
465-
{
466-
get
467-
{
468-
// The observer manages the mesh collection.
469-
return SpatialAwarenessObserver.Meshes;
470-
}
471-
}
459+
/// <remarks>The observer manages the mesh collection.</remarks>
460+
public IDictionary<int, GameObject> Meshes => SpatialAwarenessObserver.Meshes;
472461

473462
#endregion Mesh Handling implementation
474463

0 commit comments

Comments
 (0)