From 0aaed49dfb70e0c018b3f85070f02ce3e61f97c0 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 12 Jun 2020 15:45:34 -0400 Subject: [PATCH] Added boundary data provider (#86) * Added boundary data provider * updated packages --- Runtime/Providers/BoundarySystem.meta | 8 ++ ...WindowsMixedRealityBoundaryDataProvider.cs | 73 +++++++++++++++++++ ...wsMixedRealityBoundaryDataProvider.cs.meta | 11 +++ 3 files changed, 92 insertions(+) create mode 100644 Runtime/Providers/BoundarySystem.meta create mode 100644 Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs create mode 100644 Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs.meta diff --git a/Runtime/Providers/BoundarySystem.meta b/Runtime/Providers/BoundarySystem.meta new file mode 100644 index 0000000..1761f98 --- /dev/null +++ b/Runtime/Providers/BoundarySystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d0c793ac910774742acea2781e9b4793 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs b/Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs new file mode 100644 index 0000000..888d647 --- /dev/null +++ b/Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs @@ -0,0 +1,73 @@ +// Copyright (c) XRTK. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; +using UnityEngine; +using XRTK.Definitions; +using XRTK.Interfaces.BoundarySystem; +using XRTK.Services; + +#if WINDOWS_UWP +using System.Linq; +using Windows.Perception.Spatial; +using XRTK.Extensions; +#endif + +namespace XRTK.WindowsMixedReality.Providers.BoundarySystem +{ + [System.Runtime.InteropServices.Guid("e61b047a-56ac-421a-b5f7-683fd44dd33c")] + public class WindowsMixedRealityBoundaryDataProvider : BaseDataProvider, IMixedRealityBoundaryDataProvider + { + /// + public WindowsMixedRealityBoundaryDataProvider(string name, uint priority, BaseMixedRealityProfile profile, IMixedRealityBoundarySystem parentService) + : base(name, priority, profile, parentService) + { + } + + #region IMixedRealityBoundaryDataProvider Implementation + + /// + public bool IsPlatformBoundaryVisible + { + get => false; // TODO Unsure how to currently query the platform for this information. + set { } + } + + /// + public bool IsPlatformConfigured + { + get + { +#if WINDOWS_UWP + var currentStage = SpatialStageFrameOfReference.Current; + return currentStage != null && currentStage.MovementRange == SpatialMovementRange.Bounded; +#else + return false; +#endif + } + } + + /// + public bool TryGetBoundaryGeometry(ref List geometry) + { +#if WINDOWS_UWP + geometry.Clear(); + + var currentStage = SpatialStageFrameOfReference.Current; + var platformGeometry = currentStage?.TryGetMovementBounds(currentStage.CoordinateSystem); + + if (platformGeometry == null) + { + return false; + } + + geometry.AddRange(platformGeometry.Select(point => point.ToUnity())); + return true; +#else + return false; +#endif + } + + #endregion IMixedRealityBoundaryDataProvider Implementation + } +} diff --git a/Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs.meta b/Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs.meta new file mode 100644 index 0000000..a507f0f --- /dev/null +++ b/Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3dea8eccd799c0842877bb89d189d41e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 8ac5213854cf4dbabd140decf8df1946, type: 3} + userData: + assetBundleName: + assetBundleVariant: