//
// 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
{
///
///
/// Base class for a compound shape
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:52
///
/// class CompoundShape : public Shape
///
///
[InteropHandle]
public readonly partial struct CompoundShape : IDisposable
{
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:141
///
/// struct SubShape
///
///
[StructLayout(LayoutKind.Explicit, Size = 40)]
public partial struct SubShape
{
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:238
///
/// RefConst<Shape> mShape
///
///
[FieldOffset(0)]
public Shape Shape;
///
///
/// Note: Position of center of mass of sub shape!
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:239
///
/// Float3 mPositionCOM
///
///
[FieldOffset(8)]
public float3 PositionCOM;
///
///
/// Note: X, Y, Z of rotation quaternion - note we read 4 bytes beyond this so make sure there's
/// something there
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:240
///
/// Float3 mRotation
///
///
[FieldOffset(20)]
public float3 Rotation;
///
///
/// User data value (put here because it falls in padding bytes)
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:241
///
/// uint32 mUserData
///
///
[FieldOffset(32)]
public uint UserData;
///
///
/// If mRotation is close to identity (put here because it falls in padding bytes)
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:242
///
/// bool mIsRotationIdentity
///
///
[FieldOffset(36)]
public Brutal.Bool8 IsRotationIdentity;
}
///
public float3 GetCenterOfMass() => ((Shape)this).GetCenterOfMass();
///
public bool MustBeStatic() => ((Shape)this).MustBeStatic();
///
public AABox GetLocalBounds() => ((Shape)this).GetLocalBounds();
///
public uint GetSubShapeIDBitsRecursive() => ((Shape)this).GetSubShapeIDBitsRecursive();
///
public AABox GetWorldSpaceBounds(in float4x4 centerOfMassTransform, float3 scale) =>
((Shape)this).GetWorldSpaceBounds(in centerOfMassTransform, scale);
///
public float GetInnerRadius() => ((Shape)this).GetInnerRadius();
///
public MassProperties GetMassProperties() => ((Shape)this).GetMassProperties();
///
public PhysicsMaterial GetMaterial(uint subShapeID) => ((Shape)this).GetMaterial(subShapeID);
///
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 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);
///
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 void CollideSoftBodyVertices(
in float4x4 centerOfMassTransform,
float3 scale,
CollideSoftBodyVertexIterator vertices,
uint numVertices,
int collidingShapeIndex
) =>
((Shape)this).CollideSoftBodyVertices(
in centerOfMassTransform,
scale,
vertices,
numVertices,
collidingShapeIndex
);
///
public NativeHandleArray TransformShape(in float4x4 centerOfMassTransform) =>
((Shape)this).TransformShape(in centerOfMassTransform);
///
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);
///
///
/// Get which sub shape's bounding boxes overlap with an axis aligned box
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:132
///
/// virtual int GetIntersectingSubShapes(const AABox &inBox, uint *outSubShapeIndices, int inMaxSubShapeIndices) const = 0
///
///
///
///
/// Get which sub shape's bounding boxes overlap with an axis aligned box
/// @param inBox The axis aligned box to test against (relative to the center of mass of this shape)
/// @param outSubShapeIndices Buffer where to place the indices of the sub shapes that intersect
/// @param inMaxSubShapeIndices How many indices will fit in the buffer (normally you'd provide a buffer of GetNumSubShapes() indices)
/// @return How many indices were placed in outSubShapeIndices
///
///
/// subShapeIndices is the buffer the native call works on, and its element count travels with it: the call
/// may write through the span, and only for the duration of the call.
///
///
public unsafe int GetIntersectingSubShapes(in AABox box, Span subShapeIndices)
{
fixed (uint* subShapeIndices_fixed = subShapeIndices)
{
return Jolt.PInvoke.CompoundShape_GetIntersectingSubShapes(
this,
in box,
subShapeIndices_fixed,
(int)subShapeIndices.Length
);
}
}
///
///
/// Get which sub shape's bounding boxes overlap with an axis aligned box
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:139
///
/// virtual int GetIntersectingSubShapes(const OrientedBox &inBox, uint *outSubShapeIndices, int inMaxSubShapeIndices) const = 0
///
///
///
///
/// Get which sub shape's bounding boxes overlap with an axis aligned box
/// @param inBox The axis aligned box to test against (relative to the center of mass of this shape)
/// @param outSubShapeIndices Buffer where to place the indices of the sub shapes that intersect
/// @param inMaxSubShapeIndices How many indices will fit in the buffer (normally you'd provide a buffer of GetNumSubShapes() indices)
/// @return How many indices were placed in outSubShapeIndices
///
///
/// subShapeIndices is the buffer the native call works on, and its element count travels with it: the call
/// may write through the span, and only for the duration of the call.
///
///
public unsafe int GetIntersectingSubShapes(OrientedBox box, Span subShapeIndices)
{
fixed (uint* subShapeIndices_fixed = subShapeIndices)
{
return Jolt.PInvoke.CompoundShape_GetIntersectingSubShapes_2(
this,
box,
subShapeIndices_fixed,
(int)subShapeIndices.Length
);
}
}
///
///
/// Access to the sub shapes of this compound
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:251
///
/// const SubShapes & GetSubShapes() 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 GetSubShapes()
{
Jolt.PInvoke.CompoundShape_GetSubShapes(this, out var _outResult);
return new ReadOnlySpan((void*)_outResult.Data, checked((int)_outResult.Count));
}
///
///
/// Get the total number of sub shapes
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:254
///
/// uint GetNumSubShapes() const
///
///
public uint GetNumSubShapes() => Jolt.PInvoke.CompoundShape_GetNumSubShapes(this);
///
///
/// Access to a particular sub shape
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:257
///
/// const SubShape & GetSubShape(uint inIdx) const
///
///
///
///
/// The returned struct's handle fields are borrowed from the object it came from: don't Dispose them, and
/// don't read them after the owner is gone.
///
///
public CompoundShape.SubShape GetSubShape(uint idx)
{
Jolt.PInvoke.CompoundShape_GetSubShape(this, idx, out var _inRange, out var _outResult);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(idx),
idx,
"Expected an index below the number of sub shapes."
);
return _outResult;
}
///
///
/// Get the user data associated with a shape in this compound
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:260
///
/// uint32 GetCompoundUserData(uint inIdx) const
///
///
public uint GetCompoundUserData(uint idx)
{
var _result = Jolt.PInvoke.CompoundShape_GetCompoundUserData(this, idx, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(idx),
idx,
"Expected an index below the number of sub shapes."
);
return _result;
}
///
///
/// Set the user data associated with a shape in this compound
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:263
///
/// void SetCompoundUserData(uint inIdx, uint32 inUserData)
///
///
public void SetCompoundUserData(uint idx, uint userData)
{
Jolt.PInvoke.CompoundShape_SetCompoundUserData(this, idx, userData, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(idx),
idx,
"Expected an index below the number of sub shapes."
);
}
///
///
/// Check if a sub shape ID is still valid for this shape
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:268
///
/// inline bool IsSubShapeIDValid(SubShapeID inSubShapeID) const
///
///
///
///
/// Check if a sub shape ID is still valid for this shape
/// @param inSubShapeID Sub shape id that indicates the leaf shape relative to this shape
/// @return True if the ID is valid, false if not
///
///
public bool IsSubShapeIDValid(uint subShapeID) =>
Jolt.PInvoke.CompoundShape_IsSubShapeIDValid(this, subShapeID);
///
///
/// Convert SubShapeID to sub shape index
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:278
///
/// inline uint32 GetSubShapeIndexFromID(SubShapeID inSubShapeID, SubShapeID &outRemainder) const
///
///
///
///
/// Convert SubShapeID to sub shape index
/// @param inSubShapeID Sub shape id that indicates the leaf shape relative to this shape
/// @param outRemainder This is the sub shape ID for the sub shape of the compound after popping off the index
/// @return The index of the sub shape of this compound
///
///
public uint GetSubShapeIndexFromID(uint subShapeID, out uint remainder) =>
Jolt.PInvoke.CompoundShape_GetSubShapeIndexFromID(this, subShapeID, out remainder);
///
///
/// Convert a sub shape index to a sub shape ID
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:289
///
/// inline SubShapeIDCreator GetSubShapeIDFromIndex(int inIdx, const SubShapeIDCreator &inParentSubShapeID) const
///
///
///
///
/// @brief Convert a sub shape index to a sub shape ID
/// @param inIdx Index of the sub shape of this compound
/// @param inParentSubShapeID Parent SubShapeID (describing the path to the compound shape)
/// @return A sub shape ID creator that contains the full path to the sub shape with index inIdx
///
///
/// The returned handle is an owned copy; Dispose it when you're done with it.
///
///
public SubShapeIDCreator GetSubShapeIDFromIndex(int idx, SubShapeIDCreator parentSubShapeID)
{
var _result = Jolt.PInvoke.CompoundShape_GetSubShapeIDFromIndex(
this,
idx,
parentSubShapeID,
out var _inRange
);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(idx),
idx,
"Expected an index below the number of sub shapes."
);
return _result;
}
///
public void SaveBinaryState(StreamOut stream) => ((Shape)this).SaveBinaryState(stream);
///
public NativeArray SaveSubShapeState() => ((Shape)this).SaveSubShapeState();
///
public unsafe void RestoreSubShapeState(ReadOnlySpan subShapes) =>
((Shape)this).RestoreSubShapeState(subShapes);
///
public float GetVolume() => ((Shape)this).GetVolume();
///
public bool IsValidScale(float3 scale) => ((Shape)this).IsValidScale(scale);
///
public float3 MakeScaleValid(float3 scale) => ((Shape)this).MakeScaleValid(scale);
///
///
/// Register shape functions with the registry
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/CompoundShape.h:312
///
/// static void sRegister()
///
///
public static void Register() => Jolt.PInvoke.CompoundShape_Register();
public void AddRef() => ((Shape)this).AddRef();
public void Release() => ((Shape)this).Release();
public uint GetRefCount() => ((Shape)this).GetRefCount();
public static implicit operator Shape(CompoundShape 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 AABox GetWorldSpaceBounds(in double4x4 centerOfMassTransform, float3 scale) =>
((Shape)this).GetWorldSpaceBounds(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 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 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 void SaveWithChildren(StreamOut stream, ShapeToIDMap shapeMap, MaterialToIDMap materialMap) =>
((Shape)this).SaveWithChildren(stream, shapeMap, materialMap);
///
public Shape.Stats GetStats() => ((Shape)this).GetStats();
}
}