From 5362572a59ab071a01faf76ce26573629f4ddc1c Mon Sep 17 00:00:00 2001 From: andywiecko Date: Tue, 26 Nov 2024 18:54:29 +0100 Subject: [PATCH] docs: dynamic remove bulk point --- .../manual/advanced/dynamic-triangulation.md | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/Documentation~/manual/advanced/dynamic-triangulation.md b/Documentation~/manual/advanced/dynamic-triangulation.md index 1e75916..bccf000 100644 --- a/Documentation~/manual/advanced/dynamic-triangulation.md +++ b/Documentation~/manual/advanced/dynamic-triangulation.md @@ -7,12 +7,6 @@ uid: dynamic-triangulation-manual Using the [`UnsafeTriangulator`][unsafe-triangulator] API, you can perform dynamic triangulation. This feature is especially useful in scenarios like path-finding in RTS games, where recalculating only a small portion of the mesh, instead of the entire mesh, can significantly improve efficiency. -| Method | Implemented | -| :--------------------------------------------- | :---: | -| [DynamicInsertPoint][dynamic-insert-point] | ✔️ | -| [DynamicSplitHalfedge][dynamic-split-halfedge] | ✔️ | -| DynamicRemovePoint | ❌ | - ## DynamicInsertPoint The [DynamicInsertPoint][dynamic-insert-point] method allows you to insert a point into a specified triangle using barycentric coordinates. This method only supports point insertion within the original triangulation domain and cannot be used to insert points outside the existing mesh. @@ -105,10 +99,35 @@ for(int i = 0; i < 32; i++) } ``` -## DynamicRemovePoint +## DynamicRemoveBulkPoint + +The [DynamicRemoveBulkPoint][dynamic-remove-point] method allows you to remove bulk points, i.e. points which are not boundary ones, and re-triangulates the affected region to maintain a valid triangulation. +In addition to `output` and `allocator`, the method requires the index of the point to be removed, specified as `pId`. + +Below is an example demonstrating how to use the [DynamicRemoveBulkPoint][dynamic-remove-point] API: + +```csharp +using var inputPositions = new NativeArray(..., Allocator.Persistent); +using var outputPositions = new NativeList(Allocator.Persistent); +using var triangles = new NativeList(Allocator.Persistent); +using var constrainedHalfedges = new NativeList(Allocator.Persistent); +using var halfedges = new NativeList(Allocator.Persistent); -Not implemented. +var t = new UnsafeTriangulator(); +var input = new InputData { Positions = inputPositions }; +var output = new OutputData +{ + Positions = outputPositions, + Triangles = triangles, + ConstrainedHalfedges = constrainedHalfedges, + Halfedges = halfedges, +}; + +t.Triangulate(input, output, args: Args.Default(), allocator: Allocator.Persistent); +t.DynamicRemoveBulkPoint(output, pId: 8, allocator: Allocator.Persistent); +``` [unsafe-triangulator]: xref:andywiecko.BurstTriangulator.LowLevel.Unsafe.UnsafeTriangulator`1 [dynamic-insert-point]: xref:andywiecko.BurstTriangulator.LowLevel.Unsafe.Extensions.DynamicInsertPoint* [dynamic-split-halfedge]: xref:andywiecko.BurstTriangulator.LowLevel.Unsafe.Extensions.DynamicSplitHalfedge* +[dynamic-remove-point]: xref:andywiecko.BurstTriangulator.LowLevel.Unsafe.Extensions.DynamicRemoveBulkPoint*