Table of Contents

Class TypeProcessor<TBodyReferences, TPrestepData, TAccumulatedImpulse>

Namespace
BepuPhysics.Constraints
Assembly
BepuPhysics.dll
public abstract class TypeProcessor<TBodyReferences, TPrestepData, TAccumulatedImpulse> : TypeProcessor where TBodyReferences : unmanaged where TPrestepData : unmanaged where TAccumulatedImpulse : unmanaged

Type Parameters

TBodyReferences
TPrestepData
TAccumulatedImpulse
Inheritance
TypeProcessor<TBodyReferences, TPrestepData, TAccumulatedImpulse>
Derived
Inherited Members

Properties

InternalConstrainedDegreesOfFreedom

protected override int InternalConstrainedDegreesOfFreedom { get; }

Property Value

int

Methods

AddBodyReferencesLane(ref TBodyReferences, int, Span<int>)

public static void AddBodyReferencesLane(ref TBodyReferences bundle, int innerIndex, Span<int> bodyIndices)

Parameters

bundle TBodyReferences
innerIndex int
bodyIndices Span<int>

AllocateInTypeBatch(ref TypeBatch, ConstraintHandle, Span<int>, BufferPool)

Allocates a slot in the batch, assuming the batch is not a fallback batch.

public override sealed int AllocateInTypeBatch(ref TypeBatch typeBatch, ConstraintHandle handle, Span<int> bodyIndices, BufferPool pool)

Parameters

typeBatch TypeBatch

Type batch to allocate in.

handle ConstraintHandle

Handle of the constraint to allocate. Establishes a link from the allocated constraint to its handle.

bodyIndices Span<int>
pool BufferPool

Allocation provider to use if the type batch has to be resized.

Returns

int

Index of the slot in the batch.

AllocateInTypeBatchForFallback(ref TypeBatch, ConstraintHandle, Span<int>, BufferPool)

Allocates a slot in the batch, assuming the batch is a fallback batch.

public override sealed int AllocateInTypeBatchForFallback(ref TypeBatch typeBatch, ConstraintHandle handle, Span<int> encodedBodyIndices, BufferPool pool)

Parameters

typeBatch TypeBatch

Type batch to allocate in.

handle ConstraintHandle

Handle of the constraint to allocate. Establishes a link from the allocated constraint to its handle.

encodedBodyIndices Span<int>

List of body indices (not handles!) with count equal to the type batch's expected number of involved bodies.

pool BufferPool

Allocation provider to use if the type batch has to be resized.

Returns

int

Index of the slot in the batch.

BundleShouldIntegrate(int, in IndexSet, out Vector<int>)

public static TypeProcessor<TBodyReferences, TPrestepData, TAccumulatedImpulse>.BundleIntegrationMode BundleShouldIntegrate(int bundleIndex, in IndexSet integrationFlags, out Vector<int> integrationMask)

Parameters

bundleIndex int
integrationFlags IndexSet
integrationMask Vector<int>

Returns

TypeProcessor<TBodyReferences, TPrestepData, TAccumulatedImpulse>.BundleIntegrationMode

GatherAndIntegrate<TIntegratorCallbacks, TBatchIntegrationMode, TAccessFilter, TShouldIntegratePoses>(Bodies, ref TIntegratorCallbacks, ref Buffer<IndexSet>, int, float, int, int, ref Vector<int>, out Vector3Wide, out QuaternionWide, out BodyVelocityWide, out BodyInertiaWide)

public static void GatherAndIntegrate<TIntegratorCallbacks, TBatchIntegrationMode, TAccessFilter, TShouldIntegratePoses>(Bodies bodies, ref TIntegratorCallbacks integratorCallbacks, ref Buffer<IndexSet> integrationFlags, int bodyIndexInConstraint, float dt, int workerIndex, int bundleIndex, ref Vector<int> encodedBodyIndices, out Vector3Wide position, out QuaternionWide orientation, out BodyVelocityWide velocity, out BodyInertiaWide inertia) where TIntegratorCallbacks : struct, IPoseIntegratorCallbacks where TBatchIntegrationMode : unmanaged, IBatchIntegrationMode where TAccessFilter : unmanaged, IBodyAccessFilter where TShouldIntegratePoses : unmanaged, IBatchPoseIntegrationAllowed

Parameters

bodies Bodies
integratorCallbacks TIntegratorCallbacks
integrationFlags Buffer<IndexSet>
bodyIndexInConstraint int
dt float
workerIndex int
bundleIndex int
encodedBodyIndices Vector<int>
position Vector3Wide
orientation QuaternionWide
velocity BodyVelocityWide
inertia BodyInertiaWide

Type Parameters

TIntegratorCallbacks
TBatchIntegrationMode
TAccessFilter
TShouldIntegratePoses

GenerateSortKeysAndCopyReferences<TSortKeyGenerator>(ref TypeBatch, int, int, int, int, int, int, ref int, ref int, ref Buffer<byte>)

protected void GenerateSortKeysAndCopyReferences<TSortKeyGenerator>(ref TypeBatch typeBatch, int bundleStart, int localBundleStart, int bundleCount, int constraintStart, int localConstraintStart, int constraintCount, ref int firstSortKey, ref int firstSourceIndex, ref Buffer<byte> bodyReferencesCache) where TSortKeyGenerator : struct, ISortKeyGenerator<TBodyReferences>

Parameters

typeBatch TypeBatch
bundleStart int
localBundleStart int
bundleCount int
constraintStart int
localConstraintStart int
constraintCount int
firstSortKey int
firstSourceIndex int
bodyReferencesCache Buffer<byte>

Type Parameters

TSortKeyGenerator

Initialize(ref TypeBatch, int, BufferPool)

public override void Initialize(ref TypeBatch typeBatch, int initialCapacity, BufferPool pool)

Parameters

typeBatch TypeBatch
initialCapacity int
pool BufferPool

IntegratePoseAndVelocity<TIntegratorCallbacks>(ref TIntegratorCallbacks, ref Vector<int>, in BodyInertiaWide, float, in Vector<int>, ref Vector3Wide, ref QuaternionWide, ref BodyVelocityWide, int, out BodyInertiaWide)

public static void IntegratePoseAndVelocity<TIntegratorCallbacks>(ref TIntegratorCallbacks integratorCallbacks, ref Vector<int> bodyIndices, in BodyInertiaWide localInertia, float dt, in Vector<int> integrationMask, ref Vector3Wide position, ref QuaternionWide orientation, ref BodyVelocityWide velocity, int workerIndex, out BodyInertiaWide inertia) where TIntegratorCallbacks : struct, IPoseIntegratorCallbacks

Parameters

integratorCallbacks TIntegratorCallbacks
bodyIndices Vector<int>
localInertia BodyInertiaWide
dt float
integrationMask Vector<int>
position Vector3Wide
orientation QuaternionWide
velocity BodyVelocityWide
workerIndex int
inertia BodyInertiaWide

Type Parameters

TIntegratorCallbacks

IntegrateVelocity<TIntegratorCallbacks, TBatchIntegrationMode>(ref TIntegratorCallbacks, ref Vector<int>, in BodyInertiaWide, float, in Vector<int>, in Vector3Wide, in QuaternionWide, ref BodyVelocityWide, int, out BodyInertiaWide)

public static void IntegrateVelocity<TIntegratorCallbacks, TBatchIntegrationMode>(ref TIntegratorCallbacks integratorCallbacks, ref Vector<int> bodyIndices, in BodyInertiaWide localInertia, float dt, in Vector<int> integrationMask, in Vector3Wide position, in QuaternionWide orientation, ref BodyVelocityWide velocity, int workerIndex, out BodyInertiaWide inertia) where TIntegratorCallbacks : struct, IPoseIntegratorCallbacks where TBatchIntegrationMode : unmanaged, IBatchIntegrationMode

Parameters

integratorCallbacks TIntegratorCallbacks
bodyIndices Vector<int>
localInertia BodyInertiaWide
dt float
integrationMask Vector<int>
position Vector3Wide
orientation QuaternionWide
velocity BodyVelocityWide
workerIndex int
inertia BodyInertiaWide

Type Parameters

TIntegratorCallbacks
TBatchIntegrationMode

Move(ref TBodyReferences, ref TPrestepData, ref TAccumulatedImpulse, ConstraintHandle, int, ref TBodyReferences, ref TPrestepData, ref TAccumulatedImpulse, ref ConstraintHandle, int, int, ref Buffer<ConstraintLocation>)

Overwrites all the data in the target constraint slot with source data.

protected static void Move(ref TBodyReferences sourceReferencesBundle, ref TPrestepData sourcePrestepBundle, ref TAccumulatedImpulse sourceAccumulatedBundle, ConstraintHandle sourceHandle, int sourceInner, ref TBodyReferences targetReferencesBundle, ref TPrestepData targetPrestepBundle, ref TAccumulatedImpulse targetAccumulatedBundle, ref ConstraintHandle targetIndexToHandle, int targetInner, int targetIndex, ref Buffer<ConstraintLocation> handlesToConstraints)

Parameters

sourceReferencesBundle TBodyReferences
sourcePrestepBundle TPrestepData
sourceAccumulatedBundle TAccumulatedImpulse
sourceHandle ConstraintHandle
sourceInner int
targetReferencesBundle TBodyReferences
targetPrestepBundle TPrestepData
targetAccumulatedBundle TAccumulatedImpulse
targetIndexToHandle ConstraintHandle
targetInner int
targetIndex int
handlesToConstraints Buffer<ConstraintLocation>

Remove(ref TypeBatch, int, ref Buffer<ConstraintLocation>, bool)

Removes a constraint from the batch.

public override void Remove(ref TypeBatch typeBatch, int index, ref Buffer<ConstraintLocation> handlesToConstraints, bool isFallback)

Parameters

typeBatch TypeBatch

Type batch to remove a constraint from.

index int

Index of the constraint to remove.

handlesToConstraints Buffer<ConstraintLocation>

The handle to constraint mapping used by the solver that could be modified by a swap on removal.

isFallback bool

True if the type batch being removed from belongs to the fallback batch, false otherwise.

RemoveBodyReferencesLane(ref TBodyReferences, int)

public static void RemoveBodyReferencesLane(ref TBodyReferences bundle, int innerIndex)

Parameters

bundle TBodyReferences
innerIndex int

Resize(ref TypeBatch, int, BufferPool)

public override void Resize(ref TypeBatch typeBatch, int desiredCapacity, BufferPool pool)

Parameters

typeBatch TypeBatch
desiredCapacity int
pool BufferPool

ScaleAccumulatedImpulses(ref TypeBatch, float)

public override void ScaleAccumulatedImpulses(ref TypeBatch typeBatch, float scale)

Parameters

typeBatch TypeBatch
scale float

Scramble(ref TypeBatch, Random, ref Buffer<ConstraintLocation>)

public override sealed void Scramble(ref TypeBatch typeBatch, Random random, ref Buffer<ConstraintLocation> handlesToConstraints)

Parameters

typeBatch TypeBatch
random Random
handlesToConstraints Buffer<ConstraintLocation>

SetBodyReferencesLane(ref TBodyReferences, int, Span<int>)

public static void SetBodyReferencesLane(ref TBodyReferences bundle, int innerIndex, Span<int> bodyIndices)

Parameters

bundle TBodyReferences
innerIndex int
bodyIndices Span<int>

TransferConstraint(ref TypeBatch, int, int, Solver, Bodies, int, Span<BodyHandle>, Span<int>)

Moves a constraint from one ConstraintBatch's TypeBatch to another ConstraintBatch's TypeBatch of the same type.

public override sealed void TransferConstraint(ref TypeBatch sourceTypeBatch, int sourceBatchIndex, int indexInTypeBatch, Solver solver, Bodies bodies, int targetBatchIndex, Span<BodyHandle> dynamicBodyHandles, Span<int> encodedBodyIndices)

Parameters

sourceTypeBatch TypeBatch

Source type batch to transfer the constraint out of.

sourceBatchIndex int

Index of the batch that owns the type batch that is the source of the constraint transfer.

indexInTypeBatch int

Index of the constraint to move in the current type batch.

solver Solver

Solver that owns the batches.

bodies Bodies

Bodies set that owns all the constraint's bodies.

targetBatchIndex int

Index of the ConstraintBatch in the solver to copy the constraint into.

dynamicBodyHandles Span<BodyHandle>

Set of body handles in the constraint referring to dynamic bodies.

encodedBodyIndices Span<int>

Set of encoded body indices to use in the new constraint allocation.

UpdateForBodyMemoryMove(ref TypeBatch, int, int, int)

Updates a type batch's body index references for the movement of a body in memory.

public override sealed bool UpdateForBodyMemoryMove(ref TypeBatch typeBatch, int indexInTypeBatch, int bodyIndexInConstraint, int newBodyLocation)

Parameters

typeBatch TypeBatch

Type batch containing a constraint that references the body.

indexInTypeBatch int

Index of the constraint in the type batch.

bodyIndexInConstraint int

Index within the constraint of the body.

newBodyLocation int

New index of the body in the bodies active set.

Returns

bool

True if the body being moved was kinematic according to the constraint's reference.

ValidateAccumulatedImpulsesSizeInBytes(int)

protected override void ValidateAccumulatedImpulsesSizeInBytes(int sizeInBytes)

Parameters

sizeInBytes int

VerifySortRegion<TSortKeyGenerator>(ref TypeBatch, int, int, ref Buffer<int>, ref Buffer<int>)

protected void VerifySortRegion<TSortKeyGenerator>(ref TypeBatch typeBatch, int bundleStartIndex, int constraintCount, ref Buffer<int> sortedKeys, ref Buffer<int> sortedSourceIndices) where TSortKeyGenerator : struct, ISortKeyGenerator<TBodyReferences>

Parameters

typeBatch TypeBatch
bundleStartIndex int
constraintCount int
sortedKeys Buffer<int>
sortedSourceIndices Buffer<int>

Type Parameters

TSortKeyGenerator