//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using System.Runtime.CompilerServices;
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// A convex hull builder that tries to create 2D hulls as accurately as possible. Used for offline processing.
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder2D.h:14
///
/// class ConvexHullBuilder2D : public NonCopyable
///
///
[InteropHandle]
public readonly partial struct ConvexHullBuilder2D : IDisposable
{
///
///
/// Result enum that indicates how the hull got created
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder2D.h:28
///
/// enum class EResult
///
///
public enum Result : int
{
///
///
/// Hull building finished successfully
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder2D.h:30
///
/// Success
///
///
Success,
///
///
/// Hull building finished successfully, but the desired accuracy was not reached because the max
/// vertices limit was reached
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder2D.h:31
///
/// MaxVerticesReached
///
///
MaxVerticesReached,
}
///
///
/// Constructor
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder2D.h:22
///
/// explicit ConvexHullBuilder2D(const Positions &inPositions)
///
///
///
///
/// Constructor
/// @param inPositions Positions used to make the hull. Uses X and Y component of Vec3 only!
///
///
/// positions is copied into a native container the object keeps; the span is only read.
///
///
public static unsafe ConvexHullBuilder2D Create(ReadOnlySpan positions)
{
fixed (float3* positions_fixed = positions)
{
return Jolt.PInvoke.ConvexHullBuilder2D_Create(positions_fixed, (nuint)positions.Length);
}
}
///
///
/// Takes all positions as provided by the constructor and use them to build a hull Any points that are
/// closer to the hull than inTolerance will be discarded
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder2D.h:41
///
/// EResult Initialize(int inIdx1, int inIdx2, int inIdx3, int inMaxVertices, float inTolerance, Edges &outEdges)
///
///
///
///
/// Takes all positions as provided by the constructor and use them to build a hull
/// Any points that are closer to the hull than inTolerance will be discarded
/// @param inIdx1 , inIdx2 , inIdx3 The indices to use as initial hull (in any order)
/// @param inMaxVertices Max vertices to allow in the hull. Specify INT_MAX if there is no limit.
/// @param inTolerance Max distance that a point is allowed to be outside of the hull
/// @param outEdges On success this will contain the list of indices that form the hull (counter clockwise)
/// @return Status code that reports if the hull was created or not
///
///
/// edges is an owned native buffer - read it through AsSpan() and Dispose it when you are done with it.
///
///
public ConvexHullBuilder2D.Result Initialize(
int idx1,
int idx2,
int idx3,
int maxVertices,
float tolerance,
out NativeArray edges
)
{
var _result = Jolt.PInvoke.ConvexHullBuilder2D_Initialize(
this,
idx1,
idx2,
idx3,
maxVertices,
tolerance,
out var edges_raw
);
edges = new NativeArray(edges_raw);
return _result;
}
public void Dispose() => Jolt.PInvoke.ConvexHullBuilder2D_Destroy(this);
}
}