Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Updated Spatial Awareness System (#694)
Browse files Browse the repository at this point in the history
* updated lumin build tools

updated lumin submodule checkout

* updated lumin checkout

* updated lumin checkout

* Breaking change

Removed MeshTrianglesPerCubicMeter from Spatial Mesh Observer Profile
Updated SpatialAwarenessMeshLevelOfDetail to be more consistent

* updated submodules

updated package info

* don't iterate over the same gameobjects twice, just clear

* updated submodues

* updated lumin checkout

* updated submodules
  • Loading branch information
StephenHodgson committed Dec 20, 2020
1 parent f708e4e commit b681bf2
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace XRTK.Editor.Profiles.SpatialAwareness
public class BaseMixedRealitySpatialMeshObserverProfileInspector : BaseMixedRealitySpatialObserverProfileInspector
{
private SerializedProperty meshLevelOfDetail;
private SerializedProperty meshTrianglesPerCubicMeter;
private SerializedProperty meshRecalculateNormals;
private SerializedProperty meshVisibleMaterial;
private SerializedProperty meshOcclusionMaterial;
Expand All @@ -32,7 +31,6 @@ protected override void OnEnable()
base.OnEnable();

meshLevelOfDetail = serializedObject.FindProperty(nameof(meshLevelOfDetail));
meshTrianglesPerCubicMeter = serializedObject.FindProperty(nameof(meshTrianglesPerCubicMeter));
meshRecalculateNormals = serializedObject.FindProperty(nameof(meshRecalculateNormals));
meshVisibleMaterial = serializedObject.FindProperty(nameof(meshVisibleMaterial));
meshOcclusionMaterial = serializedObject.FindProperty(nameof(meshOcclusionMaterial));
Expand Down Expand Up @@ -91,7 +89,6 @@ public override void OnInspectorGUI()
if (meshLevelOfDetail.FoldoutWithBoldLabelPropertyField(spatialMeshSettingsFoldoutHeader))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(meshTrianglesPerCubicMeter);
EditorGUILayout.PropertyField(meshRecalculateNormals);
EditorGUILayout.PropertyField(meshVisibleMaterial);
EditorGUILayout.PropertyField(meshOcclusionMaterial);
Expand Down
6 changes: 4 additions & 2 deletions Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Runtime.CompilerServices;
Expand All @@ -11,4 +11,6 @@
[assembly: InternalsVisibleTo("XRTK.WindowsMixedReality")]
[assembly: InternalsVisibleTo("XRTK.WindowsMixedReality.Player")]
[assembly: InternalsVisibleTo("XRTK.Oculus")]
[assembly: InternalsVisibleTo("XRTK.Oculus.Player")]
[assembly: InternalsVisibleTo("XRTK.Oculus.Player")]
[assembly: InternalsVisibleTo("XRTK.Lumin")]
[assembly: InternalsVisibleTo("XRTK.Lumin.Player")]
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace XRTK.Definitions.SpatialAwarenessSystem
{
/// <summary>
/// Enumeration defining levels of detail for the spatial awareness mesh subsystem.
/// Enumeration defining levels of detail for the spatial awareness service.
/// </summary>
/// <remarks>
/// The integral values for these levels of detail generally map to triangle density, in triangles per cubic meter.
/// </remarks>
public enum SpatialAwarenessMeshLevelOfDetail
{
/// <summary>
/// The custom level of detail allows specifying a custom value for
/// MeshTrianglesPerCubicMeter.
/// The low level of detail is well suited for identifying large
/// environmental features, such as floors and walls.
/// </summary>
Custom = -1,
Low = 0,

/// <summary>
/// The coarse level of detail is well suited for identifying large
/// environmental features, such as floors and walls.
/// The medium level of detail is suited for fast environmental mesh occlusion.
/// </summary>
Coarse = 0,
Medium = 1,

/// <summary>
/// The fine level of detail is well suited for using as an occlusion
/// mesh.
/// The high level of detail is well suited for mesh occlusion for object like hands.
/// </summary>
Fine = 2000
High = 2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BaseMixedRealitySpatialMeshObserverProfile : BaseMixedRealitySpatia
{
[SerializeField]
[Tooltip("Level of detail for the mesh")]
private SpatialAwarenessMeshLevelOfDetail meshLevelOfDetail = SpatialAwarenessMeshLevelOfDetail.Coarse;
private SpatialAwarenessMeshLevelOfDetail meshLevelOfDetail = SpatialAwarenessMeshLevelOfDetail.Low;

/// <summary>
/// The desired Unity Physics Layer on which to set the spatial mesh.
Expand All @@ -26,7 +26,7 @@ public class BaseMixedRealitySpatialMeshObserverProfile : BaseMixedRealitySpatia
/// <summary>
/// The level of detail, in triangles per cubic meter, for the returned spatial mesh.
/// </summary>
/// <remarks>This value is ignored, unless <see cref="MeshLevelOfDetail"/> is set to Coarse.</remarks>
/// <remarks>This value is ignored, unless <see cref="MeshLevelOfDetail"/> is set to Low.</remarks>
public uint MeshTrianglesPerCubicMeter => meshTrianglesPerCubicMeter;

[SerializeField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ public interface IMixedRealitySpatialMeshObserver : IMixedRealitySpatialAwarenes
/// <remarks>Specifying any other value will cause <see cref="MeshTrianglesPerCubicMeter"/> to be overwritten.</remarks>
SpatialAwarenessMeshLevelOfDetail MeshLevelOfDetail { get; }

/// <summary>
/// Gets or sets the level of detail, in triangles per cubic meter, for the returned spatial mesh.
/// </summary>
/// <remarks>
/// When specifying Coarse or Fine for the <see cref="MeshLevelOfDetail"/>, this value will be automatically overwritten with system default values.
/// </remarks>
uint MeshTrianglesPerCubicMeter { get; }

/// <summary>
/// Gets or sets a value indicating if the spatial awareness system to generate normal for the returned meshes
/// as some platforms may not support returning normal along with the spatial mesh.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ protected BaseMixedRealitySpatialMeshObserver(string name, uint priority, BaseMi
}

MeshLevelOfDetail = profile.MeshLevelOfDetail;
MeshTrianglesPerCubicMeter = profile.MeshTrianglesPerCubicMeter;
MeshRecalculateNormals = profile.MeshRecalculateNormals;
meshDisplayOption = MixedRealityToolkit.SpatialAwarenessSystem.SpatialMeshVisibility;
MeshVisibleMaterial = profile.MeshVisibleMaterial;
Expand Down Expand Up @@ -144,13 +143,9 @@ public override void Destroy()
{
base.Destroy();

// Cleanup the spatial meshes that are being managed by this observer.
foreach (var meshObject in spatialMeshObjects.Values)
{
meshObject.GameObject.Destroy();
}
if (!Application.isPlaying) { return; }

Debug.Assert(spatialMeshObjects.Count == 0);
spatialMeshObjects.Clear();

lock (spatialMeshObjectPool)
{
Expand All @@ -168,29 +163,8 @@ public override void Destroy()

#region IMixedRealitySpatialMeshObserver Implementation

private SpatialAwarenessMeshLevelOfDetail meshLevelOfDetail = SpatialAwarenessMeshLevelOfDetail.Coarse;

/// <inheritdoc />
public SpatialAwarenessMeshLevelOfDetail MeshLevelOfDetail
{
get => meshLevelOfDetail;
set
{
if (meshLevelOfDetail != value)
{
// Non-custom values automatically modify MeshTrianglesPerCubicMeter
if (value != SpatialAwarenessMeshLevelOfDetail.Custom)
{
MeshTrianglesPerCubicMeter = (uint)value;
}

meshLevelOfDetail = value;
}
}
}

/// <inheritdoc />
public uint MeshTrianglesPerCubicMeter { get; private set; }
public SpatialAwarenessMeshLevelOfDetail MeshLevelOfDetail { get; set; }

/// <inheritdoc />
public bool MeshRecalculateNormals { get; }
Expand Down
48 changes: 47 additions & 1 deletion Runtime/Utilities/BuildAndDeploy/LuminPlayerBuildTools.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Diagnostics;
using UnityEditor.Build.Reporting;
using UnityEngine;
using XRTK.Extensions;
using Debug = UnityEngine.Debug;

namespace XRTK.Utilities.Build
{
Expand All @@ -29,7 +31,51 @@ public static BuildReport BuildPlayer(BuildInfo buildInfo)

private static async void PostBuildAction(IBuildInfo buildInfo, BuildReport buildReport)
{
await new Process().RunAsync($"mldb install -u \"{buildInfo.OutputDirectory}\"", true);
// TODO Check if installation flag is set in build window

Debug.Log("Starting installation...");

var canInstall = false;

try
{
var deviceResult = await new Process().RunAsync("mldb devices", false);

if (deviceResult.ExitCode == 0)
{
foreach (var deviceId in deviceResult.Output)
{
if (!string.IsNullOrWhiteSpace(deviceId))
{
Debug.Log(deviceId);

if (!deviceId.Contains("List"))
{
canInstall = true;
}
}
}
}
}
catch (Exception e)
{
Debug.Log(e);
}

if (!canInstall)
{
Debug.Log("No devices found, skipping installation");
return;
}

try
{
await new Process().RunAsync($"mldb install -u \"{buildInfo.OutputDirectory}\"", true);
}
catch (Exception e)
{
Debug.Log(e);
}
}
}
}

0 comments on commit b681bf2

Please sign in to comment.