//
// 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
{
///
///
/// Class that constructs a MeshShape
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:22
///
/// class MeshShapeSettings final : public ShapeSettings
///
///
[InteropHandle]
public readonly partial struct MeshShapeSettings : IDisposable
{
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:71
///
/// enum class EBuildQuality
///
///
public enum BuildQuality : int
{
///
///
/// Favor runtime performance, takes more time to build the MeshShape but performs better
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:73
///
/// FavorRuntimePerformance
///
///
FavorRuntimePerformance,
///
///
/// Favor build speed, build the tree faster but the MeshShape will be slower
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:74
///
/// FavorBuildSpeed
///
///
FavorBuildSpeed,
}
///
///
/// Create a mesh shape.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:31
///
/// explicit MeshShapeSettings(const TriangleList &inTriangles, PhysicsMaterialList inMaterials = PhysicsMaterialList())
///
///
///
///
/// triangles is copied into a native container for the call; the span is only read.
///
///
/// materials is copied into a native container for the call; the span is only read.
///
///
public static unsafe MeshShapeSettings Create(
ReadOnlySpan triangles,
ReadOnlySpan materials
)
{
fixed (PhysicsMaterial* materials_fixed = materials)
fixed (Triangle* triangles_fixed = triangles)
{
return Jolt.PInvoke.MeshShapeSettings_Create(
triangles_fixed,
(nuint)triangles.Length,
materials_fixed,
(nuint)materials.Length
);
}
}
///
///
/// Default constructor for deserialization
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:28
///
/// MeshShapeSettings() = default
///
///
public static MeshShapeSettings Create() => Jolt.PInvoke.MeshShapeSettings_Create_2();
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:32
///
/// MeshShapeSettings(VertexList inVertices, IndexedTriangleList inTriangles, PhysicsMaterialList inMaterials = PhysicsMaterialList())
///
///
///
///
/// vertices is copied into a native container for the call; the span is only read.
///
///
/// triangles is copied into a native container for the call; the span is only read.
///
///
/// materials is copied into a native container for the call; the span is only read.
///
///
public static unsafe MeshShapeSettings Create(
ReadOnlySpan vertices,
ReadOnlySpan triangles,
ReadOnlySpan materials
)
{
fixed (PhysicsMaterial* materials_fixed = materials)
fixed (IndexedTriangle* triangles_fixed = triangles)
fixed (float3* vertices_fixed = vertices)
{
return Jolt.PInvoke.MeshShapeSettings_Create_3(
vertices_fixed,
(nuint)vertices.Length,
triangles_fixed,
(nuint)triangles.Length,
materials_fixed,
(nuint)materials.Length
);
}
}
///
public RTTI GetRTTI() => ((ShapeSettings)this).GetRTTI();
///
public unsafe Ptr CastTo(RTTI rtti) => ((ShapeSettings)this).CastTo(rtti);
///
///
/// Sanitize the mesh data. Remove duplicate and degenerate triangles. This is called automatically when
/// constructing the MeshShapeSettings with a list of (indexed-) triangles.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:35
///
/// void Sanitize()
///
///
public void Sanitize() => Jolt.PInvoke.MeshShapeSettings_Sanitize(this);
///
public Shape CreateShape() => ((ShapeSettings)this).CreateShape();
///
///
/// Vertices belonging to mIndexedTriangles
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:41
///
/// VertexList mTriangleVertices
///
///
///
///
/// The span is a view of the container's own storage, not a copy: edits land in the object that owns it.
/// It's only valid until that container is resized or its owner is destroyed.
///
///
[return: Brutal.Attributes.Fixed]
public unsafe Span GetTriangleVertices()
{
Jolt.PInvoke.MeshShapeSettings_GetTriangleVertices(this, out var _outResult);
return new Span((void*)_outResult.Data, checked((int)_outResult.Count));
}
///
///
/// Vertices belonging to mIndexedTriangles
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:41
///
/// VertexList mTriangleVertices
///
///
public unsafe void SetTriangleVertices(ReadOnlySpan value)
{
fixed (float3* value_fixed = value)
{
Jolt.PInvoke.MeshShapeSettings_SetTriangleVertices(this, value_fixed, (nuint)value.Length);
}
}
///
///
/// Original list of indexed triangles (triangles will be reordered internally in the mesh shape). Triangles
/// must be provided in counter clockwise order. Degenerate triangles will automatically be removed during
/// mesh creation but no other mesh simplifications are performed, use an external library if this is
/// desired. For simulation, the triangles are considered to be single sided. For ray casts you can choose
/// to make triangles double sided by setting RayCastSettings::mBackFaceMode to
/// EBackFaceMode::CollideWithBackFaces. For collide shape tests you can use
/// CollideShapeSettings::mBackFaceMode and for shape casts you can use
/// ShapeCastSettings::mBackFaceModeTriangles.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:49
///
/// IndexedTriangleList mIndexedTriangles
///
///
///
///
/// The span is a view of the container's own storage, not a copy: edits land in the object that owns it.
/// It's only valid until that container is resized or its owner is destroyed.
///
///
[return: Brutal.Attributes.Fixed]
public unsafe Span GetIndexedTriangles()
{
Jolt.PInvoke.MeshShapeSettings_GetIndexedTriangles(this, out var _outResult);
return new Span((void*)_outResult.Data, checked((int)_outResult.Count));
}
///
///
/// Original list of indexed triangles (triangles will be reordered internally in the mesh shape). Triangles
/// must be provided in counter clockwise order. Degenerate triangles will automatically be removed during
/// mesh creation but no other mesh simplifications are performed, use an external library if this is
/// desired. For simulation, the triangles are considered to be single sided. For ray casts you can choose
/// to make triangles double sided by setting RayCastSettings::mBackFaceMode to
/// EBackFaceMode::CollideWithBackFaces. For collide shape tests you can use
/// CollideShapeSettings::mBackFaceMode and for shape casts you can use
/// ShapeCastSettings::mBackFaceModeTriangles.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:49
///
/// IndexedTriangleList mIndexedTriangles
///
///
public unsafe void SetIndexedTriangles(ReadOnlySpan value)
{
fixed (IndexedTriangle* value_fixed = value)
{
Jolt.PInvoke.MeshShapeSettings_SetIndexedTriangles(this, value_fixed, (nuint)value.Length);
}
}
///
///
/// Materials assigned to the triangles. Each triangle specifies which material it uses through its
/// mMaterialIndex
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:52
///
/// PhysicsMaterialList mMaterials
///
///
///
///
/// 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 GetMaterials() =>
new NativeArray(Jolt.PInvoke.MeshShapeSettings_GetMaterials(this));
///
///
/// Materials assigned to the triangles. Each triangle specifies which material it uses through its
/// mMaterialIndex
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:52
///
/// PhysicsMaterialList mMaterials
///
///
public unsafe void SetMaterials(ReadOnlySpan value)
{
fixed (PhysicsMaterial* value_fixed = value)
{
Jolt.PInvoke.MeshShapeSettings_SetMaterials(this, value_fixed, (nuint)value.Length);
}
}
///
///
/// Maximum number of triangles in each leaf of the axis aligned box tree. This is a balance between memory
/// and performance. Can be in the range [1, MeshShape::MaxTrianglesPerLeaf]. Sensible values are between 4
/// (for better performance) and 8 (for less memory usage).
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:56
///
/// uint mMaxTrianglesPerLeaf = 8
///
///
public uint GetMaxTrianglesPerLeaf() => Jolt.PInvoke.MeshShapeSettings_GetMaxTrianglesPerLeaf(this);
///
///
/// Maximum number of triangles in each leaf of the axis aligned box tree. This is a balance between memory
/// and performance. Can be in the range [1, MeshShape::MaxTrianglesPerLeaf]. Sensible values are between 4
/// (for better performance) and 8 (for less memory usage).
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:56
///
/// uint mMaxTrianglesPerLeaf = 8
///
///
public void SetMaxTrianglesPerLeaf(uint value) =>
Jolt.PInvoke.MeshShapeSettings_SetMaxTrianglesPerLeaf(this, value);
///
///
/// cos(5 degrees)
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:63
///
/// float mActiveEdgeCosThresholdAngle = 0.996195f
///
///
///
///
/// Cosine of the threshold angle (if the angle between the two triangles is bigger than this, the edge is active, note that a concave edge is always inactive).
/// Setting this value too small can cause ghost collisions with edges, setting it too big can cause depenetration artifacts (objects not depenetrating quickly).
/// Valid ranges are between cos(0 degrees) and cos(90 degrees). The default value is cos(5 degrees).
/// Negative values will make all edges active and causes EActiveEdgeMode::CollideOnlyWithActive to behave as EActiveEdgeMode::CollideWithAll.
/// This speeds up the build process but will require all bodies that can interact with the mesh to use BodyCreationSettings::mEnhancedInternalEdgeRemoval = true.
///
///
public float GetActiveEdgeCosThresholdAngle() =>
Jolt.PInvoke.MeshShapeSettings_GetActiveEdgeCosThresholdAngle(this);
///
///
/// cos(5 degrees)
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:63
///
/// float mActiveEdgeCosThresholdAngle = 0.996195f
///
///
///
///
/// Cosine of the threshold angle (if the angle between the two triangles is bigger than this, the edge is active, note that a concave edge is always inactive).
/// Setting this value too small can cause ghost collisions with edges, setting it too big can cause depenetration artifacts (objects not depenetrating quickly).
/// Valid ranges are between cos(0 degrees) and cos(90 degrees). The default value is cos(5 degrees).
/// Negative values will make all edges active and causes EActiveEdgeMode::CollideOnlyWithActive to behave as EActiveEdgeMode::CollideWithAll.
/// This speeds up the build process but will require all bodies that can interact with the mesh to use BodyCreationSettings::mEnhancedInternalEdgeRemoval = true.
///
///
public void SetActiveEdgeCosThresholdAngle(float value) =>
Jolt.PInvoke.MeshShapeSettings_SetActiveEdgeCosThresholdAngle(this, value);
///
///
/// When true, we store the user data coming from Triangle::mUserData or IndexedTriangle::mUserData in the
/// mesh shape. This can be used to store additional data like the original index of the triangle in the
/// mesh. Can be retrieved using MeshShape::GetTriangleUserData. Turning this on increases the memory used
/// by the MeshShape by roughly 25%.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:69
///
/// bool mPerTriangleUserData = false
///
///
public bool GetPerTriangleUserData() => Jolt.PInvoke.MeshShapeSettings_GetPerTriangleUserData(this);
///
///
/// When true, we store the user data coming from Triangle::mUserData or IndexedTriangle::mUserData in the
/// mesh shape. This can be used to store additional data like the original index of the triangle in the
/// mesh. Can be retrieved using MeshShape::GetTriangleUserData. Turning this on increases the memory used
/// by the MeshShape by roughly 25%.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:69
///
/// bool mPerTriangleUserData = false
///
///
public void SetPerTriangleUserData(bool value) =>
Jolt.PInvoke.MeshShapeSettings_SetPerTriangleUserData(this, value);
///
///
/// Determines the quality of the tree building process.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:78
///
/// EBuildQuality mBuildQuality = EBuildQuality::FavorRuntimePerformance
///
///
public MeshShapeSettings.BuildQuality GetBuildQuality() => Jolt.PInvoke.MeshShapeSettings_GetBuildQuality(this);
///
///
/// Determines the quality of the tree building process.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/MeshShape.h:78
///
/// EBuildQuality mBuildQuality = EBuildQuality::FavorRuntimePerformance
///
///
public void SetBuildQuality(MeshShapeSettings.BuildQuality value) =>
Jolt.PInvoke.MeshShapeSettings_SetBuildQuality(this, value);
public void AddRef() => ((ShapeSettings)this).AddRef();
public void Release() => ((ShapeSettings)this).Release();
public uint GetRefCount() => ((ShapeSettings)this).GetRefCount();
public static implicit operator ShapeSettings(MeshShapeSettings value) =>
Unsafe.BitCast(value);
public void Dispose()
{
if (IsNull())
return;
Release();
}
///
public void ClearCachedResult() => ((ShapeSettings)this).ClearCachedResult();
///
public ulong GetUserData() => ((ShapeSettings)this).GetUserData();
///
public void SetUserData(ulong value) => ((ShapeSettings)this).SetUserData(value);
}
}