//
// 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 hulls as accurately as possible. Used for offline processing.
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:20
///
/// class ConvexHullBuilder : public NonCopyable
///
///
[InteropHandle]
public readonly partial struct ConvexHullBuilder : IDisposable
{
///
///
/// Result enum that indicates how the hull got created
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:96
///
/// enum class EResult
///
///
public enum Result : int
{
///
///
/// Hull building finished successfully
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:98
///
/// Success
///
///
Success,
///
///
/// Hull building finished successfully, but the desired accuracy was not reached because the max
/// vertices limit was reached
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:99
///
/// MaxVerticesReached
///
///
MaxVerticesReached,
///
///
/// Too few points to create a hull
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:100
///
/// TooFewPoints
///
///
TooFewPoints,
///
///
/// Too few faces in the created hull (signifies precision errors during building)
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:101
///
/// TooFewFaces
///
///
TooFewFaces,
///
///
/// Degenerate hull detected
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:102
///
/// Degenerate
///
///
Degenerate,
}
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:263
///
/// struct Coplanar
///
///
[StructLayout(LayoutKind.Explicit, Size = 8)]
public partial struct Coplanar
{
///
///
/// Index in mPositions
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:265
///
/// int mPositionIdx
///
///
[FieldOffset(0)]
public int PositionIdx;
///
///
/// Distance to the edge of closest face (should be > 0)
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:266
///
/// float mDistanceSq
///
///
[FieldOffset(4)]
public float DistanceSq;
}
///
///
/// Constructor
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:90
///
/// explicit ConvexHullBuilder(const Positions &inPositions)
///
///
///
///
/// positions is copied into a native container the object keeps; the span is only read.
///
///
public static unsafe ConvexHullBuilder Create(ReadOnlySpan positions)
{
fixed (float3* positions_fixed = positions)
{
return Jolt.PInvoke.ConvexHullBuilder_Create(positions_fixed, (nuint)positions.Length);
}
}
///
///
/// Returns the amount of vertices that are currently used by the hull
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:114
///
/// int GetNumVerticesUsed() const
///
///
public int GetNumVerticesUsed() => Jolt.PInvoke.ConvexHullBuilder_GetNumVerticesUsed(this);
///
///
/// Returns true if the hull contains a polygon with inIndices (counter clockwise indices in mPositions)
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:117
///
/// bool ContainsFace(const Array<int> &inIndices) const
///
///
///
///
/// indices is copied into a native container for the call; the span is only read.
///
///
public unsafe bool ContainsFace(ReadOnlySpan indices)
{
fixed (int* indices_fixed = indices)
{
return Jolt.PInvoke.ConvexHullBuilder_ContainsFace(this, indices_fixed, (nuint)indices.Length);
}
}
///
///
/// Calculate the center of mass and the volume of the current convex hull
///
///
/// C++:
/// Jolt/Geometry/ConvexHullBuilder.h:120
///
/// void GetCenterOfMassAndVolume(Vec3 &outCenterOfMass, float &outVolume) const
///
///
public void GetCenterOfMassAndVolume(out float3 centerOfMass, out float volume) =>
Jolt.PInvoke.ConvexHullBuilder_GetCenterOfMassAndVolume(this, out centerOfMass, out volume);
public void Dispose() => Jolt.PInvoke.ConvexHullBuilder_Destroy(this);
}
}