brutal/Brutal.Jolt/Generated/Jolt.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

1276 lines
59 KiB
C#

// <auto-generated/>
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
public static partial class Jolt
{
/// <summary>
/// <para>
/// Register platform default allocation / free functions
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/Memory.h#L35">Jolt/Core/Memory.h:35</see>
/// <br/>
/// <c>void RegisterDefaultAllocator()</c>
/// </para>
/// </summary>
public static void RegisterDefaultAllocator() => Jolt.PInvoke.RegisterDefaultAllocator();
/// <summary>
/// <para>
/// Implements the FNV-1a hash algorithm
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/HashCombine.h#L15">Jolt/Core/HashCombine.h:15</see>
/// <br/>
/// <c>inline uint64 HashBytes(const void *inData, uint inSize, uint64 inSeed = 0xcbf29ce484222325UL)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Implements the FNV-1a hash algorithm
/// @see https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
/// @param inData Data block of bytes
/// @param inSize Number of bytes
/// @param inSeed Seed of the hash (can be used to pass in the hash of a previous operation, otherwise leave default)
/// @return Hash
/// </code>
/// </remarks>
public static unsafe ulong HashBytes(Ptr data, ByteSize size, ulong seed) =>
Jolt.PInvoke.HashBytes(data, (uint)size, seed);
/// <summary>
/// <para>
/// Calculate the FNV-1a hash of inString.
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/HashCombine.h#L28">Jolt/Core/HashCombine.h:28</see>
/// <br/>
/// <c>constexpr uint64 HashString(const char *inString, uint64 inSeed = 0xcbf29ce484222325UL)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Calculate the FNV-1a hash of inString.
/// @see https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
/// </code>
/// </remarks>
public static unsafe ulong HashString(RefString8 @string, ulong seed)
{
fixed (byte* @string_fixed = @string)
{
return Jolt.PInvoke.HashString(@string_fixed, seed);
}
}
/// <summary>
/// <para>
/// A 64 bit hash function by Thomas Wang, Jan 1997 See:
/// http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/HashCombine.h#L43">Jolt/Core/HashCombine.h:43</see>
/// <br/>
/// <c>inline uint64 Hash64(uint64 inValue)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// A 64 bit hash function by Thomas Wang, Jan 1997
/// See: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
/// @param inValue Value to hash
/// @return Hash
/// </code>
/// </remarks>
public static ulong Hash64(ulong value) => Jolt.PInvoke.Hash64(value);
/// <summary>
/// <para>
/// Convert a value from degrees to radians
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L16">Jolt/Math/Math.h:16</see>
/// <br/>
/// <c>constexpr float DegreesToRadians(float inV)</c>
/// </para>
/// </summary>
public static float DegreesToRadians(float v) => Jolt.PInvoke.DegreesToRadians(v);
/// <summary>
/// <para>
/// Convert a value from radians to degrees
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L22">Jolt/Math/Math.h:22</see>
/// <br/>
/// <c>constexpr float RadiansToDegrees(float inV)</c>
/// </para>
/// </summary>
public static float RadiansToDegrees(float v) => Jolt.PInvoke.RadiansToDegrees(v);
/// <summary>
/// <para>
/// Convert angle in radians to the range \f$[-\pi, \pi]\f$
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L28">Jolt/Math/Math.h:28</see>
/// <br/>
/// <c>inline float CenterAngleAroundZero(float inV)</c>
/// </para>
/// </summary>
public static float CenterAngleAroundZero(float v) => Jolt.PInvoke.CenterAngleAroundZero(v);
/// <summary>
/// <para>
/// Calculates inA * inB - inC * inD with higher accuracy when fused multiply add instructions are
/// available. If inA * inB and inC * inD are large, the subtraction can cause a large loss of precision
/// when the result is small. See: https://pharr.org/matt/blog/2019/11/03/difference-of-floats (or search
/// for Kahan's algorithm)
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L49">Jolt/Math/Math.h:49</see>
/// <br/>
/// <c>float DifferenceOfProducts(float inA, float inB, float inC, float inD)</c>
/// </para>
/// </summary>
public static float DifferenceOfProducts(float a, float b, float c, float d) =>
Jolt.PInvoke.DifferenceOfProducts(a, b, c, d);
/// <summary>
/// <para>
/// Take the square root of a float value
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L76">Jolt/Math/Math.h:76</see>
/// <br/>
/// <c>float Sqrt(float inV)</c>
/// </para>
/// </summary>
public static float Sqrt(float v) => Jolt.PInvoke.Sqrt(v);
/// <summary>
/// <para>
/// Take the square root of a double value
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L92">Jolt/Math/Math.h:92</see>
/// <br/>
/// <c>double Sqrt(double inV)</c>
/// </para>
/// </summary>
public static double Sqrt(double v) => Jolt.PInvoke.Sqrt_2(v);
/// <summary>
/// <para>
/// Compute number of trailing zero bits (how many low bits are zero)
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L145">Jolt/Math/Math.h:145</see>
/// <br/>
/// <c>inline uint CountTrailingZeros(uint32 inValue)</c>
/// </para>
/// </summary>
public static uint CountTrailingZeros(uint value) => Jolt.PInvoke.CountTrailingZeros(value);
/// <summary>
/// <para>
/// Compute the number of leading zero bits (how many high bits are zero)
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L181">Jolt/Math/Math.h:181</see>
/// <br/>
/// <c>inline uint CountLeadingZeros(uint32 inValue)</c>
/// </para>
/// </summary>
public static uint CountLeadingZeros(uint value) => Jolt.PInvoke.CountLeadingZeros(value);
/// <summary>
/// <para>
/// Count the number of 1 bits in a value
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L211">Jolt/Math/Math.h:211</see>
/// <br/>
/// <c>inline uint CountBits(uint32 inValue)</c>
/// </para>
/// </summary>
public static uint CountBits(uint value) => Jolt.PInvoke.CountBits(value);
/// <summary>
/// <para>
/// Get the next higher power of 2 of a value, or the value itself if the value is already a power of 2
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Math.h#L232">Jolt/Math/Math.h:232</see>
/// <br/>
/// <c>inline uint32 GetNextPowerOf2(uint32 inValue)</c>
/// </para>
/// </summary>
public static uint GetNextPowerOf2(uint value) => Jolt.PInvoke.GetNextPowerOf2(value);
/// <summary>
/// <para>
/// Sine of x (input in radians)
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L12">Jolt/Math/Trigonometry.h:12</see>
/// <br/>
/// <c>float Sin(float inX)</c>
/// </para>
/// </summary>
public static float Sin(float x) => Jolt.PInvoke.Sin(x);
/// <summary>
/// <para>
/// Cosine of x (input in radians)
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L20">Jolt/Math/Trigonometry.h:20</see>
/// <br/>
/// <c>float Cos(float inX)</c>
/// </para>
/// </summary>
public static float Cos(float x) => Jolt.PInvoke.Cos(x);
/// <summary>
/// <para>
/// Tangent of x (input in radians)
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L28">Jolt/Math/Trigonometry.h:28</see>
/// <br/>
/// <c>float Tan(float inX)</c>
/// </para>
/// </summary>
public static float Tan(float x) => Jolt.PInvoke.Tan(x);
/// <summary>
/// <para>
/// Arc sine of x (returns value in the range [-PI / 2, PI / 2]) Note that all input values will be clamped
/// to the range [-1, 1] and this function will not return NaNs like std::asin
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L35">Jolt/Math/Trigonometry.h:35</see>
/// <br/>
/// <c>float ASin(float inX)</c>
/// </para>
/// </summary>
public static float ASin(float x) => Jolt.PInvoke.ASin(x);
/// <summary>
/// <para>
/// Arc cosine of x (returns value in the range [0, PI]) Note that all input values will be clamped to the
/// range [-1, 1] and this function will not return NaNs like std::acos
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L42">Jolt/Math/Trigonometry.h:42</see>
/// <br/>
/// <c>float ACos(float inX)</c>
/// </para>
/// </summary>
public static float ACos(float x) => Jolt.PInvoke.ACos(x);
/// <summary>
/// <para>
/// An approximation of ACos, max error is 4.2e-3 over the entire range [-1, 1], is approximately 2.5x
/// faster than ACos
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L48">Jolt/Math/Trigonometry.h:48</see>
/// <br/>
/// <c>float ACosApproximate(float inX)</c>
/// </para>
/// </summary>
public static float ACosApproximate(float x) => Jolt.PInvoke.ACosApproximate(x);
/// <summary>
/// <para>
/// Arc tangent of x (returns value in the range [-PI / 2, PI / 2])
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L68">Jolt/Math/Trigonometry.h:68</see>
/// <br/>
/// <c>float ATan(float inX)</c>
/// </para>
/// </summary>
public static float ATan(float x) => Jolt.PInvoke.ATan(x);
/// <summary>
/// <para>
/// Arc tangent of y / x using the signs of the arguments to determine the correct quadrant (returns value
/// in the range [-PI, PI])
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Math/Trigonometry.h#L74">Jolt/Math/Trigonometry.h:74</see>
/// <br/>
/// <c>float ATan2(float inY, float inX)</c>
/// </para>
/// </summary>
public static float ATan2(float y, float x) => Jolt.PInvoke.ATan2(y, x);
/// <summary>
/// <para>
/// Intersect ray with triangle, returns closest point or FLT_MAX if no hit (branch less version) Adapted
/// from: http://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayTriangle.h#L11">Jolt/Geometry/RayTriangle.h:11</see>
/// <br/>
/// <c>float RayTriangle(Vec3Arg inOrigin, Vec3Arg inDirection, Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2)</c>
/// </para>
/// </summary>
public static float RayTriangle(float3 origin, float3 direction, float3 v0, float3 v1, float3 v2) =>
Jolt.PInvoke.RayTriangle(origin, direction, v0, v1, v2);
/// <summary>
/// <para>
/// Intersect ray with 4 triangles in SOA format, returns 4 vector of closest points or FLT_MAX if no hit
/// (uses bit tricks to do less divisions)
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayTriangle.h#L76">Jolt/Geometry/RayTriangle.h:76</see>
/// <br/>
/// <c>Vec4 RayTriangle4(Vec3Arg inOrigin, Vec3Arg inDirection, Vec4Arg inV0X, Vec4Arg inV0Y, Vec4Arg inV0Z, Vec4Arg inV1X, Vec4Arg inV1Y, Vec4Arg inV1Z, Vec4Arg inV2X, Vec4Arg inV2Y, Vec4Arg inV2Z)</c>
/// </para>
/// </summary>
public static float4 RayTriangle4(
float3 origin,
float3 direction,
float4 v0x,
float4 v0y,
float4 v0z,
float4 v1x,
float4 v1y,
float4 v1z,
float4 v2x,
float4 v2y,
float4 v2z
) => Jolt.PInvoke.RayTriangle4(origin, direction, v0x, v0y, v0z, v1x, v1y, v1z, v2x, v2y, v2z);
/// <summary>
/// <para>
/// Construct a string that lists the most important configuration settings
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/ConfigurationString.h#L10">Jolt/ConfigurationString.h:10</see>
/// <br/>
/// <c>inline const char *GetConfigurationString()</c>
/// </para>
/// </summary>
public static unsafe RefString8 GetConfigurationString() => (Ptr<byte>)Jolt.PInvoke.GetConfigurationString();
/// <summary>
/// <para>
/// Functionality to get the processors cycle counter
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/TickCounter.h#L28">Jolt/Core/TickCounter.h:28</see>
/// <br/>
/// <c>uint64 GetProcessorTickCount()</c>
/// </para>
/// </summary>
public static ulong GetProcessorTickCount() => Jolt.PInvoke.GetProcessorTickCount();
/// <summary>
/// <para>
/// Convert a string to lower case
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/StringTools.h#L33">Jolt/Core/StringTools.h:33</see>
/// <br/>
/// <c>String ToLower(const string_view &amp;inString)</c>
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The text is copied into a managed string; the native buffer behind it is reused by the next
/// string-returning call on this thread.
/// </para>
/// </remarks>
public static unsafe string ToLower(RefString8 @string)
{
fixed (byte* @string_fixed = @string)
{
return Marshal.PtrToStringUTF8(Jolt.PInvoke.ToLower(@string_fixed)) ?? string.Empty;
}
}
/// <summary>
/// <para>
/// Converts the lower 4 bits of inNibble to a string that represents the number in binary format
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/StringTools.h#L36">Jolt/Core/StringTools.h:36</see>
/// <br/>
/// <c>const char *NibbleToBinary(uint32 inNibble)</c>
/// </para>
/// </summary>
public static unsafe RefString8 NibbleToBinary(uint nibble) => (Ptr<byte>)Jolt.PInvoke.NibbleToBinary(nibble);
/// <summary>
/// <para>
/// Helper functions that process 4 axis aligned boxes at the same time using SIMD Test if 4 bounding boxes
/// overlap with 1 bounding box, splat 1 box
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L13">Jolt/Geometry/AABox4.h:13</see>
/// <br/>
/// <c>UVec4 AABox4VsBox(const AABox &amp;inBox1, Vec4Arg inBox2MinX, Vec4Arg inBox2MinY, Vec4Arg inBox2MinZ, Vec4Arg inBox2MaxX, Vec4Arg inBox2MaxY, Vec4Arg inBox2MaxZ)</c>
/// </para>
/// </summary>
public static uint4 AABox4VsBox(
in AABox box1,
float4 box2MinX,
float4 box2MinY,
float4 box2MinZ,
float4 box2MaxX,
float4 box2MaxY,
float4 box2MaxZ
) => Jolt.PInvoke.AABox4VsBox(in box1, box2MinX, box2MinY, box2MinZ, box2MaxX, box2MaxY, box2MaxZ);
/// <summary>
/// <para>
/// Test if 4 bounding boxes overlap with an oriented box
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L88">Jolt/Geometry/AABox4.h:88</see>
/// <br/>
/// <c>UVec4 AABox4VsBox(Mat44Arg inOrientation, Vec3Arg inHalfExtents, Vec4Arg inBoxMinX, Vec4Arg inBoxMinY, Vec4Arg inBoxMinZ, Vec4Arg inBoxMaxX, Vec4Arg inBoxMaxY, Vec4Arg inBoxMaxZ, float inEpsilon = 1.0e-6f)</c>
/// </para>
/// </summary>
public static uint4 AABox4VsBox(
in float4x4 orientation,
float3 halfExtents,
float4 boxMinX,
float4 boxMinY,
float4 boxMinZ,
float4 boxMaxX,
float4 boxMaxY,
float4 boxMaxZ,
float epsilon = 1E-06f
) =>
Jolt.PInvoke.AABox4VsBox_2(
in orientation,
halfExtents,
boxMinX,
boxMinY,
boxMinZ,
boxMaxX,
boxMaxY,
boxMaxZ,
epsilon
);
/// <summary>
/// <para>
/// Convenience function that tests 4 AABoxes vs OrientedBox
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L187">Jolt/Geometry/AABox4.h:187</see>
/// <br/>
/// <c>UVec4 AABox4VsBox(const OrientedBox &amp;inBox, Vec4Arg inBoxMinX, Vec4Arg inBoxMinY, Vec4Arg inBoxMinZ, Vec4Arg inBoxMaxX, Vec4Arg inBoxMaxY, Vec4Arg inBoxMaxZ, float inEpsilon = 1.0e-6f)</c>
/// </para>
/// </summary>
public static uint4 AABox4VsBox(
OrientedBox box,
float4 boxMinX,
float4 boxMinY,
float4 boxMinZ,
float4 boxMaxX,
float4 boxMaxY,
float4 boxMaxZ,
float epsilon = 1E-06f
) => Jolt.PInvoke.AABox4VsBox_3(box, boxMinX, boxMinY, boxMinZ, boxMaxX, boxMaxY, boxMaxZ, epsilon);
/// <summary>
/// <para>
/// Test if 4 bounding boxes overlap with a point
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L71">Jolt/Geometry/AABox4.h:71</see>
/// <br/>
/// <c>UVec4 AABox4VsPoint(Vec3Arg inPoint, Vec4Arg inBoxMinX, Vec4Arg inBoxMinY, Vec4Arg inBoxMinZ, Vec4Arg inBoxMaxX, Vec4Arg inBoxMaxY, Vec4Arg inBoxMaxZ)</c>
/// </para>
/// </summary>
public static uint4 AABox4VsPoint(
float3 point,
float4 boxMinX,
float4 boxMinY,
float4 boxMinZ,
float4 boxMaxX,
float4 boxMaxY,
float4 boxMaxZ
) => Jolt.PInvoke.AABox4VsPoint(point, boxMinX, boxMinY, boxMinZ, boxMaxX, boxMaxY, boxMaxZ);
/// <summary>
/// <para>
/// Get the squared distance between 4 AABoxes and a point
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L193">Jolt/Geometry/AABox4.h:193</see>
/// <br/>
/// <c>Vec4 AABox4DistanceSqToPoint(Vec4Arg inPointX, Vec4Arg inPointY, Vec4Arg inPointZ, Vec4Arg inBoxMinX, Vec4Arg inBoxMinY, Vec4Arg inBoxMinZ, Vec4Arg inBoxMaxX, Vec4Arg inBoxMaxY, Vec4Arg inBoxMaxZ)</c>
/// </para>
/// </summary>
public static float4 AABox4DistanceSqToPoint(
float4 pointX,
float4 pointY,
float4 pointZ,
float4 boxMinX,
float4 boxMinY,
float4 boxMinZ,
float4 boxMaxX,
float4 boxMaxY,
float4 boxMaxZ
) =>
Jolt.PInvoke.AABox4DistanceSqToPoint(
pointX,
pointY,
pointZ,
boxMinX,
boxMinY,
boxMinZ,
boxMaxX,
boxMaxY,
boxMaxZ
);
/// <summary>
/// <para>
/// Get the squared distance between 4 AABoxes and a point
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L205">Jolt/Geometry/AABox4.h:205</see>
/// <br/>
/// <c>Vec4 AABox4DistanceSqToPoint(Vec3 inPoint, Vec4Arg inBoxMinX, Vec4Arg inBoxMinY, Vec4Arg inBoxMinZ, Vec4Arg inBoxMaxX, Vec4Arg inBoxMaxY, Vec4Arg inBoxMaxZ)</c>
/// </para>
/// </summary>
public static float4 AABox4DistanceSqToPoint(
float3 point,
float4 boxMinX,
float4 boxMinY,
float4 boxMinZ,
float4 boxMaxX,
float4 boxMaxY,
float4 boxMaxZ
) => Jolt.PInvoke.AABox4DistanceSqToPoint_2(point, boxMinX, boxMinY, boxMinZ, boxMaxX, boxMaxY, boxMaxZ);
/// <summary>
/// <para>
/// Test 4 AABoxes vs a sphere
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L211">Jolt/Geometry/AABox4.h:211</see>
/// <br/>
/// <c>UVec4 AABox4VsSphere(Vec4Arg inCenterX, Vec4Arg inCenterY, Vec4Arg inCenterZ, Vec4Arg inRadiusSq, Vec4Arg inBoxMinX, Vec4Arg inBoxMinY, Vec4Arg inBoxMinZ, Vec4Arg inBoxMaxX, Vec4Arg inBoxMaxY, Vec4Arg inBoxMaxZ)</c>
/// </para>
/// </summary>
public static uint4 AABox4VsSphere(
float4 centerX,
float4 centerY,
float4 centerZ,
float4 radiusSq,
float4 boxMinX,
float4 boxMinY,
float4 boxMinZ,
float4 boxMaxX,
float4 boxMaxY,
float4 boxMaxZ
) =>
Jolt.PInvoke.AABox4VsSphere(
centerX,
centerY,
centerZ,
radiusSq,
boxMinX,
boxMinY,
boxMinZ,
boxMaxX,
boxMaxY,
boxMaxZ
);
/// <summary>
/// <para>
/// Test 4 AABoxes vs a sphere
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/AABox4.h#L219">Jolt/Geometry/AABox4.h:219</see>
/// <br/>
/// <c>UVec4 AABox4VsSphere(Vec3Arg inCenter, float inRadiusSq, Vec4Arg inBoxMinX, Vec4Arg inBoxMinY, Vec4Arg inBoxMinZ, Vec4Arg inBoxMaxX, Vec4Arg inBoxMaxY, Vec4Arg inBoxMaxZ)</c>
/// </para>
/// </summary>
public static uint4 AABox4VsSphere(
float3 center,
float radiusSq,
float4 boxMinX,
float4 boxMinY,
float4 boxMinZ,
float4 boxMaxX,
float4 boxMaxY,
float4 boxMaxZ
) => Jolt.PInvoke.AABox4VsSphere_2(center, radiusSq, boxMinX, boxMinY, boxMinZ, boxMaxX, boxMaxY, boxMaxZ);
/// <summary>
/// <para>
/// Take a list of triangles and get the unique set of vertices and use them to create indexed triangles.
/// Vertices that are less than inVertexWeldDistance apart will be combined to a single vertex.
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/Indexify.h#L14">Jolt/Geometry/Indexify.h:14</see>
/// <br/>
/// <c>void Indexify(const TriangleList &amp;inTriangles, VertexList &amp;outVertices, IndexedTriangleList &amp;outTriangles, float inVertexWeldDistance = 1.0e-4f)</c>
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// inTriangles is copied into a native container for the call; the span is only read.
/// </para>
/// <para>
/// outVertices is an owned native buffer - read it through AsSpan() and Dispose it when you are done with
/// it.
/// </para>
/// <para>
/// outTriangles is an owned native buffer - read it through AsSpan() and Dispose it when you are done with
/// it.
/// </para>
/// </remarks>
public static unsafe void Indexify(
ReadOnlySpan<Triangle> inTriangles,
out NativeArray<float3> outVertices,
out NativeArray<IndexedTriangle> outTriangles,
float inVertexWeldDistance = 0.0001f
)
{
fixed (Triangle* inTriangles_fixed = inTriangles)
{
Jolt.PInvoke.Indexify(
inTriangles_fixed,
(nuint)inTriangles.Length,
out var outVertices_raw,
out var outTriangles_raw,
inVertexWeldDistance
);
outVertices = new NativeArray<float3>(outVertices_raw);
outTriangles = new NativeArray<IndexedTriangle>(outTriangles_raw);
}
}
/// <summary>
/// <para>
/// Take a list of indexed triangles and unpack them
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/Indexify.h#L17">Jolt/Geometry/Indexify.h:17</see>
/// <br/>
/// <c>void Deindexify(const VertexList &amp;inVertices, const IndexedTriangleList &amp;inTriangles, TriangleList &amp;outTriangles)</c>
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// inVertices is copied into a native container for the call; the span is only read.
/// </para>
/// <para>
/// inTriangles is copied into a native container for the call; the span is only read.
/// </para>
/// <para>
/// Returns an owned native buffer - read it through AsSpan() and Dispose it when you are done with it.
/// </para>
/// </remarks>
public static unsafe NativeArray<Triangle> Deindexify(
ReadOnlySpan<float3> inVertices,
ReadOnlySpan<IndexedTriangle> inTriangles
)
{
fixed (IndexedTriangle* inTriangles_fixed = inTriangles)
fixed (float3* inVertices_fixed = inVertices)
{
Jolt.PInvoke.Deindexify(
inVertices_fixed,
(nuint)inVertices.Length,
inTriangles_fixed,
(nuint)inTriangles.Length,
out var outTriangles_raw
);
return new NativeArray<Triangle>(outTriangles_raw);
}
}
/// <summary>
/// <para>
/// Intersect AABB with ray, returns minimal distance along ray or FLT_MAX if no hit Note: Can return
/// negative value if ray starts in box
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayAABox.h#L33">Jolt/Geometry/RayAABox.h:33</see>
/// <br/>
/// <c>float RayAABox(Vec3Arg inOrigin, const RayInvDirection &amp;inInvDirection, Vec3Arg inBoundsMin, Vec3Arg inBoundsMax)</c>
/// </para>
/// </summary>
public static float RayAABox(float3 origin, RayInvDirection invDirection, float3 boundsMin, float3 boundsMax) =>
Jolt.PInvoke.RayAABox(origin, invDirection, boundsMin, boundsMax);
/// <summary>
/// <para>
/// Intersect AABB with ray, returns minimal and maximal distance along ray or FLT_MAX, -FLT_MAX if no hit
/// Note: Can return negative value for outMin if ray starts in box
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayAABox.h#L136">Jolt/Geometry/RayAABox.h:136</see>
/// <br/>
/// <c>void RayAABox(Vec3Arg inOrigin, const RayInvDirection &amp;inInvDirection, Vec3Arg inBoundsMin, Vec3Arg inBoundsMax, float &amp;outMin, float &amp;outMax)</c>
/// </para>
/// </summary>
public static void RayAABox(
float3 origin,
RayInvDirection invDirection,
float3 boundsMin,
float3 boundsMax,
out float min,
out float max
) => Jolt.PInvoke.RayAABox_2(origin, invDirection, boundsMin, boundsMax, out min, out max);
/// <summary>
/// <para>
/// Intersect 4 AABBs with ray, returns minimal distance along ray or FLT_MAX if no hit Note: Can return
/// negative value if ray starts in box
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayAABox.h#L72">Jolt/Geometry/RayAABox.h:72</see>
/// <br/>
/// <c>Vec4 RayAABox4(Vec3Arg inOrigin, const RayInvDirection &amp;inInvDirection, Vec4Arg inBoundsMinX, Vec4Arg inBoundsMinY, Vec4Arg inBoundsMinZ, Vec4Arg inBoundsMaxX, Vec4Arg inBoundsMaxY, Vec4Arg inBoundsMaxZ)</c>
/// </para>
/// </summary>
public static float4 RayAABox4(
float3 origin,
RayInvDirection invDirection,
float4 boundsMinX,
float4 boundsMinY,
float4 boundsMinZ,
float4 boundsMaxX,
float4 boundsMaxY,
float4 boundsMaxZ
) =>
Jolt.PInvoke.RayAABox4(
origin,
invDirection,
boundsMinX,
boundsMinY,
boundsMinZ,
boundsMaxX,
boundsMaxY,
boundsMaxZ
);
/// <summary>
/// <para>
/// Intersect AABB with ray, returns true if there is a hit closer than inClosest
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayAABox.h#L175">Jolt/Geometry/RayAABox.h:175</see>
/// <br/>
/// <c>bool RayAABoxHits(Vec3Arg inOrigin, const RayInvDirection &amp;inInvDirection, Vec3Arg inBoundsMin, Vec3Arg inBoundsMax, float inClosest)</c>
/// </para>
/// </summary>
public static bool RayAABoxHits(
float3 origin,
RayInvDirection invDirection,
float3 boundsMin,
float3 boundsMax,
float closest
) => Jolt.PInvoke.RayAABoxHits(origin, invDirection, boundsMin, boundsMax, closest);
/// <summary>
/// <para>
/// Intersect AABB with ray without hit fraction, based on separating axis test
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayAABox.h#L216">Jolt/Geometry/RayAABox.h:216</see>
/// <br/>
/// <c>bool RayAABoxHits(Vec3Arg inOrigin, Vec3Arg inDirection, Vec3Arg inBoundsMin, Vec3Arg inBoundsMax)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Intersect AABB with ray without hit fraction, based on separating axis test
/// @see http://www.codercorner.com/RayAABB.cpp
/// </code>
/// </remarks>
public static bool RayAABoxHits(float3 origin, float3 direction, float3 boundsMin, float3 boundsMax) =>
Jolt.PInvoke.RayAABoxHits_2(origin, direction, boundsMin, boundsMax);
/// <summary>
/// <para>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against an infinite
/// cylinder centered along the Y axis
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayCylinder.h#L17">Jolt/Geometry/RayCylinder.h:17</see>
/// <br/>
/// <c>float RayCylinder(Vec3Arg inRayOrigin, Vec3Arg inRayDirection, float inCylinderRadius)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection
/// against an infinite cylinder centered along the Y axis
/// @return FLT_MAX if there is no intersection, otherwise the fraction along the ray.
/// @param inRayDirection Direction of the ray. Does not need to be normalized.
/// @param inRayOrigin Origin of the ray. If the ray starts inside the cylinder, the returned fraction will be 0.
/// @param inCylinderRadius Radius of the infinite cylinder
/// </code>
/// </remarks>
public static float RayCylinder(float3 rayOrigin, float3 rayDirection, float cylinderRadius) =>
Jolt.PInvoke.RayCylinder(rayOrigin, rayDirection, cylinderRadius);
/// <summary>
/// <para>
/// Test a ray against a cylinder centered around the origin with its axis along the Y axis and half height
/// specified.
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayCylinder.h#L57">Jolt/Geometry/RayCylinder.h:57</see>
/// <br/>
/// <c>float RayCylinder(Vec3Arg inRayOrigin, Vec3Arg inRayDirection, float inCylinderHalfHeight, float inCylinderRadius)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Test a ray against a cylinder centered around the origin with its axis along the Y axis and half height specified.
/// @return FLT_MAX if there is no intersection, otherwise the fraction along the ray.
/// @param inRayDirection Ray direction. Does not need to be normalized.
/// @param inRayOrigin Origin of the ray. If the ray starts inside the cylinder, the returned fraction will be 0.
/// @param inCylinderRadius Radius of the cylinder
/// @param inCylinderHalfHeight Distance from the origin to the top (or bottom) of the cylinder
/// </code>
/// </remarks>
public static float RayCylinder(
float3 rayOrigin,
float3 rayDirection,
float cylinderHalfHeight,
float cylinderRadius
) => Jolt.PInvoke.RayCylinder_2(rayOrigin, rayDirection, cylinderHalfHeight, cylinderRadius);
/// <summary>
/// <para>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against a sphere,
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RaySphere.h#L17">Jolt/Geometry/RaySphere.h:17</see>
/// <br/>
/// <c>float RaySphere(Vec3Arg inRayOrigin, Vec3Arg inRayDirection, Vec3Arg inSphereCenter, float inSphereRadius)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against a sphere,
/// @return FLT_MAX if there is no intersection, otherwise the fraction along the ray.
/// @param inRayOrigin Ray origin. If the ray starts inside the sphere, the returned fraction will be 0.
/// @param inRayDirection Ray direction. Does not need to be normalized.
/// @param inSphereCenter Position of the center of the sphere
/// @param inSphereRadius Radius of the sphere
/// </code>
/// </remarks>
public static float RaySphere(float3 rayOrigin, float3 rayDirection, float3 sphereCenter, float sphereRadius) =>
Jolt.PInvoke.RaySphere(rayOrigin, rayDirection, sphereCenter, sphereRadius);
/// <summary>
/// <para>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against a sphere. Outputs
/// entry and exit points (outMinFraction and outMaxFraction) along the ray (which could be negative if the
/// hit point is before the start of the ray).
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RaySphere.h#L54">Jolt/Geometry/RaySphere.h:54</see>
/// <br/>
/// <c>int RaySphere(Vec3Arg inRayOrigin, Vec3Arg inRayDirection, Vec3Arg inSphereCenter, float inSphereRadius, float &amp;outMinFraction, float &amp;outMaxFraction)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against a sphere.
/// Outputs entry and exit points (outMinFraction and outMaxFraction) along the ray (which could be negative if the hit point is before the start of the ray).
/// @param inRayOrigin Ray origin. If the ray starts inside the sphere, the returned fraction will be 0.
/// @param inRayDirection Ray direction. Does not need to be normalized.
/// @param inSphereCenter Position of the center of the sphere.
/// @param inSphereRadius Radius of the sphere.
/// @param outMinFraction Returned lowest intersection fraction
/// @param outMaxFraction Returned highest intersection fraction
/// @return The amount of intersections with the sphere.
/// If 1 intersection is returned outMinFraction will be equal to outMaxFraction
/// </code>
/// </remarks>
public static int RaySphere(
float3 rayOrigin,
float3 rayDirection,
float3 sphereCenter,
float sphereRadius,
out float minFraction,
out float maxFraction
) =>
Jolt.PInvoke.RaySphere_2(
rayOrigin,
rayDirection,
sphereCenter,
sphereRadius,
out minFraction,
out maxFraction
);
/// <summary>
/// <para>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against a capsule
/// centered around the origin with its axis along the Y axis and half height specified.
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Geometry/RayCapsule.h#L19">Jolt/Geometry/RayCapsule.h:19</see>
/// <br/>
/// <c>float RayCapsule(Vec3Arg inRayOrigin, Vec3Arg inRayDirection, float inCapsuleHalfHeight, float inCapsuleRadius)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection
/// against a capsule centered around the origin with its axis along the Y axis and half height specified.
/// @return FLT_MAX if there is no intersection, otherwise the fraction along the ray.
/// @param inRayDirection Ray direction. Does not need to be normalized.
/// @param inRayOrigin Origin of the ray. If the ray starts inside the capsule, the returned fraction will be 0.
/// @param inCapsuleHalfHeight Distance from the origin to the center of the top sphere (or that of the bottom)
/// @param inCapsuleRadius Radius of the top/bottom sphere
/// </code>
/// </remarks>
public static float RayCapsule(
float3 rayOrigin,
float3 rayDirection,
float capsuleHalfHeight,
float capsuleRadius
) => Jolt.PInvoke.RayCapsule(rayOrigin, rayDirection, capsuleHalfHeight, capsuleRadius);
/// <summary>
/// <para>
/// This function estimates the contact impulses and body velocity changes as a result of a collision. It
/// can be used in the ContactListener::OnContactAdded to determine the strength of the collision to e.g.
/// play a sound or trigger a particle system. This function is accurate when two bodies collide but will
/// not be accurate when more than 2 bodies collide at the same time as it does not know about these other
/// collisions.
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Collision/EstimateCollisionResponse.h#L42">Jolt/Physics/Collision/EstimateCollisionResponse.h:42</see>
/// <br/>
/// <c>void EstimateCollisionResponse(const Body &amp;inBody1, const Body &amp;inBody2, const ContactManifold &amp;inManifold, CollisionEstimationResult &amp;outResult, float inCombinedFriction, float inCombinedRestitution, float inMinVelocityForRestitution = 1.0f, uint inNumIterations = 10)</c>
/// </para>
/// </summary>
/// <remarks>
/// <code>
/// This function estimates the contact impulses and body velocity changes as a result of a collision.
/// It can be used in the ContactListener::OnContactAdded to determine the strength of the collision to e.g. play a sound or trigger a particle system.
/// This function is accurate when two bodies collide but will not be accurate when more than 2 bodies collide at the same time as it does not know about these other collisions.
///
/// @param inBody1 Colliding body 1
/// @param inBody2 Colliding body 2
/// @param inManifold The collision manifold
/// @param outResult A structure that contains the estimated contact and friction impulses and the resulting body velocities
/// @param inCombinedFriction The combined friction of body 1 and body 2 (see ContactSettings::mCombinedFriction)
/// @param inCombinedRestitution The combined restitution of body 1 and body 2 (see ContactSettings::mCombinedRestitution)
/// @param inMinVelocityForRestitution Minimal velocity required for restitution to be applied (see PhysicsSettings::mMinVelocityForRestitution)
/// @param inNumIterations Number of iterations to use for the impulse estimation (see PhysicsSettings::mNumVelocitySteps, note you can probably use a lower number for a decent estimate). If you set the number of iterations to 1 then no friction will be calculated.
/// </code>
/// </remarks>
public static void EstimateCollisionResponse(
Body body1,
Body body2,
in ContactManifold manifold,
ref CollisionEstimationResult result,
float combinedFriction,
float combinedRestitution,
float minVelocityForRestitution = 1f,
uint numIterations = 10
) =>
Jolt.PInvoke.EstimateCollisionResponse(
body1,
body2,
in manifold,
ref result,
combinedFriction,
combinedRestitution,
minVelocityForRestitution,
numIterations
);
/// <summary>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h#L20">Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h:20</see>
/// <br/>
/// <c>void PruneContactPoints(Vec3Arg inPenetrationAxis, ContactPoints &amp;ioContactPointsOn1, ContactPoints &amp;ioContactPointsOn2</c>
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// Throws ArgumentException for contactPointsOn1: "contactPointsOn1 must hold more than 4 points (at most
/// 64); with 4 or fewer there's nothing to prune." Throws ArgumentException for contactPointsOn2:
/// "contactPointsOn2 must hold as many points as contactPointsOn1."
/// </para>
/// </remarks>
public static void PruneContactPoints(
float3 penetrationAxis,
ref StaticArrayVec3_64 contactPointsOn1,
ref StaticArrayVec3_64 contactPointsOn2,
float3 centerOfMass
)
{
Jolt.PInvoke.PruneContactPoints(
penetrationAxis,
ref contactPointsOn1,
ref contactPointsOn2,
centerOfMass,
out var _bufferCheck
);
if (_bufferCheck == 1)
throw new ArgumentException(
"contactPointsOn1 must hold more than 4 points (at most 64); with 4 or fewer there's nothing to prune.",
nameof(contactPointsOn1)
);
if (_bufferCheck == 2)
throw new ArgumentException(
"contactPointsOn2 must hold as many points as contactPointsOn1.",
nameof(contactPointsOn2)
);
}
/// <summary>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h#L38">Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h:38</see>
/// <br/>
/// <c>void ManifoldBetweenTwoFaces(Vec3Arg inContactPoint1, Vec3Arg inContactPoint2, Vec3Arg inPenetrationAxis, float inMaxContactDistance, const ConvexShape::SupportingFace &amp;inShape1Face, const ConvexShape::SupportingFace &amp;inShape2Face, ContactPoints &amp;outContactPoints1, ContactPoints &amp;outContactPoints2</c>
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// shape1Face is copied into a fixed 32-element native container for the call; anything past that is
/// ignored.
/// </para>
/// <para>
/// shape2Face is copied into a fixed 32-element native container for the call; anything past that is
/// ignored.
/// </para>
/// </remarks>
public static unsafe void ManifoldBetweenTwoFaces(
float3 contactPoint1,
float3 contactPoint2,
float3 penetrationAxis,
float maxContactDistance,
ReadOnlySpan<float3> shape1Face,
ReadOnlySpan<float3> shape2Face,
out StaticArrayVec3_64 contactPoints1,
out StaticArrayVec3_64 contactPoints2,
float3 centerOfMass
)
{
fixed (float3* shape2Face_fixed = shape2Face)
fixed (float3* shape1Face_fixed = shape1Face)
{
Jolt.PInvoke.ManifoldBetweenTwoFaces(
contactPoint1,
contactPoint2,
penetrationAxis,
maxContactDistance,
shape1Face_fixed,
(nuint)shape1Face.Length,
shape2Face_fixed,
(nuint)shape2Face.Length,
out contactPoints1,
out contactPoints2,
centerOfMass
);
}
}
/// <summary>
/// <para>
/// Ability to check if position/velocity is enabled for a motor state
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/MotorSettings.h#L25">Jolt/Physics/Constraints/MotorSettings.h:25</see>
/// <br/>
/// <c>constexpr bool IsVelocityMotor(EMotorState inMotorState) { return (int(inMotorState) &amp; int(EMotorState::Velocity)) != 0; }</c>
/// </para>
/// </summary>
public static bool IsVelocityMotor(MotorState motorState) => Jolt.PInvoke.IsVelocityMotor(motorState);
/// <summary>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Constraints/MotorSettings.h#L26">Jolt/Physics/Constraints/MotorSettings.h:26</see>
/// <br/>
/// <c>constexpr bool IsPositionMotor(EMotorState inMotorState) { return (int(inMotorState) &amp; int(EMotorState::Position)) != 0; }</c>
/// </para>
/// </summary>
public static bool IsPositionMotor(MotorState motorState) => Jolt.PInvoke.IsPositionMotor(motorState);
/// <summary>
/// <para>
/// Internal helper function
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/RegisterTypes.h#L10">Jolt/RegisterTypes.h:10</see>
/// <br/>
/// <c>extern bool VerifyJoltVersionIDInternal(uint64 inVersionID)</c>
/// </para>
/// </summary>
public static bool VerifyJoltVersionIDInternal(ulong versionID) =>
Jolt.PInvoke.VerifyJoltVersionIDInternal(versionID);
/// <summary>
/// <para>
/// This function can be used to verify the library ABI is compatible with your application. Use it in this
/// way: `assert(VerifyJoltVersionID());`. Returns `false` if the library used is not compatible with your
/// app.
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/RegisterTypes.h#L16">Jolt/RegisterTypes.h:16</see>
/// <br/>
/// <c>bool VerifyJoltVersionID()</c>
/// </para>
/// </summary>
public static bool VerifyJoltVersionID() => Jolt.PInvoke.VerifyJoltVersionID();
/// <summary>
/// <para>
/// Internal helper function
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/RegisterTypes.h#L19">Jolt/RegisterTypes.h:19</see>
/// <br/>
/// <c>extern void RegisterTypesInternal(uint64 inVersionID)</c>
/// </para>
/// </summary>
public static void RegisterTypesInternal(ulong versionID) => Jolt.PInvoke.RegisterTypesInternal(versionID);
/// <summary>
/// <para>
/// Register all physics types with the factory and install their collision handlers with the
/// CollisionDispatch class. If you have your own custom shape types you probably need to register their
/// handlers with the CollisionDispatch before calling this function. If you implement your own default
/// material (PhysicsMaterial::sDefault) make sure to initialize it before this function or else this
/// function will create one for you.
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/RegisterTypes.h#L24">Jolt/RegisterTypes.h:24</see>
/// <br/>
/// <c>void RegisterTypes()</c>
/// </para>
/// </summary>
public static void RegisterTypes() => Jolt.PInvoke.RegisterTypes();
/// <summary>
/// <para>
/// Unregisters all types with the factory and cleans up the default material
/// </para>
/// <para>
/// C++:
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/RegisterTypes.h#L27">Jolt/RegisterTypes.h:27</see>
/// <br/>
/// <c>extern void UnregisterTypes()</c>
/// </para>
/// </summary>
public static void UnregisterTypes() => Jolt.PInvoke.UnregisterTypes();
/// <summary>
/// <para>
/// The error message from the most recent failed Result-returning call on this thread, the text the
/// throwing wrappers (ShapeSettings.CreateShape and friends) report.
/// </para>
/// </summary>
public static string GetLastError() => Marshal.PtrToStringUTF8(Jolt.PInvoke.GetLastError()) ?? string.Empty;
/// <summary>
/// <para>
/// Installs the function Jolt calls when one of its asserts fails, and returns whether the loaded natives
/// have asserts at all - only Debug natives, or ones built with JOLT_DEBUG, do. The handler gets the failed
/// expression, an optional message (may be null), and the file and line as UTF-8 C strings; returning true
/// breaks into the debugger, false carries on as a release build would. It runs on whichever thread
/// asserted, Jolt's workers included, so it must be a static method marked [UnmanagedCallersOnly(CallConvs
/// = [typeof(CallConvCdecl)])] and must not throw. Pass null to put back Jolt's default, which breaks. Jolt
/// reads the hook unsynchronised, so set it while no physics update is running.
/// </para>
/// </summary>
public static unsafe bool SetAssertHandler(
delegate* unmanaged[Cdecl]<byte*, byte*, byte*, uint, Brutal.Bool8> handler
) => Jolt.PInvoke.SetAssertHandler(handler);
/// <summary>
/// <para>
/// Installs the function Jolt's log messages go to, as a formatted UTF-8 C string (at most 1023 bytes). It
/// runs on whichever thread logged, Jolt's workers included, so it must be a static method marked
/// [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])], thread-safe, and must not throw. Pass null
/// to drop the messages. Either way Jolt's own default, which asserts, is replaced - so natives built with
/// asserts don't treat a log line as a failure. Call it before the first physics update: swapping handlers
/// later is safe, but the first call installs Jolt's trace hook, which Jolt itself only expects to change
/// while nothing is running.
/// </para>
/// </summary>
public static unsafe void SetTraceHandler(delegate* unmanaged[Cdecl]<byte*, void> handler) =>
Jolt.PInvoke.SetTraceHandler(handler);
}
}