-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ViRGIS-Team/2.5.0
2.5.0
- Loading branch information
Showing
11 changed files
with
672 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
This plugin will be updated as and when new versions of PDAL are released and will use the version numbers from PDAL. | ||
|
||
2.2.0+3 : | ||
# Version 2.5.0 | ||
|
||
Updates PDAL to version 2.5.0 using pdalc version 2.2.0 to get over the Pipeline Executor deprecation. | ||
|
||
This version also moves the conda build to an Asset Post Processor and standardizes assembly names - so there may/will be minor changes in how it operates - including if other assemblies reference this assembly directly. | ||
|
||
This version also moves the processing in `BakedPointCloud` to the Unity Job System for faster processing. | ||
|
||
# 2.2.0+3 : | ||
|
||
- Fixes Bug whne there is a space in the project name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using g3; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Unity.Collections; | ||
using Unity.Jobs; | ||
using UnityEngine; | ||
using Unity.Burst; | ||
|
||
|
||
namespace Pdal | ||
{ | ||
/// <summary> | ||
/// Class for Holding and Manipulating Meshes Loaded Using PDAL | ||
/// </summary> | ||
public class BakedMesh | ||
{ | ||
|
||
public DMesh3 Dmesh; | ||
public BakedMesh() { } | ||
|
||
/// <summary> | ||
/// Load a PointView as a Mesh | ||
/// </summary> | ||
/// <param name="view">Pointview</param> | ||
/// <returns></returns> | ||
/// <exception cref="Exception"></exception> | ||
public async static Task<BakedMesh> Initialize(PointView view) | ||
{ | ||
BakedPointCloud bpc = await BakedPointCloud.Initialize(view); | ||
NativeArray<byte> Data = new(view.GetPackedMesh(out ulong dataSize), Allocator.Persistent); | ||
if (dataSize == 0) throw new Exception("BakedMesh : No Mesh Found"); | ||
|
||
ulong sizeTri = dataSize / 12; | ||
|
||
NativeArray<Int32> Tris = new(new Int32[sizeTri * 3], Allocator.Persistent); | ||
|
||
DecodeMesh dm = new() { | ||
Data = Data, | ||
Tris = Tris, | ||
}; | ||
|
||
JobHandle jh = dm.Schedule((int)sizeTri, 100); | ||
jh.Complete(); | ||
|
||
NativeArray<Color> positions = bpc.PositionMap.GetRawTextureData<Color>(); | ||
NativeArray<Color32> colors = bpc.ColorMap.GetRawTextureData<Color32>(); | ||
|
||
double[] vertices= new double[bpc.PointCount * 3 ]; | ||
|
||
|
||
for (int i = 0; i < bpc.PointCount; i++) | ||
{ | ||
Color position = positions[i]; | ||
vertices[3 * i] = position.r; | ||
vertices[3 * i + 1] = position.g; | ||
vertices[3 * i + 2] = position.b; | ||
} | ||
|
||
// Now we can make the Mesh | ||
BakedMesh bm = new() | ||
{ | ||
Dmesh = DMesh3Builder.Build<double, int, int>(vertices, Tris) | ||
}; | ||
if (colors.Length > 0) | ||
{ | ||
bm.Dmesh.EnableVertexColors(new Vector3f()); | ||
foreach (int idx in bm.Dmesh.VertexIndices()) | ||
{ | ||
bm.Dmesh.SetVertexColor(idx, new Vector3f(colors[idx].r / 256, colors[idx].g / 256, colors[idx].b / 256)); | ||
} | ||
} | ||
|
||
positions.Dispose(); | ||
colors.Dispose(); | ||
Data.Dispose(); | ||
Tris.Dispose(); | ||
return bm; | ||
} | ||
|
||
/// <summary> | ||
/// Job System Job that is used to iterate the Vertices | ||
/// </summary> | ||
[BurstCompile] | ||
public struct DecodeMesh : IJobParallelFor | ||
{ | ||
[ReadOnly] | ||
public NativeArray<byte> Data; | ||
|
||
[NativeDisableParallelForRestriction] | ||
public NativeArray<Int32> Tris; | ||
|
||
public void Execute(int job) | ||
{ | ||
int pointer = job * 3; | ||
int index = pointer * 4; | ||
|
||
if (index + 12 > Data.Length) | ||
return; | ||
Tris[pointer] = (int)Data.ReinterpretLoad<UInt32>(index); | ||
Tris[pointer + 1] = (int)Data.ReinterpretLoad<UInt32>(index + 4); | ||
Tris[pointer + 2] = (int)Data.ReinterpretLoad<UInt32>(index + 8); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.