From 2033ff7a0b22f1115558181af7871e3e809075f2 Mon Sep 17 00:00:00 2001 From: bart <bart.knuiman@wur.nl> Date: Wed, 3 May 2023 12:43:28 +0200 Subject: [PATCH] Fixes --- Runtime/Lidar/LAZLoader.cs | 4 +++- Runtime/Lidar/LAZOctreeCell.cs | 5 +++-- .../Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs | 14 +++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Runtime/Lidar/LAZLoader.cs b/Runtime/Lidar/LAZLoader.cs index d2d9150..c8171d8 100644 --- a/Runtime/Lidar/LAZLoader.cs +++ b/Runtime/Lidar/LAZLoader.cs @@ -674,7 +674,7 @@ namespace LAZNamespace #endregion #region Generic Tasks - public GenericTask StartGenericTask( Action callback, Action onDone=null ) + public GenericTask StartGenericTask( Action callback, Action onDone=null, bool executeOnMain=false ) { // Lazy initialize, if not already on main thread. if (genericTasks == null) @@ -690,6 +690,8 @@ namespace LAZNamespace gt.done = false; uint taskIdx = (uint) genericTaskIterator++; taskIdx %= (uint)numGenericTasks; + if (executeOnMain) + taskIdx = 0; // This allows ordered execution of tasks. lock (genericTasks[taskIdx]) { genericTasks[taskIdx].Add( gt ); diff --git a/Runtime/Lidar/LAZOctreeCell.cs b/Runtime/Lidar/LAZOctreeCell.cs index 50377cd..7c2b6c4 100644 --- a/Runtime/Lidar/LAZOctreeCell.cs +++ b/Runtime/Lidar/LAZOctreeCell.cs @@ -495,7 +495,7 @@ namespace LAZNamespace var verticesSliced = vertices; if (verticesSliced== null) // Might be unloading the data. return; - System.Diagnostics.Debug.Assert( Directory.Exists( tree.PathToCacheFolder ) ); + Debug.Assert( Directory.Exists( tree.PathToCacheFolder ) ); var filePath = GetPathOnDisk().NormalizePath(); Monitor.Enter( this ); try @@ -510,6 +510,7 @@ namespace LAZNamespace { verticesSliced[i].Write( br ); } + br.Flush(); } } finally @@ -556,7 +557,7 @@ namespace LAZNamespace verticesNew.Add( ver ); } numPoints = verticesNew.Count; - System.Diagnostics.Debug.Assert( verticesNew.Count==vertCount, "Cache invalid. Clear cache and Reload files." ); + Debug.Assert( verticesNew.Count==vertCount, "Cache invalid. Clear cache and Reload files." ); vertices = verticesNew; } } diff --git a/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs b/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs index 6bf239e..e76df1a 100644 --- a/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs +++ b/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs @@ -59,13 +59,13 @@ namespace LAZNamespace } ); } } - // Regardless of visible, we must finish the task, otherewise it will only due when visible, but task was already started. - if (loadVoxelTask != null && loadVoxelTask.done) - { - loadVoxelTask = null; - FinalizeMeshData(); - UnityEngine.Debug.Log( "done updating mesh" ); - } + } + // Regardless of visible, we must finish the task, otherewise it will only due when visible, but task was already started. + if (loadVoxelTask != null && loadVoxelTask.done) + { + loadVoxelTask = null; + FinalizeMeshData(); + UnityEngine.Debug.Log( "done updating mesh" ); } return mesh; } -- GitLab