//
// 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
{
///
///
/// Keeps track of connected bodies and builds islands for multithreaded velocity/position update
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:18
///
/// class IslandBuilder : public NonCopyable
///
///
[InteropHandle]
public readonly partial struct IslandBuilder : IDisposable
{
public static IslandBuilder Create() => Jolt.PInvoke.IslandBuilder_Create();
///
///
/// Initialize the island builder with the maximum amount of bodies that could be active
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:25
///
/// void Init(uint32 inMaxActiveBodies)
///
///
public void Init(uint maxActiveBodies) => Jolt.PInvoke.IslandBuilder_Init(this, maxActiveBodies);
///
///
/// Prepare for simulation step by allocating space for the contact constraints
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:28
///
/// void PrepareContactConstraints(uint32 inMaxContactConstraints, TempAllocator *inTempAllocator)
///
///
public void PrepareContactConstraints(uint maxContactConstraints, TempAllocator tempAllocator) =>
Jolt.PInvoke.IslandBuilder_PrepareContactConstraints(this, maxContactConstraints, tempAllocator);
///
///
/// Prepare for simulation step by allocating space for the non-contact constraints
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:31
///
/// void PrepareNonContactConstraints(uint32 inNumConstraints, TempAllocator *inTempAllocator)
///
///
public void PrepareNonContactConstraints(uint numConstraints, TempAllocator tempAllocator) =>
Jolt.PInvoke.IslandBuilder_PrepareNonContactConstraints(this, numConstraints, tempAllocator);
///
///
/// Link two bodies by their index in the BodyManager::mActiveBodies list to form islands
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:34
///
/// void LinkBodies(uint32 inFirst, uint32 inSecond)
///
///
public void LinkBodies(uint first, uint second) => Jolt.PInvoke.IslandBuilder_LinkBodies(this, first, second);
///
///
/// Link a constraint to a body by their index in the BodyManager::mActiveBodies
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:37
///
/// void LinkConstraint(uint32 inConstraintIndex, uint32 inIndexInActiveBodyList)
///
///
public void LinkConstraint(uint constraintIndex, uint indexInActiveBodyList) =>
Jolt.PInvoke.IslandBuilder_LinkConstraint(this, constraintIndex, indexInActiveBodyList);
///
///
/// Link a contact to a body by their index in the BodyManager::mActiveBodies
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:40
///
/// void LinkContact(uint32 inContactIndex, uint32 inIndexInActiveBodyList)
///
///
public void LinkContact(uint contactIndex, uint indexInActiveBodyList) =>
Jolt.PInvoke.IslandBuilder_LinkContact(this, contactIndex, indexInActiveBodyList);
///
///
/// Finalize the islands after all bodies have been Link()-ed
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:43
///
/// void Finalize(const BodyID *inActiveBodies, uint32 inNumActiveBodies, uint32 inNumContacts, TempAllocator *inTempAllocator)
///
///
///
///
/// activeBodies is the buffer the native call reads, and its element count travels with it: the span is
/// only read, and it is only read for the duration of the call.
///
///
public unsafe void Complete(ReadOnlySpan activeBodies, uint numContacts, TempAllocator tempAllocator)
{
fixed (uint* activeBodies_fixed = activeBodies)
{
Jolt.PInvoke.IslandBuilder_Complete(
this,
activeBodies_fixed,
(uint)activeBodies.Length,
numContacts,
tempAllocator
);
}
}
///
///
/// Get the amount of islands formed
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:46
///
/// uint32 GetNumIslands() const
///
///
public uint GetNumIslands() => Jolt.PInvoke.IslandBuilder_GetNumIslands(this);
///
///
/// The number of position iterations for each island
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:54
///
/// void SetNumPositionSteps(uint32 inIslandIndex, uint inNumPositionSteps)
///
///
public void SetNumPositionSteps(uint islandIndex, uint numPositionSteps)
{
Jolt.PInvoke.IslandBuilder_SetNumPositionSteps(this, islandIndex, numPositionSteps, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(islandIndex),
islandIndex,
"Expected an index below the number of islands."
);
}
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:55
///
/// uint GetNumPositionSteps(uint32 inIslandIndex) const
///
///
public uint GetNumPositionSteps(uint islandIndex)
{
var _result = Jolt.PInvoke.IslandBuilder_GetNumPositionSteps(this, islandIndex, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(islandIndex),
islandIndex,
"Expected an index below the number of islands."
);
return _result;
}
///
///
/// After you're done calling the three functions above, call this function to free associated data
///
///
/// C++:
/// Jolt/Physics/IslandBuilder.h:73
///
/// void ResetIslands(TempAllocator *inTempAllocator)
///
///
public void ResetIslands(TempAllocator tempAllocator) =>
Jolt.PInvoke.IslandBuilder_ResetIslands(this, tempAllocator);
public void Dispose() => Jolt.PInvoke.IslandBuilder_Destroy(this);
}
}