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
TBodyReferencesTPrestepDataTAccumulatedImpulse
- Inheritance
-
TypeProcessor<TBodyReferences, TPrestepData, TAccumulatedImpulse>
- Derived
- Inherited Members
Properties
InternalConstrainedDegreesOfFreedom
protected override int InternalConstrainedDegreesOfFreedom { get; }
Property Value
Methods
AddBodyReferencesLane(ref TBodyReferences, int, Span<int>)
public static void AddBodyReferencesLane(ref TBodyReferences bundle, int innerIndex, Span<int> bodyIndices)
Parameters
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
typeBatchTypeBatchType batch to allocate in.
handleConstraintHandleHandle of the constraint to allocate. Establishes a link from the allocated constraint to its handle.
bodyIndicesSpan<int>poolBufferPoolAllocation 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
typeBatchTypeBatchType batch to allocate in.
handleConstraintHandleHandle of the constraint to allocate. Establishes a link from the allocated constraint to its handle.
encodedBodyIndicesSpan<int>List of body indices (not handles!) with count equal to the type batch's expected number of involved bodies.
poolBufferPoolAllocation 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
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
bodiesBodiesintegratorCallbacksTIntegratorCallbacksintegrationFlagsBuffer<IndexSet>bodyIndexInConstraintintdtfloatworkerIndexintbundleIndexintencodedBodyIndicesVector<int>positionVector3WideorientationQuaternionWidevelocityBodyVelocityWideinertiaBodyInertiaWide
Type Parameters
TIntegratorCallbacksTBatchIntegrationModeTAccessFilterTShouldIntegratePoses
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
typeBatchTypeBatchbundleStartintlocalBundleStartintbundleCountintconstraintStartintlocalConstraintStartintconstraintCountintfirstSortKeyintfirstSourceIndexintbodyReferencesCacheBuffer<byte>
Type Parameters
TSortKeyGenerator
Initialize(ref TypeBatch, int, BufferPool)
public override void Initialize(ref TypeBatch typeBatch, int initialCapacity, BufferPool pool)
Parameters
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
integratorCallbacksTIntegratorCallbacksbodyIndicesVector<int>localInertiaBodyInertiaWidedtfloatintegrationMaskVector<int>positionVector3WideorientationQuaternionWidevelocityBodyVelocityWideworkerIndexintinertiaBodyInertiaWide
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
integratorCallbacksTIntegratorCallbacksbodyIndicesVector<int>localInertiaBodyInertiaWidedtfloatintegrationMaskVector<int>positionVector3WideorientationQuaternionWidevelocityBodyVelocityWideworkerIndexintinertiaBodyInertiaWide
Type Parameters
TIntegratorCallbacksTBatchIntegrationMode
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
sourceReferencesBundleTBodyReferencessourcePrestepBundleTPrestepDatasourceAccumulatedBundleTAccumulatedImpulsesourceHandleConstraintHandlesourceInnerinttargetReferencesBundleTBodyReferencestargetPrestepBundleTPrestepDatatargetAccumulatedBundleTAccumulatedImpulsetargetIndexToHandleConstraintHandletargetInnerinttargetIndexinthandlesToConstraintsBuffer<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
typeBatchTypeBatchType batch to remove a constraint from.
indexintIndex of the constraint to remove.
handlesToConstraintsBuffer<ConstraintLocation>The handle to constraint mapping used by the solver that could be modified by a swap on removal.
isFallbackboolTrue 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
bundleTBodyReferencesinnerIndexint
Resize(ref TypeBatch, int, BufferPool)
public override void Resize(ref TypeBatch typeBatch, int desiredCapacity, BufferPool pool)
Parameters
ScaleAccumulatedImpulses(ref TypeBatch, float)
public override void ScaleAccumulatedImpulses(ref TypeBatch typeBatch, float scale)
Parameters
Scramble(ref TypeBatch, Random, ref Buffer<ConstraintLocation>)
public override sealed void Scramble(ref TypeBatch typeBatch, Random random, ref Buffer<ConstraintLocation> handlesToConstraints)
Parameters
typeBatchTypeBatchrandomRandomhandlesToConstraintsBuffer<ConstraintLocation>
SetBodyReferencesLane(ref TBodyReferences, int, Span<int>)
public static void SetBodyReferencesLane(ref TBodyReferences bundle, int innerIndex, Span<int> bodyIndices)
Parameters
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
sourceTypeBatchTypeBatchSource type batch to transfer the constraint out of.
sourceBatchIndexintIndex of the batch that owns the type batch that is the source of the constraint transfer.
indexInTypeBatchintIndex of the constraint to move in the current type batch.
solverSolverSolver that owns the batches.
bodiesBodiesBodies set that owns all the constraint's bodies.
targetBatchIndexintIndex of the ConstraintBatch in the solver to copy the constraint into.
dynamicBodyHandlesSpan<BodyHandle>Set of body handles in the constraint referring to dynamic bodies.
encodedBodyIndicesSpan<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
typeBatchTypeBatchType batch containing a constraint that references the body.
indexInTypeBatchintIndex of the constraint in the type batch.
bodyIndexInConstraintintIndex within the constraint of the body.
newBodyLocationintNew 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
sizeInBytesint
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
typeBatchTypeBatchbundleStartIndexintconstraintCountintsortedKeysBuffer<int>sortedSourceIndicesBuffer<int>
Type Parameters
TSortKeyGenerator