RavEngine
Loading...
Searching...
No Matches
physx::Dy::DynamicsContext Class Reference

Encapsules the data used by the constraint solver. More...

#include <DyDynamics.h>

Inheritance diagram for physx::Dy::DynamicsContext:
[legend]
Collaboration diagram for physx::Dy::DynamicsContext:
[legend]

Public Member Functions

void destroy ()
 Destroys this DynamicsContext.
 
PX_FORCE_INLINE PxSolverBody & getWorldSolverBody ()
 Returns the static world solver body.
 
PX_FORCE_INLINE Cm::FlushPool & getTaskPool ()
 
PX_FORCE_INLINE ThresholdStream & getThresholdStream ()
 
PX_FORCE_INLINE PxvSimStats & getSimStats ()
 
virtual PX_CATCH_UNDEFINED_ENABLE_SIM_STATS void update (IG::SimpleIslandManager &simpleIslandManager, PxBaseTask *continuation, PxBaseTask *lostTouchTask, PxvNphaseImplementationContext *nPhase, const PxU32 maxPatchesPerCM, const PxU32 maxArticulationLinks, const PxReal dt, const PxVec3 &gravity, PxBitMapPinned &changedHandleMap)
 The entry point for the constraint solver.
 
void updatePostKinematic (IG::SimpleIslandManager &simpleIslandManager, PxBaseTask *continuation, PxBaseTask *lostTouchTask, const PxU32 maxLinks)
 
virtual void processLostPatches (IG::SimpleIslandManager &, PxsContactManager **, PxU32, PxsContactManagerOutputCounts *)
 
virtual void processFoundPatches (IG::SimpleIslandManager &, PxsContactManager **, PxU32, PxsContactManagerOutputCounts *)
 
virtual void updateBodyCore (PxBaseTask *continuation)
 This method copy gpu solver body data to cpu body core.
 
virtual void setSimulationController (PxsSimulationController *simulationController)
 
virtual void mergeResults ()
 This method combines the results of several islands, e.g. constructing scene-level simulation statistics and merging together threshold streams for contact notification.
 
virtual void getDataStreamBase (void *&, void *&, void *&)
 
virtual PxSolverType::Enum getSolverType () const
 
PX_FORCE_INLINE ThreadContext * getThreadContext ()
 Allocates and returns a thread context object.
 
void putThreadContext (ThreadContext *context)
 Returns a thread context to the thread context pool.
 
PX_FORCE_INLINE PxU32 getKinematicCount () const
 
PX_FORCE_INLINE PxU64 getContextId () const
 
- Public Member Functions inherited from physx::Dy::Context
PX_FORCE_INLINE PxReal getMaxBiasCoefficient () const
 
PX_FORCE_INLINE void setMaxBiasCoefficient (PxReal coeff)
 
PX_FORCE_INLINE PxReal getBounceThreshold () const
 Returns the bounce threshold.
 
PX_FORCE_INLINE PxReal getFrictionOffsetThreshold () const
 Returns the friction offset threshold.
 
PX_FORCE_INLINE PxReal getCorrelationDistance () const
 Returns the correlation distance.
 
PX_FORCE_INLINE PxReal getCCDSeparationThreshold () const
 Returns the CCD separation threshold.
 
PX_FORCE_INLINE PxReal getLengthScale () const
 Returns the length scale.
 
PX_FORCE_INLINE void setBounceThreshold (PxReal f)
 Sets the bounce threshold.
 
PX_FORCE_INLINE void setCorrelationDistance (PxReal f)
 Sets the correlation distance.
 
PX_FORCE_INLINE void setFrictionOffsetThreshold (PxReal offset)
 Sets the friction offset threshold.
 
PX_FORCE_INLINE void setCCDSeparationThreshold (PxReal offset)
 Sets the friction offset threshold.
 
PX_FORCE_INLINE PxU32 getSolverBatchSize () const
 Returns the solver batch size.
 
PX_FORCE_INLINE void setSolverBatchSize (PxU32 f)
 Sets the solver batch size.
 
PX_FORCE_INLINE PxU32 getSolverArticBatchSize () const
 Returns the solver batch size.
 
PX_FORCE_INLINE void setSolverArticBatchSize (PxU32 f)
 Sets the solver batch size.
 
PX_FORCE_INLINE PxU32 getMaxSolverConstraintSize () const
 Returns the maximum solver constraint size.
 
PX_FORCE_INLINE PxFrictionType::Enum getFrictionType () const
 Returns the friction model being used.
 
PX_FORCE_INLINE ThresholdStream & getThresholdStream ()
 Returns the threshold stream.
 
PX_FORCE_INLINE ThresholdStream & getForceChangedThresholdStream ()
 
PX_FORCE_INLINE ThresholdTable & getThresholdTable ()
 Returns the threshold table.
 
PX_FORCE_INLINE void setFrictionType (PxFrictionType::Enum f)
 Sets the friction model to be used.
 
PX_FORCE_INLINE PxcDataStreamPool & getContactStreamPool ()
 
PX_FORCE_INLINE PxcDataStreamPool & getPatchStreamPool ()
 
PX_FORCE_INLINE PxcDataStreamPool & getForceStreamPool ()
 
PX_FORCE_INLINE PxPinnedArray< Dy::ConstraintWriteback > & getConstraintWriteBackPool ()
 
PX_FORCE_INLINE PxReal getDt () const
 Returns the current frame's timestep.
 
PX_FORCE_INLINE PxReal getInvDt () const
 Returns 1/(current frame's timestep)
 
PX_FORCE_INLINE PxVec3 getGravity () const
 
void createThresholdStream (PxVirtualAllocatorCallback &callback)
 
void createForceChangeThresholdStream (PxVirtualAllocatorCallback &callback)
 
void setStateDirty (bool dirty)
 
bool isStateDirty ()
 
void setSuppressReadback (bool suppressReadback)
 
bool getSuppressReadback ()
 
void setDt (const PxReal dt)
 

Static Public Member Functions

static DynamicsContext * create (PxcNpMemBlockPool *memBlockPool, PxcScratchAllocator &scratchAllocator, Cm::FlushPool &taskPool, PxvSimStats &simStats, PxTaskManager *taskManager, PxVirtualAllocatorCallback *allocator, PxsMaterialManager *materialManager, IG::SimpleIslandManager *islandManager, PxU64 contextID, const bool enableStabilization, const bool useEnhancedDeterminism, const PxReal maxBiasCoefficient, const bool frictionEveryIteration, const PxReal lengthScale)
 Creates a DynamicsContext associated with a PxsContext.
 

Protected Member Functions

 DynamicsContext (PxcNpMemBlockPool *memBlockPool, PxcScratchAllocator &scratchAllocator, Cm::FlushPool &taskPool, PxvSimStats &simStats, PxTaskManager *taskManager, PxVirtualAllocatorCallback *allocator, PxsMaterialManager *materialManager, IG::SimpleIslandManager *islandManager, PxU64 contextID, const bool enableStabilization, const bool useEnhancedDeterminism, const PxReal maxBiasCoefficient, const bool frictionEveryIteration, const PxReal lengthScale)
 Constructor for DynamicsContext.
 
virtual ~DynamicsContext ()
 Destructor for DynamicsContext.
 
void computeUnconstrainedVelocity (PxsRigidBody *atom) const
 Computes the unconstrained velocity for a given PxsRigidBody.
 
void setDescFromIndices (PxSolverConstraintDesc &desc, const IG::IslandSim &islandSim, const PxsIndexedInteraction &constraint, const PxU32 solverBodyOffset)
 fills in a PxSolverConstraintDesc from an indexed interaction
 
void setDescFromIndices (PxSolverConstraintDesc &desc, IG::EdgeIndex edgeIndex, const IG::SimpleIslandManager &islandManager, PxU32 *bodyRemapTable, const PxU32 solverBodyOffset)
 
void preIntegrationParallel (const PxF32 dt, PxsBodyCore *const *bodyArray, PxsRigidBody *const *originalBodyArray, PxU32 const *nodeIndexArray, PxU32 bodyCount, PxSolverBody *solverBodyPool, PxSolverBodyData *solverBodyDataPool, Cm::SpatialVector *motionVelocityArray, PxU32 &maxSolverPositionIterations, PxU32 &maxSolverVelocityIterations, PxBaseTask &integrateTask)
 Compute the unconstrained velocity for set of bodies in parallel. This function may spawn additional tasks.
 
void solveParallel (SolverIslandParams &params, IG::IslandSim &islandSim, Cm::SpatialVectorF *Z, Cm::SpatialVectorF *deltaV)
 Solves an island in parallel.
 
void integrateCoreParallel (SolverIslandParams &params, Cm::SpatialVectorF *deltaV, IG::IslandSim &islandSim)
 
void resetThreadContexts ()
 Resets the thread contexts.
 
PX_FORCE_INLINE PxcScratchAllocator & getScratchAllocator ()
 Returns the scratch memory allocator.
 
 PX_ALIGN (16, PxSolverBody mWorldSolverBody)
 Body to represent the world static body.
 
 PX_ALIGN (16, PxSolverBodyData mWorldSolverBodyData)
 Body data to represent the world static body.
 
- Protected Member Functions inherited from physx::Dy::Context
 Context (IG::SimpleIslandManager *islandManager, PxVirtualAllocatorCallback *allocatorCallback, PxvSimStats &simStats, bool enableStabilization, bool useEnhancedDeterminism, const PxReal maxBiasCoefficient, const PxReal lengthScale)
 

Protected Attributes

PxcThreadCoherentCache< ThreadContext, PxcNpMemBlockPool > mThreadContextPool
 A thread context pool.
 
SolverConstraintDescPool mSolverConstraintDescPool
 Solver constraint desc array.
 
SolverConstraintDescPool mOrderedSolverConstraintDescPool
 Ordered sover constraint desc array (after partitioning)
 
SolverConstraintDescPool mTempSolverConstraintDescPool
 A temporary array of constraint descs used for partitioning.
 
PxArray< PxConstraintBatchHeader > mContactConstraintBatchHeaders
 An array of contact constraint batch headers.
 
PxArray< Cm::SpatialVector > mMotionVelocityArray
 Array of motion velocities for all bodies in the scene.
 
PxArray< PxsBodyCore * > mBodyCoreArray
 Array of body core pointers for all bodies in the scene.
 
PxArray< PxsRigidBody * > mRigidBodyArray
 Array of rigid body pointers for all bodies in the scene.
 
PxArray< FeatherstoneArticulation * > mArticulationArray
 Array of articulation pointers for all articulations in the scene.
 
SolverBodyPool mSolverBodyPool
 Global pool for solver bodies. Kinematic bodies are at the start, and then dynamic bodies.
 
SolverBodyDataPool mSolverBodyDataPool
 Global pool for solver body data. Kinematic bodies are at the start, and then dynamic bodies.
 
ThresholdStream * mExceededForceThresholdStream [2]
 
PxArray< PxU32 > mExceededForceThresholdStreamMask
 
SolverCore * mSolverCore [PxFrictionType::eFRICTION_COUNT]
 Interface to the solver core.
 
PxArray< PxU32 > mSolverBodyRemapTable
 
PxArray< PxU32 > mNodeIndexArray
 
PxArray< PxsIndexedContactManager > mContactList
 
PxU32 mKinematicCount
 The total number of kinematic bodies in the scene.
 
PxI32 mThresholdStreamOut
 Atomic counter for the number of threshold stream elements.
 
PxsMaterialManager * mMaterialManager
 
PxsContactManagerOutputIterator mOutputIterator
 
- Protected Attributes inherited from physx::Dy::Context
ThresholdStream * mThresholdStream
 
ThresholdStream * mForceChangedThresholdStream
 
ThresholdTable mThresholdTable
 
IG::SimpleIslandManager * mIslandManager
 
PxsSimulationController * mSimulationController
 
PxReal mDt
 Time-step.
 
PxReal mInvDt
 1/time-step.
 
PxReal mMaxBiasCoefficient
 
const bool mEnableStabilization
 
const bool mUseEnhancedDeterminism
 
PxVec3 mGravity
 
PxU32 mMaxSolverConstraintSize
 max solver constraint size
 
PxReal mBounceThreshold
 Threshold controlling the relative velocity at which the solver transitions between restitution and bias for solving normal contact constraint.
 
PxReal mFrictionOffsetThreshold
 Threshold controlling whether friction anchors are constructed or not. If the separation is above mFrictionOffsetThreshold, the contact will not be considered to become a friction anchor.
 
PxReal mCCDSeparationThreshold
 Threshold controlling whether distant contacts are processed using bias, restitution or a combination of the two. This only has effect on pairs involving bodies that have enabled speculative CCD simulation mode.
 
PxReal mCorrelationDistance
 Threshold for controlling friction correlation.
 
PxReal mLengthScale
 The length scale from PxTolerancesScale::length.
 
PxU32 mSolverBatchSize
 The minimum size of an island to generate a solver task chain.
 
PxU32 mSolverArticBatchSize
 The minimum number of articulations required to generate a solver task chain.
 
PxFrictionType::Enum mFrictionType
 The current friction model being used.
 
PxcDataStreamPool mContactStreamPool
 Structure to encapsulate contact stream allocations. Used by GPU solver to reference pre-allocated pinned host memory.
 
PxcDataStreamPool mPatchStreamPool
 Struct to encapsulate the contact patch stream allocations. Used by GPU solver to reference pre-allocated pinned host memory.
 
PxcDataStreamPool mForceStreamPool
 Structure to encapsulate force stream allocations. Used by GPU solver to reference pre-allocated pinned host memory for force reports.
 
PxPinnedArray< Dy::ConstraintWriteback > mConstraintWriteBackPool
 Structure to encapsulate constraint write back allocations. Used by GPU/CPU solver to reference pre-allocated pinned host memory for breakable joint reports.
 
PxvSimStats & mSimStats
 
bool mBodyStateDirty
 
bool mSuppressReadback
 

Friends

class PxsSolverStartTask
 
class PxsSolverAticulationsTask
 
class PxsSolverSetupConstraintsTask
 
class PxsSolverCreateFinalizeConstraintsTask
 
class PxsSolverConstraintPartitionTask
 
class PxsSolverSetupSolveTask
 
class PxsSolverIntegrateTask
 
class PxsSolverEndTask
 
class PxsSolverConstraintPostProcessTask
 
class PxsForceThresholdTask
 
class SolverArticulationUpdateTask
 
void solveParallel (SOLVER_PARALLEL_METHOD_ARGS)
 

Detailed Description

Encapsules the data used by the constraint solver.

Member Function Documentation

◆ computeUnconstrainedVelocity()

void physx::Dy::DynamicsContext::computeUnconstrainedVelocity ( PxsRigidBody *  atom) const
protected

Computes the unconstrained velocity for a given PxsRigidBody.

Parameters
[in]atomThe PxsRigidBody

◆ create()

DynamicsContext * physx::Dy::DynamicsContext::create ( PxcNpMemBlockPool *  memBlockPool,
PxcScratchAllocator &  scratchAllocator,
Cm::FlushPool &  taskPool,
PxvSimStats &  simStats,
PxTaskManager *  taskManager,
PxVirtualAllocatorCallback *  allocator,
PxsMaterialManager *  materialManager,
IG::SimpleIslandManager *  islandManager,
PxU64  contextID,
const bool  enableStabilization,
const bool  useEnhancedDeterminism,
const PxReal  maxBiasCoefficient,
const bool  frictionEveryIteration,
const PxReal  lengthScale 
)
static

Creates a DynamicsContext associated with a PxsContext.

Returns
A pointer to the newly-created DynamicsContext.

◆ destroy()

void physx::Dy::DynamicsContext::destroy ( )
virtual

Destroys this DynamicsContext.

Implements physx::Dy::Context.

◆ getDataStreamBase()

virtual void physx::Dy::DynamicsContext::getDataStreamBase ( void *&  ,
void *&  ,
void *&   
)
inlinevirtual

Implements physx::Dy::Context.

◆ getScratchAllocator()

PX_FORCE_INLINE PxcScratchAllocator & physx::Dy::DynamicsContext::getScratchAllocator ( )
inlineprotected

Returns the scratch memory allocator.

Returns
The scratch memory allocator.

◆ getSolverType()

virtual PxSolverType::Enum physx::Dy::DynamicsContext::getSolverType ( ) const
inlinevirtual

Implements physx::Dy::Context.

◆ getThreadContext()

PX_FORCE_INLINE ThreadContext * physx::Dy::DynamicsContext::getThreadContext ( )
inline

Allocates and returns a thread context object.

Returns
A thread context.

◆ getWorldSolverBody()

PX_FORCE_INLINE PxSolverBody & physx::Dy::DynamicsContext::getWorldSolverBody ( )
inline

Returns the static world solver body.

Returns
The static world solver body.

◆ mergeResults()

void physx::Dy::DynamicsContext::mergeResults ( )
virtual

This method combines the results of several islands, e.g. constructing scene-level simulation statistics and merging together threshold streams for contact notification.

Implements physx::Dy::Context.

◆ preIntegrationParallel()

void physx::Dy::DynamicsContext::preIntegrationParallel ( const PxF32  dt,
PxsBodyCore *const *  bodyArray,
PxsRigidBody *const *  originalBodyArray,
PxU32 const *  nodeIndexArray,
PxU32  bodyCount,
PxSolverBody *  solverBodyPool,
PxSolverBodyData *  solverBodyDataPool,
Cm::SpatialVector *  motionVelocityArray,
PxU32 &  maxSolverPositionIterations,
PxU32 &  maxSolverVelocityIterations,
PxBaseTask &  integrateTask 
)
protected

Compute the unconstrained velocity for set of bodies in parallel. This function may spawn additional tasks.

Parameters
[in]dtThe timestep
[in]bodyArrayThe array of body cores
[in]originalBodyArrayThe array of PxsRigidBody
[in]nodeIndexArrayThe array of island node index
[in]bodyCountThe number of bodies
[out]solverBodyPoolThe pool of solver bodies. These are synced with the corresponding body in bodyArray.
[out]solverBodyDataPoolThe pool of solver body data. These are synced with the corresponding body in bodyArray
[out]motionVelocityArrayThe motion velocities for the bodies
[out]maxSolverPositionIterationsThe maximum number of position iterations requested by any body in the island
[out]maxSolverVelocityIterationsThe maximum number of velocity iterations requested by any body in the island
[out]integrateTaskThe continuation task for any tasks spawned by this function.

◆ processFoundPatches()

virtual void physx::Dy::DynamicsContext::processFoundPatches ( IG::SimpleIslandManager &  ,
PxsContactManager **  ,
PxU32  ,
PxsContactManagerOutputCounts *   
)
inlinevirtual

Implements physx::Dy::Context.

◆ processLostPatches()

virtual void physx::Dy::DynamicsContext::processLostPatches ( IG::SimpleIslandManager &  ,
PxsContactManager **  ,
PxU32  ,
PxsContactManagerOutputCounts *   
)
inlinevirtual

Implements physx::Dy::Context.

◆ putThreadContext()

void physx::Dy::DynamicsContext::putThreadContext ( ThreadContext *  context)
inline

Returns a thread context to the thread context pool.

Parameters
[in]contextThe thread context to return to the thread context pool.

◆ setDescFromIndices()

PX_CATCH_UNDEFINED_ENABLE_SIM_STATS void physx::Dy::DynamicsContext::setDescFromIndices ( PxSolverConstraintDesc &  desc,
const IG::IslandSim &  islandSim,
const PxsIndexedInteraction &  constraint,
const PxU32  solverBodyOffset 
)
protected

fills in a PxSolverConstraintDesc from an indexed interaction

Parameters
[in,out]descThe PxSolverConstraintDesc
[in]constraintThe PxsIndexedInteraction

◆ setSimulationController()

virtual void physx::Dy::DynamicsContext::setSimulationController ( PxsSimulationController *  simulationController)
inlinevirtual

Implements physx::Dy::Context.

◆ solveParallel()

void physx::Dy::DynamicsContext::solveParallel ( SolverIslandParams &  params,
IG::IslandSim &  islandSim,
Cm::SpatialVectorF *  Z,
Cm::SpatialVectorF *  deltaV 
)
protected

Solves an island in parallel.

Parameters
[in]paramsSolver parameter structure

◆ update()

void physx::Dy::DynamicsContext::update ( IG::SimpleIslandManager &  simpleIslandManager,
PxBaseTask *  continuation,
PxBaseTask *  lostTouchTask,
PxvNphaseImplementationContext *  nPhase,
const PxU32  maxPatchesPerCM,
const PxU32  maxArticulationLinks,
const PxReal  dt,
const PxVec3 &  gravity,
PxBitMapPinned &  changedHandleMap 
)
virtual

The entry point for the constraint solver.

Parameters
[in]dtThe simulation time-step
[in]continuationThe continuation task for the solver

This method is called after the island generation has completed. Its main responsibilities are: (1) Reserving the solver body pools (2) Initializing the static and kinematic solver bodies, which are shared resources between islands. (3) Construct the solver task chains for each island

Each island is solved as an independent solver task chain in parallel.

Implements physx::Dy::Context.

◆ updateBodyCore()

void physx::Dy::DynamicsContext::updateBodyCore ( PxBaseTask *  continuation)
virtual

This method copy gpu solver body data to cpu body core.

Implements physx::Dy::Context.

Member Data Documentation

◆ mSolverCore

SolverCore* physx::Dy::DynamicsContext::mSolverCore[PxFrictionType::eFRICTION_COUNT]
protected

Interface to the solver core.

Note
We currently only support PxsSolverCoreSIMD. Other cores may be added in future releases.

The documentation for this class was generated from the following files: