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

Commit

Permalink
Spatial Awareness display options enhancement (#179)
Browse files Browse the repository at this point in the history
* added the ability to set the mesh display option at runtime and added an additional option of colliders only.

* updated wmr display options
  • Loading branch information
StephenHodgson authored May 11, 2019
1 parent 55711d6 commit 3f1cc7d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
13 changes: 9 additions & 4 deletions Definitions/SpatialAwarenessSystem/SpatialMeshDisplayOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ namespace XRTK.Definitions.SpatialAwarenessSystem
public enum SpatialMeshDisplayOptions
{
/// <summary>
/// Do not display the spatial mesh
/// Disable the spatial mesh renderer and collider.
/// </summary>
None = 0,

/// <summary>
/// Display the spatial mesh using the configured material
/// Display the spatial mesh using the configured material.
/// </summary>
Visible,

/// <summary>
/// Display the spatial mesh using the configured occlusion material
/// Display the spatial mesh using the configured occlusion material.
/// </summary>
Occlusion
Occlusion,

/// <summary>
/// Only enable the collider for the spatial mesh object.
/// </summary>
Collision,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public interface IMixedRealitySpatialMeshObserver : IMixedRealitySpatialObserver
/// <remarks>
/// Applications that wish to process the <see cref="Mesh"/>es should set this value to None.
/// </remarks>
SpatialMeshDisplayOptions MeshDisplayOption { get; }
SpatialMeshDisplayOptions MeshDisplayOption { get; set; }

/// <summary>
/// Gets or sets the <see cref="Material"/> to be used when displaying <see cref="SpatialMeshObject"/>s.
Expand Down
34 changes: 32 additions & 2 deletions Providers/SpatialObservers/BaseMixedRealitySpatialMeshObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected BaseMixedRealitySpatialMeshObserver(string name, uint priority, BaseMi
MeshLevelOfDetail = profile.MeshLevelOfDetail;
MeshTrianglesPerCubicMeter = profile.MeshTrianglesPerCubicMeter;
MeshRecalculateNormals = profile.MeshRecalculateNormals;
MeshDisplayOption = profile.MeshDisplayOption;
meshDisplayOption = profile.MeshDisplayOption;
MeshVisibleMaterial = profile.MeshVisibleMaterial;
MeshOcclusionMaterial = profile.MeshOcclusionMaterial;
ObservationExtents = profile.ObservationExtents;
Expand Down Expand Up @@ -212,8 +212,38 @@ public SpatialAwarenessMeshLevelOfDetail MeshLevelOfDetail
/// <inheritdoc />
public bool MeshRecalculateNormals { get; }

private SpatialMeshDisplayOptions meshDisplayOption;

/// <inheritdoc />
public SpatialMeshDisplayOptions MeshDisplayOption { get; }
public SpatialMeshDisplayOptions MeshDisplayOption
{
get => meshDisplayOption;
set
{
meshDisplayOption = value;

if (meshDisplayOption != SpatialMeshDisplayOptions.None)
{
foreach (var spatialMeshObject in SpatialMeshObjects)
{
spatialMeshObject.Value.Collider.enabled = true;
spatialMeshObject.Value.Renderer.enabled = meshDisplayOption == SpatialMeshDisplayOptions.Visible ||
meshDisplayOption == SpatialMeshDisplayOptions.Occlusion;
spatialMeshObject.Value.Renderer.sharedMaterial = meshDisplayOption == SpatialMeshDisplayOptions.Visible
? MeshVisibleMaterial
: MeshOcclusionMaterial;
}
}
else
{
foreach (var spatialMeshObject in SpatialMeshObjects)
{
spatialMeshObject.Value.Renderer.enabled = false;
spatialMeshObject.Value.Collider.enabled = false;
}
}
}
}

/// <inheritdoc />
public Material MeshVisibleMaterial { get; }
Expand Down

0 comments on commit 3f1cc7d

Please sign in to comment.