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

Commit

Permalink
Fixing issue #35 - SurfaceObserver not starting
Browse files Browse the repository at this point in the history
Adds the Start() method back to SpatialMappingManager, which was
accidentally removed during the last update. This method is repsonsible
for starting the SurfaceObserver.
Also fixed: the RecalculateNormals was no longer present in
SpatialMappingObserver.cs. This call is required when using shaders
(like 'BlueLinesOnWalls') that rely on surface mesh normals being
correct.
  • Loading branch information
angelaHillier committed Jan 26, 2017
1 parent 13f19be commit c33c829
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public partial class SpatialMappingManager : Singleton<SpatialMappingManager>
[Tooltip("Determines if spatial mapping data will cast shadows.")]
public bool castShadows = false;

[Tooltip("Determines if the surface observer should be automatically started.")]
public bool autoStartObserver = true;

/// <summary>
/// Used for gathering real-time Spatial Mapping data on the HoloLens.
/// </summary>
Expand All @@ -54,6 +57,14 @@ protected void Awake()
Source = surfaceObserver;
}

private void Start()
{
if(autoStartObserver)
{
StartObserver();
}
}

/// <summary>
/// Returns the layer as a bit mask.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class SpatialMappingObserver : SpatialMappingSource
[Tooltip("How long to wait (in sec) between Spatial Mapping updates.")]
public float TimeBetweenUpdates = 3.5f;

[Tooltip("Recalculates normals whenever a mesh is updated.")]
public bool RecalculateNormals = false;

/// <summary>
/// Event for hooking when surfaces are changed.
/// </summary>
Expand Down Expand Up @@ -241,6 +244,15 @@ private void SurfaceObserver_OnDataReady(SurfaceData cookedData, bool outputWrit
renderer.sharedMaterial = SpatialMappingManager.Instance.SurfaceMaterial;
renderer.enabled = SpatialMappingManager.Instance.DrawVisualMeshes;

if (RecalculateNormals)
{
MeshFilter filter = surface.GetComponent<MeshFilter>();
if(filter != null && filter.sharedMesh != null)
{
filter.sharedMesh.RecalculateNormals();
}
}

if (SpatialMappingManager.Instance.CastShadows == false)
{
renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
Expand Down
Binary file modified Starting/Planetarium.unitypackage
Binary file not shown.

0 comments on commit c33c829

Please sign in to comment.