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
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
typeBatch
TypeBatchType batch to allocate in.
handle
ConstraintHandleHandle of the constraint to allocate. Establishes a link from the allocated constraint to its handle.
bodyIndices
Span<int>pool
BufferPoolAllocation 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
TypeBatchType batch to allocate in.
handle
ConstraintHandleHandle 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
BufferPoolAllocation 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
bodies
BodiesintegratorCallbacks
TIntegratorCallbacksintegrationFlags
Buffer<IndexSet>bodyIndexInConstraint
intdt
floatworkerIndex
intbundleIndex
intencodedBodyIndices
Vector<int>position
Vector3Wideorientation
QuaternionWidevelocity
BodyVelocityWideinertia
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
TypeBatchbundleStart
intlocalBundleStart
intbundleCount
intconstraintStart
intlocalConstraintStart
intconstraintCount
intfirstSortKey
intfirstSourceIndex
intbodyReferencesCache
Buffer<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
integratorCallbacks
TIntegratorCallbacksbodyIndices
Vector<int>localInertia
BodyInertiaWidedt
floatintegrationMask
Vector<int>position
Vector3Wideorientation
QuaternionWidevelocity
BodyVelocityWideworkerIndex
intinertia
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
TIntegratorCallbacksbodyIndices
Vector<int>localInertia
BodyInertiaWidedt
floatintegrationMask
Vector<int>position
Vector3Wideorientation
QuaternionWidevelocity
BodyVelocityWideworkerIndex
intinertia
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
TBodyReferencessourcePrestepBundle
TPrestepDatasourceAccumulatedBundle
TAccumulatedImpulsesourceHandle
ConstraintHandlesourceInner
inttargetReferencesBundle
TBodyReferencestargetPrestepBundle
TPrestepDatatargetAccumulatedBundle
TAccumulatedImpulsetargetIndexToHandle
ConstraintHandletargetInner
inttargetIndex
inthandlesToConstraints
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
TypeBatchType batch to remove a constraint from.
index
intIndex 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
boolTrue 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
TBodyReferencesinnerIndex
int
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
typeBatch
TypeBatchrandom
RandomhandlesToConstraints
Buffer<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
sourceTypeBatch
TypeBatchSource type batch to transfer the constraint out of.
sourceBatchIndex
intIndex of the batch that owns the type batch that is the source of the constraint transfer.
indexInTypeBatch
intIndex of the constraint to move in the current type batch.
solver
SolverSolver that owns the batches.
bodies
BodiesBodies set that owns all the constraint's bodies.
targetBatchIndex
intIndex 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
TypeBatchType batch containing a constraint that references the body.
indexInTypeBatch
intIndex of the constraint in the type batch.
bodyIndexInConstraint
intIndex within the constraint of the body.
newBodyLocation
intNew 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
TypeBatchbundleStartIndex
intconstraintCount
intsortedKeys
Buffer<int>sortedSourceIndices
Buffer<int>
Type Parameters
TSortKeyGenerator