Managed input support
This package provides an extension for easily adapting managed arrays (i.e., standard C# arrays T2[]
) for use as input in triangulation. To achieve this, you can use the AsNativeArray
extension. However, the user must manually release the data from the garbage collector by calling Handle.Free()
.
This step ensures that the garbage collector does not prematurely release memory, preventing accidental memory issues.
using var triangulator = new Triangulator<float2>(Allocator.Persistent)
{
Input = new ManagedInput<float2>
{
Positions = new float2[] { new(0, 0), new(1, 0), new(1, 1), new(0, 1) }.AsNativeArray(out var handle)
},
};
...
handle.Free();
Note
AsNativeArray
is allocation-free. It provides native array views for triangulation without additional memory allocation.