Skip to content

Commit a286bc5

Browse files
Merge pull request #594 from Sacristan/master
Added event when scan is done and a bool property whether Any mesh sectors been scanned
2 parents 8961267 + 15b1be2 commit a286bc5

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

Assets/HoloToolkit/SpatialMapping/Scripts/SpatialMappingManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public partial class SpatialMappingManager : Singleton<SpatialMappingManager>
4747
[HideInInspector]
4848
public float StartTime { get; private set; }
4949

50+
/// <summary>
51+
/// SurfaceMappingObserver GET
52+
/// </summary>
53+
public SpatialMappingObserver SurfaceObserver { get { return surfaceObserver; } }
54+
5055
/// <summary>
5156
/// The current source of spatial mapping data.
5257
/// </summary>

Assets/HoloToolkit/SpatialUnderstanding/Scripts/SpatialUnderstanding.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public bool AllowSpatialUnderstanding
4747
return true;
4848
}
4949
}
50+
5051
/// <summary>
5152
/// Reference to the SpatialUnderstandingDLL class (wraps the understanding dll functions).
5253
/// </summary>
@@ -97,7 +98,14 @@ public bool ScanStatsReportStillWorking
9798
}
9899
}
99100

101+
public delegate void OnScanDoneDelegate();
102+
100103
// Events
104+
/// <summary>
105+
/// Event indicating that the scan is done
106+
/// </summary>
107+
public event OnScanDoneDelegate OnScanDone;
108+
101109
/// <summary>
102110
/// Event indicating that the scan state has changed
103111
/// </summary>
@@ -247,7 +255,7 @@ private void Update_Scan(float deltaTime)
247255

248256
// If it's done, finish up
249257
if ((ScanState == ScanStates.Finishing) &&
250-
(scanDone) &&
258+
(scanDone) &&
251259
(!UnderstandingCustomMesh.IsImportActive) &&
252260
(UnderstandingCustomMesh != null))
253261
{
@@ -256,6 +264,7 @@ private void Update_Scan(float deltaTime)
256264

257265
// Mark it
258266
ScanState = ScanStates.Done;
267+
if (OnScanDone != null) OnScanDone.Invoke();
259268
}
260269
}
261270
}

Assets/HoloToolkit/SpatialUnderstanding/Scripts/SpatialUnderstandingCustomMesh.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ private float MaxFrameTimeInSeconds
3939
public bool CreateMeshColliders = true;
4040

4141
private bool drawProcessedMesh = true;
42+
4243
// Properties
4344
/// <summary>
4445
/// Controls rendering of the mesh. This can be set by the user to hide or show the mesh.
@@ -59,6 +60,11 @@ public bool DrawProcessedMesh
5960
}
6061
}
6162

63+
/// <summary>
64+
/// Have any mesh sectors been scanned
65+
/// </summary>
66+
public bool HasMeshSectors { get { return meshSectors != null && meshSectors.Count > 0; } }
67+
6268
/// <summary>
6369
/// Indicates if the previous import is still being processed.
6470
/// </summary>
@@ -80,13 +86,13 @@ public bool DrawProcessedMesh
8086
private SpatialUnderstanding spatialUnderstanding;
8187

8288
/// <summary>
83-
/// The spatial understanding mesh will be split into pieces so that we don't have to
89+
/// The spatial understanding mesh will be split into pieces so that we don't have to
8490
/// render the whole mesh, rather just the parts that are visible to the user.
8591
/// </summary>
8692
private Dictionary<Vector3, MeshData> meshSectors = new Dictionary<Vector3, MeshData>();
8793

8894
/// <summary>
89-
/// A data structure to manage collecting triangles as we
95+
/// A data structure to manage collecting triangles as we
9096
/// subdivide the spatial understanding mesh into smaller sub meshes.
9197
/// </summary>
9298
private class MeshData
@@ -157,11 +163,11 @@ public void Commit()
157163
/// <param name="point3">Third point on the triangle.</param>
158164
public void AddTriangle(Vector3 point1, Vector3 point2, Vector3 point3)
159165
{
160-
// Currently spatial understanding in the native layer voxellizes the space
161-
// into ~2000 voxels per cubic meter. Even in a degerate case we
166+
// Currently spatial understanding in the native layer voxellizes the space
167+
// into ~2000 voxels per cubic meter. Even in a degerate case we
162168
// will use far fewer than 65000 vertices, this check should not fail
163169
// unless the spatial understanding native layer is updated to have more
164-
// voxels per cubic meter.
170+
// voxels per cubic meter.
165171
if (verts.Count < 65000)
166172
{
167173
tris.Add(verts.Count);
@@ -195,7 +201,7 @@ private void Update()
195201
}
196202

197203
/// <summary>
198-
/// Adds a triangle with the specified points to the specified sector.
204+
/// Adds a triangle with the specified points to the specified sector.
199205
/// </summary>
200206
/// <param name="sector">The sector to add the triangle to.</param>
201207
/// <param name="point1">First point of the triangle.</param>
@@ -289,8 +295,8 @@ public IEnumerator Import_UnderstandingMesh()
289295
}
290296

291297
float startTime = Time.realtimeSinceStartup;
292-
// first we need to split the playspace up into segments so we don't always
293-
// draw everything. We can break things up in to cubic meters.
298+
// first we need to split the playspace up into segments so we don't always
299+
// draw everything. We can break things up in to cubic meters.
294300
for (int index = 0; index < meshIndices.Length; index += 3)
295301
{
296302
Vector3 firstVertex = meshVertices[meshIndices[index]];
@@ -389,7 +395,7 @@ private Vector3 VectorToSector(Vector3 vector)
389395
}
390396

391397
/// <summary>
392-
/// Updates the mesh import process. This function will kick off the import
398+
/// Updates the mesh import process. This function will kick off the import
393399
/// coroutine at the requested internal.
394400
/// </summary>
395401
private void Update_MeshImport()
@@ -411,4 +417,4 @@ private void OnDestroy()
411417
}
412418
}
413419

414-
}
420+
}

0 commit comments

Comments
 (0)