Skip to content

Commit ce8a51f

Browse files
author
David Kline (ANALOG)
committed
minor rework of @keveleigh's fixes
1 parent c42dd54 commit ce8a51f

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

Assets/MixedRealityToolkit-SDK/Features/SpatialAwareness/System/Handlers/MixedRealitySpatialAwarenessMeshHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ public class MixedRealitySpatialAwarenessMeshHandler : MonoBehaviour, IMixedReal
1717
/// <inheritdoc />
1818
public void OnMeshAdded(MixedRealitySpatialAwarenessEventData eventData)
1919
{
20-
eventData.GameObject.SetActive(true);
20+
// Custom implementations can use this event to access the mesh data on arrival.
2121
}
2222

2323
/// <inheritdoc />
2424
public void OnMeshUpdated(MixedRealitySpatialAwarenessEventData eventData)
2525
{
26-
eventData.GameObject.SetActive(true);
26+
// Custom implementations can use this event to access the mesh data on update.
2727
}
2828

2929
/// <inheritdoc />
3030
public void OnMeshRemoved(MixedRealitySpatialAwarenessEventData eventData)
3131
{
32-
eventData.GameObject.SetActive(false);
32+
// Custom implementations can use this event to respond to mesh removal.
3333
}
3434
}
3535
}

Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealitySpatialObserver.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -454,23 +454,29 @@ private void SurfaceObserver_OnDataReady(SurfaceData cookedData, bool outputWrit
454454
}
455455

456456
// Add / update the mesh to our collection
457-
if (!meshObjects.ContainsKey(cookedData.id.handle))
458-
{
459-
meshObjects.Add(cookedData.id.handle, meshObject);
460-
MixedRealityManager.SpatialAwarenessSystem.RaiseMeshAdded(cookedData.id.handle, meshObject.GameObject);
461-
}
462-
else
457+
// todo: fix
458+
bool sendUpdatedEvent = false;
459+
if (meshObjects.ContainsKey(cookedData.id.handle))
463460
{
464461
// Reclaim the old mesh object for future use.
465462
ReclaimMeshObject(meshObjects[cookedData.id.handle]);
466-
meshObjects[cookedData.id.handle] = meshObject;
463+
meshObjects.Remove(cookedData.id.handle);
464+
465+
sendUpdatedEvent = true;
466+
}
467+
meshObjects.Add(cookedData.id.handle, meshObject);
468+
469+
if (sendUpdatedEvent)
470+
{
467471
MixedRealityManager.SpatialAwarenessSystem.RaiseMeshUpdated(cookedData.id.handle, meshObject.GameObject);
468472
}
473+
else
474+
{
475+
MixedRealityManager.SpatialAwarenessSystem.RaiseMeshAdded(cookedData.id.handle, meshObject.GameObject);
476+
}
469477
}
470478
#endif // UNITY_WSA
471479

472-
// todo: SetObserverOrigin
473-
474480
#endregion IMixedRealitySpatialAwarenessObserver implementation
475481
}
476482
}

0 commit comments

Comments
 (0)