//
// 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
{
///
///
/// Assigns bodies in large islands to multiple groups that can run in parallel
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:26
///
/// class LargeIslandSplitter : public NonCopyable
///
///
///
///
/// Assigns bodies in large islands to multiple groups that can run in parallel
///
/// This basically implements what is described in: High-Performance Physical Simulations on Next-Generation Architecture with Many Cores by Chen et al.
/// See: http://web.eecs.umich.edu/~msmelyan/papers/physsim_onmanycore_itj.pdf section "PARALLELIZATION METHODOLOGY"
///
/// WARNING: This class is an internal part of PhysicsSystem, it has no functions that can be called by users of the library.
///
///
[InteropHandle]
public readonly partial struct LargeIslandSplitter : IDisposable
{
///
///
/// Status code for retrieving a batch
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:37
///
/// enum class EStatus
///
///
public enum Status : int
{
///
///
/// Work is expected to be available later
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:39
///
/// WaitingForBatch
///
///
WaitingForBatch,
///
///
/// Work is being returned
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:40
///
/// BatchRetrieved
///
///
BatchRetrieved,
///
///
/// No further work is expected from this
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:41
///
/// AllBatchesDone
///
///
AllBatchesDone,
}
///
///
/// Describes a split of constraints and contacts
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:45
///
/// struct Split
///
///
[StructLayout(LayoutKind.Explicit, Size = 16)]
public partial struct Split
{
///
///
/// Begin of the contact buffer (offset relative to mContactAndConstraintIndices)
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:51
///
/// uint32 mContactBufferBegin
///
///
[FieldOffset(0)]
public uint ContactBufferBegin;
///
///
/// End of the contact buffer
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:52
///
/// uint32 mContactBufferEnd
///
///
[FieldOffset(4)]
public uint ContactBufferEnd;
///
///
/// Begin of the constraint buffer (offset relative to mContactAndConstraintIndices)
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:54
///
/// uint32 mConstraintBufferBegin
///
///
[FieldOffset(8)]
public uint ConstraintBufferBegin;
///
///
/// End of the constraint buffer
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:55
///
/// uint32 mConstraintBufferEnd
///
///
[FieldOffset(12)]
public uint ConstraintBufferEnd;
}
public static LargeIslandSplitter Create() => Jolt.PInvoke.LargeIslandSplitter_Create();
///
///
/// Prepare the island splitter by allocating memory
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:139
///
/// void Prepare(const IslandBuilder &inIslandBuilder, uint32 inNumActiveBodies, TempAllocator *inTempAllocator)
///
///
public void Prepare(IslandBuilder islandBuilder, uint numActiveBodies, TempAllocator tempAllocator) =>
Jolt.PInvoke.LargeIslandSplitter_Prepare(this, islandBuilder, numActiveBodies, tempAllocator);
///
///
/// Assign two bodies to a split. Returns the split index.
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:142
///
/// uint AssignSplit(const Body *inBody1, const Body *inBody2)
///
///
public uint AssignSplit(Body body1, Body body2) =>
Jolt.PInvoke.LargeIslandSplitter_AssignSplit(this, body1, body2);
///
///
/// Force a body to be in a non parallel split. Returns the split index.
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:145
///
/// uint AssignToNonParallelSplit(const Body *inBody)
///
///
public uint AssignToNonParallelSplit(Body body) =>
Jolt.PInvoke.LargeIslandSplitter_AssignToNonParallelSplit(this, body);
///
///
/// Get the island index of the island that was split for a particular split island index
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:157
///
/// inline uint32 GetIslandIndex(uint inSplitIslandIndex) const
///
///
public uint GetIslandIndex(uint splitIslandIndex) =>
Jolt.PInvoke.LargeIslandSplitter_GetIslandIndex(this, splitIslandIndex);
///
///
/// Prepare the island splitter for iterating over the split islands again for position solving. Marks all
/// batches as startable.
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:164
///
/// void PrepareForSolvePositions()
///
///
public void PrepareForSolvePositions() => Jolt.PInvoke.LargeIslandSplitter_PrepareForSolvePositions(this);
///
///
/// Reset the island splitter
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:167
///
/// void Reset(TempAllocator *inTempAllocator)
///
///
public void Reset(TempAllocator tempAllocator) => Jolt.PInvoke.LargeIslandSplitter_Reset(this, tempAllocator);
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:32
///
/// static constexpr uint cNumSplits = sizeof(SplitMask) * 8
///
///
public static uint GetNumSplits() => Jolt.PInvoke.LargeIslandSplitter_GetNumSplits();
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:33
///
/// static constexpr uint cNonParallelSplitIdx = cNumSplits - 1
///
///
public static uint GetNonParallelSplitIdx() => Jolt.PInvoke.LargeIslandSplitter_GetNonParallelSplitIdx();
///
///
/// If the number of constraints + contacts in an island is larger than this, we will try to split the
/// island
///
///
/// C++:
/// Jolt/Physics/LargeIslandSplitter.h:34
///
/// static constexpr uint cLargeIslandTreshold = 128
///
///
public static uint GetLargeIslandTreshold() => Jolt.PInvoke.LargeIslandSplitter_GetLargeIslandTreshold();
public void Dispose() => Jolt.PInvoke.LargeIslandSplitter_Destroy(this);
}
}