//
// 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 mesh shape, consisting of triangles. Mesh shapes are mostly used for static geometry. They can be used by
/// dynamic or kinematic objects but only if they don't collide with other mesh or heightfield shapes as those
/// collisions are currently not supported. Note that if you make a mesh shape a dynamic or kinematic object,
/// you need to provide a mass yourself as mesh shapes don't need to form a closed hull so don't have a well
/// defined volume from which the mass can be calculated.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:84
///
/// class MeshShape final : public Shape
///
///
[InteropHandle]
public readonly partial struct MeshShape : IDisposable
{
///
///
/// 8 bit flags stored per triangle
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:209
///
/// enum ETriangleFlags
///
///
public enum TriangleFlags : int
{
///
///
/// Material index
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:212
///
/// FLAGS_MATERIAL_BITS = 5
///
///
FLAGS_MATERIAL_BITS = 5,
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:213
///
/// FLAGS_MATERIAL_MASK = (1 << FLAGS_MATERIAL_BITS) - 1
///
///
FLAGS_MATERIAL_MASK = 31,
///
///
/// Active edge bits
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:216
///
/// FLAGS_ACTIVE_EGDE_SHIFT = FLAGS_MATERIAL_BITS
///
///
FLAGS_ACTIVE_EGDE_SHIFT = 5,
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:217
///
/// FLAGS_ACTIVE_EDGE_BITS = 3
///
///
FLAGS_ACTIVE_EDGE_BITS = 3,
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:218
///
/// FLAGS_ACTIVE_EDGE_MASK = (1 << FLAGS_ACTIVE_EDGE_BITS) - 1
///
///
FLAGS_ACTIVE_EDGE_MASK = 7,
}
///
///
/// Constructor
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:90
///
/// MeshShape()
///
///
public static MeshShape Create() => Jolt.PInvoke.MeshShape_Create();
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:91
///
/// MeshShape(const MeshShapeSettings &inSettings, ShapeResult &outResult)
///
///
public static MeshShape Create(MeshShapeSettings settings)
{
var _handle = Jolt.PInvoke.MeshShape_Create_2(settings);
if (_handle.IsNull())
throw JoltException.FromLastError();
return _handle;
}
///
public bool MustBeStatic() => ((Shape)this).MustBeStatic();
///
public AABox GetLocalBounds() => ((Shape)this).GetLocalBounds();
///
public uint GetSubShapeIDBitsRecursive() => ((Shape)this).GetSubShapeIDBitsRecursive();
///
public float GetInnerRadius() => ((Shape)this).GetInnerRadius();
///
public MassProperties GetMassProperties() => ((Shape)this).GetMassProperties();
///
public PhysicsMaterial GetMaterial(uint subShapeID) => ((Shape)this).GetMaterial(subShapeID);
///
///
/// Get the list of all materials
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:112
///
/// const PhysicsMaterialList & GetMaterialList() const
///
///
///
///
/// Returns an owned native buffer - read it through AsSpan() and Dispose it when you are done with it. The
/// handles in it are borrowed views into the buffer: they stay valid until Dispose and must not be disposed
/// themselves.
///
///
public NativeArray GetMaterialList() =>
new NativeArray(Jolt.PInvoke.MeshShape_GetMaterialList(this));
///
///
/// Determine which material index a particular sub shape uses (note that if there are no materials this
/// function will return 0 so check the array size) Note: This could for example be used to create a
/// decorator shape around a mesh shape that overrides the GetMaterial call to replace a material with
/// another material.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:116
///
/// uint GetMaterialIndex(const SubShapeID &inSubShapeID) const
///
///
public uint GetMaterialIndex(uint subShapeID) => Jolt.PInvoke.MeshShape_GetMaterialIndex(this, subShapeID);
///
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 Draw(
DebugRenderer renderer,
in float4x4 centerOfMassTransform,
float3 scale,
uint color,
bool useMaterialColors,
bool drawWireframe
) => ((Shape)this).Draw(renderer, in centerOfMassTransform, scale, color, useMaterialColors, drawWireframe);
///
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 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 SaveBinaryState(StreamOut stream) => ((Shape)this).SaveBinaryState(stream);
///
public NativeArray SaveMaterialState() => ((Shape)this).SaveMaterialState();
///
public unsafe void RestoreMaterialState(ReadOnlySpan materials) =>
((Shape)this).RestoreMaterialState(materials);
///
public Shape.Stats GetStats() => ((Shape)this).GetStats();
///
public float GetVolume() => ((Shape)this).GetVolume();
///
///
/// When MeshShape::mPerTriangleUserData is true, this function can be used to retrieve the user data that
/// was stored in the mesh shape.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:162
///
/// uint32 GetTriangleUserData(const SubShapeID &inSubShapeID) const
///
///
public uint GetTriangleUserData(uint subShapeID) =>
Jolt.PInvoke.MeshShape_GetTriangleUserData(this, subShapeID);
///
///
/// Register shape functions with the registry
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:171
///
/// static void sRegister()
///
///
public static void Register() => Jolt.PInvoke.MeshShape_Register();
///
///
/// Settings
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:166
///
/// static bool sDrawTriangleGroups
///
///
public static bool GetDrawTriangleGroups() => Jolt.PInvoke.MeshShape_GetDrawTriangleGroups();
///
///
/// Settings
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:166
///
/// static bool sDrawTriangleGroups
///
///
public static void SetDrawTriangleGroups(bool value) => Jolt.PInvoke.MeshShape_SetDrawTriangleGroups(value);
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:167
///
/// static bool sDrawTriangleOutlines
///
///
public static bool GetDrawTriangleOutlines() => Jolt.PInvoke.MeshShape_GetDrawTriangleOutlines();
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:167
///
/// static bool sDrawTriangleOutlines
///
///
public static void SetDrawTriangleOutlines(bool value) => Jolt.PInvoke.MeshShape_SetDrawTriangleOutlines(value);
public void AddRef() => ((Shape)this).AddRef();
public void Release() => ((Shape)this).Release();
public uint GetRefCount() => ((Shape)this).GetRefCount();
public static implicit operator Shape(MeshShape value) => Unsafe.BitCast(value);
public void Dispose()
{
if (IsNull())
return;
Release();
}
///
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 float3 GetCenterOfMass() => ((Shape)this).GetCenterOfMass();
///
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 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 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);
}
}