This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added boundary data provider * updated packages
- Loading branch information
1 parent
fd1eb70
commit 0aaed49
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <inheritdoc /> | ||
public WindowsMixedRealityBoundaryDataProvider(string name, uint priority, BaseMixedRealityProfile profile, IMixedRealityBoundarySystem parentService) | ||
: base(name, priority, profile, parentService) | ||
{ | ||
} | ||
|
||
#region IMixedRealityBoundaryDataProvider Implementation | ||
|
||
/// <inheritdoc /> | ||
public bool IsPlatformBoundaryVisible | ||
{ | ||
get => false; // TODO Unsure how to currently query the platform for this information. | ||
set { } | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool IsPlatformConfigured | ||
{ | ||
get | ||
{ | ||
#if WINDOWS_UWP | ||
var currentStage = SpatialStageFrameOfReference.Current; | ||
return currentStage != null && currentStage.MovementRange == SpatialMovementRange.Bounded; | ||
#else | ||
return false; | ||
#endif | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool TryGetBoundaryGeometry(ref List<Vector3> 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 | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Runtime/Providers/BoundarySystem/WindowsMixedRealityBoundaryDataProvider.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.