//
// 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 height field shape. Cannot be used as a dynamic object.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:118
///
/// class HeightFieldShape final : public Shape
///
///
///
///
/// A height field shape. Cannot be used as a dynamic object.
///
/// Note: If you're using HeightFieldShape and are querying data while modifying the shape you'll have a race condition.
/// In this case it is best to create a new HeightFieldShape using the Clone function. You replace the shape on a body using BodyInterface::SetShape.
/// If a query is still working on the old shape, it will have taken a reference and keep the old shape alive until the query finishes.
///
///
[InteropHandle]
public readonly partial struct HeightFieldShape : IDisposable
{
///
///
/// A block of 2x2 ranges used to form a hierarchical grid, ordered left top, right top, left bottom, right
/// bottom
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:340
///
/// struct alignas(16) RangeBlock
///
///
[StructLayout(LayoutKind.Explicit, Size = 16)]
public partial struct RangeBlock
{
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:342
///
/// uint16 mMin[4]
///
///
[FieldOffset(0)]
public ushort_4 Min;
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:343
///
/// uint16 mMax[4]
///
///
[FieldOffset(8)]
public ushort_4 Max;
}
///
///
/// Constructor
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:124
///
/// HeightFieldShape()
///
///
public static HeightFieldShape Create() => Jolt.PInvoke.HeightFieldShape_Create();
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:125
///
/// HeightFieldShape(const HeightFieldShapeSettings &inSettings, ShapeResult &outResult)
///
///
public static HeightFieldShape Create(HeightFieldShapeSettings settings)
{
var _handle = Jolt.PInvoke.HeightFieldShape_Create_2(settings);
if (_handle.IsNull())
throw JoltException.FromLastError();
return _handle;
}
///
///
/// Clone this shape. Can be used to avoid race conditions. See the documentation of this class for more
/// information.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:129
///
/// Ref<HeightFieldShape> Clone() const
///
///
///
///
/// The returned handle carries its own reference; Dispose it once when you're done.
///
///
public HeightFieldShape Clone() => Jolt.PInvoke.HeightFieldShape_Clone(this);
///
public bool MustBeStatic() => ((Shape)this).MustBeStatic();
///
///
/// Get the size of the height field. Note that this will always be rounded up to the nearest multiple of
/// GetBlockSize().
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:135
///
/// inline uint GetSampleCount() const
///
///
public uint GetSampleCount() => Jolt.PInvoke.HeightFieldShape_GetSampleCount(this);
///
///
/// Get the size of a block
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:138
///
/// inline uint GetBlockSize() const
///
///
public uint GetBlockSize() => Jolt.PInvoke.HeightFieldShape_GetBlockSize(this);
///
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);
///
///
/// Overload to get the material at a particular location
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:156
///
/// const PhysicsMaterial * GetMaterial(uint inX, uint inY) const
///
///
///
///
/// The returned handle carries its own reference; Dispose it once when you're done.
///
///
public PhysicsMaterial GetMaterial(uint x, uint y) => Jolt.PInvoke.HeightFieldShape_GetMaterial(this, x, y);
///
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 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);
///
///
/// Get height field position at sampled location (inX, inY). where inX and inY are integers in the range
/// inX e [0, mSampleCount - 1] and inY e [0, mSampleCount - 1].
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:190
///
/// Vec3 GetPosition(uint inX, uint inY) const
///
///
public float3 GetPosition(uint x, uint y) => Jolt.PInvoke.HeightFieldShape_GetPosition(this, x, y);
///
///
/// Check if height field at sampled location (inX, inY) has collision (has a hole or not)
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:193
///
/// bool IsNoCollision(uint inX, uint inY) const
///
///
public bool IsNoCollision(uint x, uint y) => Jolt.PInvoke.HeightFieldShape_IsNoCollision(this, x, y);
///
///
/// Projects inLocalPosition (a point in the space of the shape) along the Y axis onto the surface and
/// returns it in outSurfacePosition. When there is no surface position (because of a hole or because the
/// point is outside the heightfield) the function will return false.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:197
///
/// bool ProjectOntoSurface(Vec3Arg inLocalPosition, Vec3 &outSurfacePosition, SubShapeID &outSubShapeID) const
///
///
public bool ProjectOntoSurface(float3 localPosition, out float3 surfacePosition, out uint subShapeID) =>
Jolt.PInvoke.HeightFieldShape_ProjectOntoSurface(this, localPosition, out surfacePosition, out subShapeID);
///
///
/// Returns the coordinates of the triangle that a sub shape ID represents
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:204
///
/// void GetSubShapeCoordinates(const SubShapeID &inSubShapeID, uint &outX, uint &outY, uint &outTriangleIndex) const
///
///
///
///
/// Returns the coordinates of the triangle that a sub shape ID represents
/// @param inSubShapeID The sub shape ID to decode
/// @param outX X coordinate of the triangle (in the range [0, mSampleCount - 2])
/// @param outY Y coordinate of the triangle (in the range [0, mSampleCount - 2])
/// @param outTriangleIndex Triangle within the quad (0 = lower triangle or 1 = upper triangle)
///
///
public void GetSubShapeCoordinates(uint subShapeID, out uint x, out uint y, out uint triangleIndex) =>
Jolt.PInvoke.HeightFieldShape_GetSubShapeCoordinates(this, subShapeID, out x, out y, out triangleIndex);
///
///
/// Get the range of height values that this height field can encode. Can be used to determine the allowed
/// range when setting the height values with SetHeights.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:207
///
/// float GetMinHeightValue() const
///
///
public float GetMinHeightValue() => Jolt.PInvoke.HeightFieldShape_GetMinHeightValue(this);
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:208
///
/// float GetMaxHeightValue() const
///
///
public float GetMaxHeightValue() => Jolt.PInvoke.HeightFieldShape_GetMaxHeightValue(this);
///
///
/// Get the height values of a block of data. Note that the height values are decompressed so will be
/// slightly different from what the shape was originally created with.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:218
///
/// void GetHeights(uint inX, uint inY, uint inSizeX, uint inSizeY, float *outHeights, intptr_t inHeightsStride) const
///
///
///
///
/// Get the height values of a block of data.
/// Note that the height values are decompressed so will be slightly different from what the shape was originally created with.
/// @param inX Start X position, must be a multiple of mBlockSize and in the range [0, mSampleCount - 1]
/// @param inY Start Y position, must be a multiple of mBlockSize and in the range [0, mSampleCount - 1]
/// @param inSizeX Number of samples in X direction, must be a multiple of mBlockSize and in the range [0, mSampleCount - inX]
/// @param inSizeY Number of samples in Y direction, must be a multiple of mBlockSize and in the range [0, mSampleCount - inY]
/// @param outHeights Returned height values, must be at least inSizeX * inSizeY floats. Values are returned in x-major order and can be cNoCollisionValue.
/// @param inHeightsStride Stride in floats between two consecutive rows of outHeights (can be negative if the data is upside down).
///
///
public unsafe void GetHeights(uint x, uint y, uint sizeX, uint sizeY, Ptr heights, long heightsStride) =>
Jolt.PInvoke.HeightFieldShape_GetHeights(this, x, y, sizeX, sizeY, heights, heightsStride);
///
///
/// Set the height values of a block of data. Note that this requires decompressing and recompressing a
/// border of size mBlockSize in the negative x/y direction so will cause some precision loss. Beware this
/// can create a race condition if you're running collision queries in parallel. See class documentation for
/// more information.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:231
///
/// void SetHeights(uint inX, uint inY, uint inSizeX, uint inSizeY, const float *inHeights, intptr_t inHeightsStride, TempAllocator &inAllocator, float inActiveEdgeCosThresholdAngle = 0.996195f)
///
///
///
///
/// Set the height values of a block of data.
/// Note that this requires decompressing and recompressing a border of size mBlockSize in the negative x/y direction so will cause some precision loss.
/// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
/// @param inX Start X position, must be a multiple of mBlockSize and in the range [0, mSampleCount - 1]
/// @param inY Start Y position, must be a multiple of mBlockSize and in the range [0, mSampleCount - 1]
/// @param inSizeX Number of samples in X direction, must be a multiple of mBlockSize and in the range [0, mSampleCount - inX]
/// @param inSizeY Number of samples in Y direction, must be a multiple of mBlockSize and in the range [0, mSampleCount - inY]
/// @param inHeights The new height values to set, must be an array of inSizeX * inSizeY floats, can be cNoCollisionValue. Values outside of the range [GetMinHeightValue(), GetMaxHeightValue()] will be clamped.
/// @param inHeightsStride Stride in floats between two consecutive rows of inHeights (can be negative if the data is upside down).
/// @param inAllocator Allocator to use for temporary memory
/// @param inActiveEdgeCosThresholdAngle 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).
///
///
public unsafe void SetHeights(
uint x,
uint y,
uint sizeX,
uint sizeY,
Ptr heights,
long heightsStride,
TempAllocator allocator,
float activeEdgeCosThresholdAngle = 0.996195f
) =>
Jolt.PInvoke.HeightFieldShape_SetHeights(
this,
x,
y,
sizeX,
sizeY,
heights,
heightsStride,
allocator,
activeEdgeCosThresholdAngle
);
///
///
/// Get the current list of materials, the indices returned by GetMaterials() will index into this list.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:234
///
/// 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.HeightFieldShape_GetMaterialList(this));
///
///
/// Get the material indices of a block of data.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:243
///
/// void GetMaterials(uint inX, uint inY, uint inSizeX, uint inSizeY, uint8 *outMaterials, intptr_t inMaterialsStride) const
///
///
///
///
/// Get the material indices of a block of data.
/// @param inX Start X position, must in the range [0, mSampleCount - 1]
/// @param inY Start Y position, must in the range [0, mSampleCount - 1]
/// @param inSizeX Number of samples in X direction
/// @param inSizeY Number of samples in Y direction
/// @param outMaterials Returned material indices, must be at least inSizeX * inSizeY uint8s. Values are returned in x-major order.
/// @param inMaterialsStride Stride in uint8s between two consecutive rows of outMaterials (can be negative if the data is upside down).
///
///
public unsafe void GetMaterials(
uint x,
uint y,
uint sizeX,
uint sizeY,
Ptr materials,
long materialsStride
) => Jolt.PInvoke.HeightFieldShape_GetMaterials(this, x, y, sizeX, sizeY, materials, materialsStride);
///
///
/// Set the material indices of a block of data. Beware this can create a race condition if you're running
/// collision queries in parallel. See class documentation for more information.
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:256
///
/// bool SetMaterials(uint inX, uint inY, uint inSizeX, uint inSizeY, const uint8 *inMaterials, intptr_t inMaterialsStride, const PhysicsMaterialList *inMaterialList, TempAllocator &inAllocator)
///
///
///
///
/// Set the material indices of a block of data.
/// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
/// @param inX Start X position, must in the range [0, mSampleCount - 1]
/// @param inY Start Y position, must in the range [0, mSampleCount - 1]
/// @param inSizeX Number of samples in X direction
/// @param inSizeY Number of samples in Y direction
/// @param inMaterials The new material indices, must be at least inSizeX * inSizeY uint8s. Values are returned in x-major order.
/// @param inMaterialsStride Stride in uint8s between two consecutive rows of inMaterials (can be negative if the data is upside down).
/// @param inMaterialList The material list to use for the new material indices or nullptr if the material list should not be updated
/// @param inAllocator Allocator to use for temporary memory
/// @return True if the material indices were set, false if the total number of materials exceeded 256
///
///
/// An empty materialList passes nullptr, which the callee reads as not given; otherwise it is copied into a
/// native container for the call.
///
///
public unsafe bool SetMaterials(
uint x,
uint y,
uint sizeX,
uint sizeY,
Ptr materials,
long materialsStride,
ReadOnlySpan materialList,
TempAllocator allocator
)
{
fixed (PhysicsMaterial* materialList_fixed = materialList)
{
return Jolt.PInvoke.HeightFieldShape_SetMaterials(
this,
x,
y,
sizeX,
sizeY,
materials,
materialsStride,
materialList_fixed,
(nuint)materialList.Length,
allocator
);
}
}
///
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();
///
///
/// Register shape functions with the registry
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:275
///
/// static void sRegister()
///
///
public static void Register() => Jolt.PInvoke.HeightFieldShape_Register();
///
///
/// Settings
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:271
///
/// static bool sDrawTriangleOutlines
///
///
public static bool GetDrawTriangleOutlines() => Jolt.PInvoke.HeightFieldShape_GetDrawTriangleOutlines();
///
///
/// Settings
///
///
/// C++:
/// Jolt/Physics/Collision/Shape/HeightFieldShape.h:271
///
/// static bool sDrawTriangleOutlines
///
///
public static void SetDrawTriangleOutlines(bool value) =>
Jolt.PInvoke.HeightFieldShape_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(HeightFieldShape 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);
}
}