29#ifndef DY_SOLVER_CORE_H
30#define DY_SOLVER_CORE_H
33#include "foundation/PxArray.h"
34#include "foundation/PxThread.h"
41struct PxSolverBodyData;
42struct PxSolverConstraintDesc;
43struct PxConstraintBatchHeader;
47struct ThresholdStreamElement;
50struct ArticulationSolverDesc;
54typedef void (*WriteBackMethod)(
const PxSolverConstraintDesc& desc, SolverContext& cache, PxSolverBodyData& sbd0, PxSolverBodyData& sbd1);
55typedef void (*SolveMethod)(
const PxSolverConstraintDesc& desc, SolverContext& cache);
56typedef void (*SolveBlockMethod)(
const PxSolverConstraintDesc* desc,
const PxU32 constraintCount, SolverContext& cache);
57typedef void (*SolveWriteBackBlockMethod)(
const PxSolverConstraintDesc* desc,
const PxU32 constraintCount, SolverContext& cache);
58typedef void (*WriteBackBlockMethod)(
const PxSolverConstraintDesc* desc,
const PxU32 constraintCount, SolverContext& cache);
60#define PX_PROFILE_SOLVE_STALLS 0
61#if PX_PROFILE_SOLVE_STALLS
71 QueryPerformanceCounter(&i);
79#define YIELD_THREADS 1
83#define ATTEMPTS_BEFORE_BACKOFF 30000
84#define ATTEMPTS_BEFORE_RETEST 10000
88PX_INLINE void WaitForProgressCount(
volatile PxI32* pGlobalIndex,
const PxI32 targetIndex)
91 if(*pGlobalIndex < targetIndex)
93 bool satisfied =
false;
94 PxU32 count = ATTEMPTS_BEFORE_BACKOFF;
98 while(*pGlobalIndex < targetIndex)
108 count = ATTEMPTS_BEFORE_RETEST;
113 while(*pGlobalIndex < targetIndex);
118#if PX_PROFILE_SOLVE_STALLS
119PX_INLINE void WaitForProgressCount(
volatile PxI32* pGlobalIndex,
const PxI32 targetIndex, PxU64& stallTime)
121 if(*pGlobalIndex < targetIndex)
123 bool satisfied =
false;
124 PxU32 count = ATTEMPTS_BEFORE_BACKOFF;
128 PxU64 startTime = readTimer();
129 while(*pGlobalIndex < targetIndex)
137 PxU64 endTime = readTimer();
138 stallTime += (endTime - startTime);
141 count = ATTEMPTS_BEFORE_BACKOFF;
147#define WAIT_FOR_PROGRESS(pGlobalIndex, targetIndex) if(*pGlobalIndex < targetIndex) WaitForProgressCount(pGlobalIndex, targetIndex, stallCount)
149#define WAIT_FOR_PROGRESS(pGlobalIndex, targetIndex) if(*pGlobalIndex < targetIndex) WaitForProgressCount(pGlobalIndex, targetIndex)
151#define WAIT_FOR_PROGRESS_NO_TIMER(pGlobalIndex, targetIndex) if(*pGlobalIndex < targetIndex) WaitForProgressCount(pGlobalIndex, targetIndex)
157 PxU32 positionIterations;
158 PxU32 velocityIterations;
162 PxU32 solverBodyOffset;
164 PxU32 articulationListSize;
167 PxU32 numConstraintHeaders;
168 PxU32* headersPerPartition;
176 PxI32 constraintIndex;
177 PxI32 constraintIndex2;
179 PxI32 bodyListIndex2;
180 PxI32 articSolveIndex;
181 PxI32 articSolveIndex2;
182 PxI32 bodyIntegrationListIndex;
183 PxI32 numObjectsIntegrated;
193 PxU32 numFrictionConstraintHeaders;
194 PxU32* frictionHeadersPerPartition;
195 PxU32 nbFrictionPartitions;
198 PxI32 frictionConstraintIndex;
202 PxU32 thresholdStreamLength;
204 PxI32* outThresholdPairs;
206 PxU32 mMaxArticulationLinks;
219 virtual void destroyV() = 0;
231 virtual PxI32 solveVParallelAndWriteBack
235 virtual void solveV_Blocks
239 virtual void writeBackV
242 PxSolverBodyData* atomListData, WriteBackBlockMethod writeBackTable[])
const = 0;
Definition CmSpatialVector.h:46
Definition DySolverCore.h:217
static void yield()
Definition PxThread.h:323
Definition PxsRigidBody.h:43
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition CmSpatialVector.h:134
Definition DyVArticulation.h:102
Definition DySolverCore.h:155
Definition DyThresholdTable.h:52
Struct that the solver uses to store the state and other properties of a body.
Definition PxSolverDefs.h:74
Struct that the solver uses to store velocity updates for a body.
Definition PxSolverDefs.h:55
Constraint descriptor used inside the solver.
Definition PxSolverDefs.h:108
Definition PxvDynamics.h:74