Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Added boundary data provider (#86)
Browse files Browse the repository at this point in the history
* Added boundary data provider

* updated packages
  • Loading branch information
StephenHodgson committed Jun 12, 2020
1 parent fd1eb70 commit 0aaed49
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Runtime/Providers/BoundarySystem.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0aaed49

Please sign in to comment.