//
// 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
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:40
///
/// class ConvexHullShape final : public ConvexShape
///
///
[InteropHandle]
public readonly partial struct ConvexHullShape : IDisposable
{
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:167
///
/// struct Face
///
///
[StructLayout(LayoutKind.Explicit, Size = 4)]
public partial struct Face
{
///
///
/// First index in mVertexIdx to use
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:169
///
/// uint16 mFirstVertex
///
///
[FieldOffset(0)]
public ushort FirstVertex;
///
///
/// Number of vertices in the mVertexIdx to use
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:170
///
/// uint16 mNumVertices = 0
///
///
[FieldOffset(2)]
public ushort NumVertices;
}
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:176
///
/// struct Point
///
///
[StructLayout(LayoutKind.Explicit, Size = 32)]
public partial struct Point
{
///
///
/// Position of vertex
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:178
///
/// Vec3 mPosition
///
///
[FieldOffset(0)]
public float3 Position;
///
///
/// Number of faces in the face array below
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:179
///
/// int mNumFaces = 0
///
///
[FieldOffset(16)]
public int NumFaces;
///
///
/// Indices of 3 neighboring faces with the biggest difference in normal (used to shift vertices for
/// convex radius)
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:180
///
/// int mFaces[3] = { -1, -1, -1 }
///
///
[FieldOffset(20)]
public int_3 Faces;
}
///
///
/// Constructor
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:50
///
/// ConvexHullShape()
///
///
public static ConvexHullShape Create() => Jolt.PInvoke.ConvexHullShape_Create();
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:51
///
/// ConvexHullShape(const ConvexHullShapeSettings &inSettings, ShapeResult &outResult)
///
///
public static ConvexHullShape Create(ConvexHullShapeSettings settings)
{
var _handle = Jolt.PInvoke.ConvexHullShape_Create_2(settings);
if (_handle.IsNull())
throw JoltException.FromLastError();
return _handle;
}
///
public float3 GetCenterOfMass() => ((Shape)this).GetCenterOfMass();
///
public AABox GetLocalBounds() => ((Shape)this).GetLocalBounds();
///
public float GetInnerRadius() => ((Shape)this).GetInnerRadius();
///
public MassProperties GetMassProperties() => ((Shape)this).GetMassProperties();
///
public float3 GetSurfaceNormal(uint subShapeID, float3 localSurfacePosition) =>
((Shape)this).GetSurfaceNormal(subShapeID, localSurfacePosition);
///
public void GetSupportingFace(
uint subShapeID,
float3 direction,
float3 scale,
in float4x4 centerOfMassTransform,
out StaticArrayVec3_32 vertices
) => ((Shape)this).GetSupportingFace(subShapeID, direction, scale, in centerOfMassTransform, out vertices);
///
public void GetSubmergedVolume(
in float4x4 centerOfMassTransform,
float3 scale,
in Plane surface,
out float totalVolume,
out float submergedVolume,
out float3 centerOfBuoyancy,
float3 baseOffset
) =>
((Shape)this).GetSubmergedVolume(
in centerOfMassTransform,
scale,
in surface,
out totalVolume,
out submergedVolume,
out centerOfBuoyancy,
baseOffset
);
///
public void Draw(
DebugRenderer renderer,
in float4x4 centerOfMassTransform,
float3 scale,
uint color,
bool useMaterialColors,
bool drawWireframe
) => ((Shape)this).Draw(renderer, in centerOfMassTransform, scale, color, useMaterialColors, drawWireframe);
///
///
/// Debugging helper draw function that draws how all points are moved when a shape is shrunk by the convex
/// radius
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:82
///
/// void DrawShrunkShape(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, Vec3Arg inScale) const
///
///
public void DrawShrunkShape(DebugRenderer renderer, in float4x4 centerOfMassTransform, float3 scale) =>
Jolt.PInvoke.ConvexHullShape_DrawShrunkShape(this, renderer, in centerOfMassTransform, scale);
///
public bool CastRay(in RayCast ray, SubShapeIDCreator subShapeIDCreator, ref RayCastResult hit) =>
((Shape)this).CastRay(in ray, subShapeIDCreator, ref hit);
///
public unsafe uint CastRay(
in RayCast ray,
RayCastSettings rayCastSettings,
SubShapeIDCreator subShapeIDCreator,
Span results,
out uint totalHits,
ShapeFilter shapeFilter = default
) => ((Shape)this).CastRay(in ray, rayCastSettings, subShapeIDCreator, results, out totalHits, shapeFilter);
///
public bool CastRayClosest(
in RayCast ray,
RayCastSettings rayCastSettings,
SubShapeIDCreator subShapeIDCreator,
out RayCastResult result,
ShapeFilter shapeFilter = default
) => ((Shape)this).CastRayClosest(in ray, rayCastSettings, subShapeIDCreator, out result, shapeFilter);
///
public unsafe uint CollidePoint(
float3 point,
SubShapeIDCreator subShapeIDCreator,
Span results,
out uint totalHits,
ShapeFilter shapeFilter = default
) => ((Shape)this).CollidePoint(point, subShapeIDCreator, results, out totalHits, shapeFilter);
///
public void CollideSoftBodyVertices(
in float4x4 centerOfMassTransform,
float3 scale,
CollideSoftBodyVertexIterator vertices,
uint numVertices,
int collidingShapeIndex
) =>
((Shape)this).CollideSoftBodyVertices(
in centerOfMassTransform,
scale,
vertices,
numVertices,
collidingShapeIndex
);
///
public void GetTrianglesStart(
ref Shape.GetTrianglesContext context,
in AABox box,
float3 positionCOM,
floatQuat rotation,
float3 scale
) => ((Shape)this).GetTrianglesStart(ref context, in box, positionCOM, rotation, scale);
///
public unsafe int GetTrianglesNext(
ref Shape.GetTrianglesContext context,
int maxTrianglesRequested,
Ptr triangleVertices,
Ptr materials = default
) => ((Shape)this).GetTrianglesNext(ref context, maxTrianglesRequested, triangleVertices, materials);
///
public void SaveBinaryState(StreamOut stream) => ((Shape)this).SaveBinaryState(stream);
///
public Shape.Stats GetStats() => ((Shape)this).GetStats();
///
public float GetVolume() => ((Shape)this).GetVolume();
///
///
/// Get the convex radius of this convex hull
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:111
///
/// float GetConvexRadius() const
///
///
public float GetConvexRadius() => Jolt.PInvoke.ConvexHullShape_GetConvexRadius(this);
///
///
/// Get the planes of this convex hull
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:114
///
/// const Array<Plane> & GetPlanes() const
///
///
///
///
/// The span is a view of the container's own storage, not a copy, so it costs nothing to take. It's only
/// valid until that container is resized or its owner is destroyed.
///
///
[return: Brutal.Attributes.Fixed]
public unsafe ReadOnlySpan GetPlanes()
{
Jolt.PInvoke.ConvexHullShape_GetPlanes(this, out var _outResult);
return new ReadOnlySpan((void*)_outResult.Data, checked((int)_outResult.Count));
}
///
///
/// Get the number of vertices in this convex hull
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:117
///
/// inline uint GetNumPoints() const
///
///
public uint GetNumPoints() => Jolt.PInvoke.ConvexHullShape_GetNumPoints(this);
///
///
/// Get a vertex of this convex hull relative to the center of mass
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:120
///
/// inline Vec3 GetPoint(uint inIndex) const
///
///
public float3 GetPoint(uint index)
{
var _result = Jolt.PInvoke.ConvexHullShape_GetPoint(this, index, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(index),
index,
"Expected an index below the number of points."
);
return _result;
}
///
///
/// Get the number of faces in this convex hull
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:123
///
/// inline uint GetNumFaces() const
///
///
public uint GetNumFaces() => Jolt.PInvoke.ConvexHullShape_GetNumFaces(this);
///
///
/// Get the number of vertices in a face
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:126
///
/// inline uint GetNumVerticesInFace(uint inFaceIndex) const
///
///
public uint GetNumVerticesInFace(uint faceIndex)
{
var _result = Jolt.PInvoke.ConvexHullShape_GetNumVerticesInFace(this, faceIndex, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(faceIndex),
faceIndex,
"Expected an index below the number of faces."
);
return _result;
}
///
///
/// Get the vertices indices of a face
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:133
///
/// inline uint GetFaceVertices(uint inFaceIndex, uint inMaxVertices, uint *outVertices) const
///
///
///
///
/// Get the vertices indices of a face
/// @param inFaceIndex Index of the face.
/// @param inMaxVertices Maximum number of vertices to return.
/// @param outVertices Array of vertices indices, must be at least inMaxVertices in size, the vertices are returned in counter clockwise order and the positions can be obtained using GetPoint(index).
/// @return Number of vertices in face, if this is bigger than inMaxVertices, not all vertices were retrieved.
///
///
/// vertices is the buffer the native call fills, and its capacity travels with it: the call writes at most
/// as many elements as the span holds, and only for the duration of the call.
///
///
public unsafe uint GetFaceVertices(uint faceIndex, Span vertices)
{
fixed (uint* vertices_fixed = vertices)
{
var _result = Jolt.PInvoke.ConvexHullShape_GetFaceVertices(
this,
faceIndex,
(uint)vertices.Length,
vertices_fixed,
out var _inRange
);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(faceIndex),
faceIndex,
"Expected an index below the number of faces."
);
return _result;
}
}
///
///
/// Register shape functions with the registry
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:144
///
/// static void sRegister()
///
///
public static void Register() => Jolt.PInvoke.ConvexHullShape_Register();
///
///
/// Maximum amount of points supported in a convex hull. Note that while constructing a hull, interior
/// points are discarded so you can provide more points. The ConvexHullShapeSettings::Create function will
/// return an error when too many points are provided.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:47
///
/// static constexpr int cMaxPointsInHull = 256
///
///
public static int GetMaxPointsInHull() => Jolt.PInvoke.ConvexHullShape_GetMaxPointsInHull();
///
///
/// Draw the outlines of the faces of the convex hull when drawing the shape
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:148
///
/// inline static bool sDrawFaceOutlines = false
///
///
public static bool GetDrawFaceOutlines() => Jolt.PInvoke.ConvexHullShape_GetDrawFaceOutlines();
///
///
/// Draw the outlines of the faces of the convex hull when drawing the shape
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/ConvexHullShape.h:148
///
/// inline static bool sDrawFaceOutlines = false
///
///
public static void SetDrawFaceOutlines(bool value) => Jolt.PInvoke.ConvexHullShape_SetDrawFaceOutlines(value);
public void AddRef() => ((Shape)this).AddRef();
public void Release() => ((Shape)this).Release();
public uint GetRefCount() => ((Shape)this).GetRefCount();
public static implicit operator ConvexShape(ConvexHullShape value) =>
Unsafe.BitCast(value);
public static implicit operator Shape(ConvexHullShape value) => Unsafe.BitCast(value);
public void Dispose()
{
if (IsNull())
return;
Release();
}
///
public PhysicsMaterial GetMaterial() => ((ConvexShape)this).GetMaterial();
///
public void SetMaterial(PhysicsMaterial material) => ((ConvexShape)this).SetMaterial(material);
///
public void SetDensity(float density) => ((ConvexShape)this).SetDensity(density);
///
public float GetDensity() => ((ConvexShape)this).GetDensity();
///
public ShapeType GetShapeType() => ((Shape)this).GetShapeType();
///
public ShapeSubType GetSubType() => ((Shape)this).GetSubType();
///
public ulong GetUserData() => ((Shape)this).GetUserData();
///
public void SetUserData(ulong userData) => ((Shape)this).SetUserData(userData);
///
public bool MustBeStatic() => ((Shape)this).MustBeStatic();
///
public uint GetSubShapeIDBitsRecursive() => ((Shape)this).GetSubShapeIDBitsRecursive();
///
public AABox GetWorldSpaceBounds(in float4x4 centerOfMassTransform, float3 scale) =>
((Shape)this).GetWorldSpaceBounds(in centerOfMassTransform, scale);
///
public AABox GetWorldSpaceBounds(in double4x4 centerOfMassTransform, float3 scale) =>
((Shape)this).GetWorldSpaceBounds(in centerOfMassTransform, scale);
///
public Shape GetLeafShape(uint subShapeID, out uint remainder) =>
((Shape)this).GetLeafShape(subShapeID, out remainder);
///
public PhysicsMaterial GetMaterial(uint subShapeID) => ((Shape)this).GetMaterial(subShapeID);
///
public ulong GetSubShapeUserData(uint subShapeID) => ((Shape)this).GetSubShapeUserData(subShapeID);
///
public TransformedShape GetSubShapeTransformedShape(
uint subShapeID,
float3 positionCOM,
floatQuat rotation,
float3 scale,
out uint remainder
) => ((Shape)this).GetSubShapeTransformedShape(subShapeID, positionCOM, rotation, scale, out remainder);
///
public void DrawGetSupportFunction(
DebugRenderer renderer,
in float4x4 centerOfMassTransform,
float3 scale,
uint color,
bool drawSupportDirection
) =>
((Shape)this).DrawGetSupportFunction(
renderer,
in centerOfMassTransform,
scale,
color,
drawSupportDirection
);
///
public void DrawGetSupportingFace(DebugRenderer renderer, in float4x4 centerOfMassTransform, float3 scale) =>
((Shape)this).DrawGetSupportingFace(renderer, in centerOfMassTransform, scale);
///
public NativeHandleArray CollectTransformedShapes(
in AABox box,
float3 positionCOM,
floatQuat rotation,
float3 scale,
SubShapeIDCreator subShapeIDCreator,
ShapeFilter shapeFilter
) =>
((Shape)this).CollectTransformedShapes(
in box,
positionCOM,
rotation,
scale,
subShapeIDCreator,
shapeFilter
);
///
public NativeHandleArray TransformShape(in float4x4 centerOfMassTransform) =>
((Shape)this).TransformShape(in centerOfMassTransform);
///
public Shape ScaleShape(float3 scale) => ((Shape)this).ScaleShape(scale);
///
public NativeArray SaveMaterialState() => ((Shape)this).SaveMaterialState();
///
public unsafe void RestoreMaterialState(ReadOnlySpan materials) =>
((Shape)this).RestoreMaterialState(materials);
///
public NativeArray SaveSubShapeState() => ((Shape)this).SaveSubShapeState();
///
public unsafe void RestoreSubShapeState(ReadOnlySpan subShapes) =>
((Shape)this).RestoreSubShapeState(subShapes);
///
public void SaveWithChildren(StreamOut stream, ShapeToIDMap shapeMap, MaterialToIDMap materialMap) =>
((Shape)this).SaveWithChildren(stream, shapeMap, materialMap);
///
public bool IsValidScale(float3 scale) => ((Shape)this).IsValidScale(scale);
///
public float3 MakeScaleValid(float3 scale) => ((Shape)this).MakeScaleValid(scale);
}
}