29#include "geometry/PxGeometry.h"
30#include "foundation/PxHashMap.h"
31#include "foundation/PxUserAllocated.h"
32#include "GuCCDSweepConvexMesh.h"
33#include "PxsIslandSim.h"
38#define CCD_DEBUG_PRINTS 0
39#define CCD_POST_DEPENETRATE_DIST 0.001f
40#define CCD_ROTATION_LOCKING 0
41#define CCD_MIN_TIME_LEFT 0.01f
43#define DEBUG_RENDER_CCD 0
47 extern void printCCDDebug(
const char* msg,
const PxsRigidBody* atom0,
PxGeometryType::Enum g0,
bool printPtr =
true);
48 extern void printShape(PxsRigidBody* atom0,
PxGeometryType::Enum g0,
const char* annotation, PxReal dt, PxU32 pass,
bool printPtr =
true);
50#define PRINTCCDSHAPE(x) printShape x
51#define PRINTCCDDEBUG(x) printCCDDebug x
53#define PRINTCCDSHAPE(x)
54#define PRINTCCDDEBUG(x)
59 float computeCCDThreshold(
const PxGeometry& geometry);
71class PxsContactManager;
73class PxCCDContactModifyCallback;
74class PxcNpThreadContext;
76class PxvNphaseImplementationContext;
80 class ThresholdStream;
127 bool mHasAnyPassDone;
132 PxU32 mNbInteractionsThisPass;
164 overlap->mNext = mOverlappingObjects;
165 mOverlappingObjects = overlap;
176template<
typename T,
int BLOCK_SIZE>
190 BlockInfo(
Block* aBlock, PxU32 aCount) : block(aBlock), count(aCount) {}
214 for (PxU32 i = 0; i < blocks.
size(); i++)
216 PX_DELETE(blocks[i].block);
227 for (PxU32 i = 0; i < blocks.
size(); i++)
229 PX_DELETE(blocks[i].block);
251 PxU32 numBlocks = blocks.
size();
274 PxU32 numBlocks = blocks.
size();
322 PX_ASSERT(index/BLOCK_SIZE < blocks.
size());
323 PX_ASSERT(index%BLOCK_SIZE < blocks[index/BLOCK_SIZE].count);
324 return blocks[index/BLOCK_SIZE].block->items[index%BLOCK_SIZE];
350 PxReal mPenetrationPostStep;
356 bool mIsEarliestToiHit;
359 PxU16 mMaterialIndex0;
360 PxU16 mMaterialIndex1;
361 PxReal mDynamicFriction;
362 PxReal mStaticFriction;
365 PxReal mAppliedForce;
481 PX_FORCE_INLINE PxReal getCCDThreshold()
const {
return mCCDThreshold; }
508 void updateCCD(PxReal dt, PxBaseTask* continuation, IG::IslandSim& islandSim,
bool disableResweep, PxI32 numFastMovingShapes);
525 void verifyCCDBegin();
536 void postCCDSweep(PxBaseTask* continuation);
541 void postCCDAdvance(PxBaseTask* continuation);
546 void postCCDDepenetrate(PxBaseTask* continuation);
548 typedef Cm::DelegateTask<PxsCCDContext, &PxsCCDContext::postCCDSweep> PostCCDSweepTask;
549 typedef Cm::DelegateTask<PxsCCDContext, &PxsCCDContext::postCCDAdvance> PostCCDAdvanceTask;
550 typedef Cm::DelegateTask<PxsCCDContext, &PxsCCDContext::postCCDDepenetrate> PostCCDDepenetrateTask;
552 PostCCDSweepTask mPostCCDSweepTask;
553 PostCCDAdvanceTask mPostCCDAdvanceTask;
554 PostCCDDepenetrateTask mPostCCDDepenetrateTask;
556 PxCCDContactModifyCallback* mCCDContactModifyCallback;
559 bool mDisableCCDResweep;
561 PxI32 mSweepTotalHits;
567 PxArray<PxsCCDBody*> mIslandBodies;
568 PxArray<PxU16> mIslandSizes;
569 PxArray<PxsRigidBody*> mUpdatedCCDBodies;
570 PxHashMap<PxsRigidShapePair, PxsCCDShape*> mMap;
575 PxArray<PxsCCDPair*> mCCDPtrPairs;
577 PxArray<PxU32> mCCDIslandHistogram;
579 PxcNpThreadContext* mCCDThreadContext;
581 PxU32 mCCDPairsPerBatch;
584 PxsContext* mContext;
585 Dy::ThresholdStream& mThresholdStream;
587 PxvNphaseImplementationContext& mNphaseContext;
591 PxReal mCCDThreshold;
595 PX_NOCOPY(PxsCCDContext)
Definition CmSpatialVector.h:46
Definition DyThresholdTable.h:81
PX_FORCE_INLINE uint32_t size() const
Definition PxArray.h:242
PX_INLINE void clear()
Definition PxArray.h:250
PX_FORCE_INLINE T & pushBack(const T &a)
Definition PxArray.h:296
PX_INLINE T popBack()
Definition PxArray.h:311
PxNodeIndex.
Definition PxNodeIndex.h:51
Definition PxBasicTemplates.h:67
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
Definition PxcNpThreadContext.h:119
CCD context object.
Definition PxsCCD.h:423
void resetContactManagers()
Resets the CCD contact state in any contact managers that previously had a reported CCD touch....
Definition PxsCCD.cpp:1379
PX_FORCE_INLINE void setCCDContactModifyCallback(PxCCDContactModifyCallback *c)
Sets the CCD contact modification callback.
Definition PxsCCD.h:444
PX_FORCE_INLINE PxsRigidBody *const * getUpdatedBodies() const
Returns The update bodies array.
Definition PxsCCD.h:474
PX_FORCE_INLINE PxI32 getNumSweepHits() const
Returns The number of swept hits reported.
Definition PxsCCD.h:464
PX_FORCE_INLINE void setCCDMaxPasses(PxU32 ccdMaxPasses)
Sets the maximum number of CCD passes.
Definition PxsCCD.h:454
PX_FORCE_INLINE PxU32 getCurrentCCDPass() const
Returns the current CCD pass.
Definition PxsCCD.h:459
PX_FORCE_INLINE void clearUpdatedBodies()
Returns Clears the updated bodies array.
Definition PxsCCD.h:479
PX_FORCE_INLINE PxCCDContactModifyCallback * getCCDContactModifyCallback() const
Returns the CCD contact modification callback.
Definition PxsCCD.h:439
PX_FORCE_INLINE PxU32 getCCDMaxPasses() const
Returns the maximum number of CCD passes.
Definition PxsCCD.h:449
void runCCDModifiableContact(PxModifiableContact *PX_RESTRICT contacts, PxU32 contactCount, const PxsShapeCore *PX_RESTRICT shapeCore0, const PxsShapeCore *PX_RESTRICT shapeCore1, const PxsRigidCore *PX_RESTRICT rigidCore0, const PxsRigidCore *PX_RESTRICT rigidCore1, const PxsRigidBody *PX_RESTRICT rigid0, const PxsRigidBody *PX_RESTRICT rigid1)
Runs the CCD contact modification.
Definition PxsCCD.cpp:2122
~PxsCCDContext()
Destructor for PxsCCDContext.
Definition PxsCCD.cpp:337
PX_FORCE_INLINE PxU32 getNumUpdatedBodies() const
Returns The number of updated bodies.
Definition PxsCCD.h:469
void updateCCDBegin()
Signals the beginning of a CCD multi-pass update.
Definition PxsCCD.cpp:1319
void updateCCD(PxReal dt, PxBaseTask *continuation, IG::IslandSim &islandSim, bool disableResweep, PxI32 numFastMovingShapes)
Performs a single CCD update This occurs after broad phase and is responsible for creating islands,...
Definition PxsCCD.cpp:1425
Definition PxsContext.h:92
Definition PxsRigidBody.h:43
Definition PxvNphaseImplementationContext.h:120
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxPair< const PxsRigidCore *, const PxsShapeCore * > PxsRigidShapePair
Pair structure to be able to look-up a rigid body-shape pair in a map.
Definition PxsCCD.h:417
PxsCCDBlockArray< PxsCCDPair, 128 > PxsCCDPairArray
Block array of CCD pairs.
Definition PxsCCD.h:404
PxsCCDBlockArray< PxsCCDOverlap, 128 > PxsCCDOverlapArray
Block array of CCD overlaps.
Definition PxsCCD.h:408
PxsCCDBlockArray< PxsCCDBody, 128 > PxsCCDBodyArray
Block array of CCD bodies.
Definition PxsCCD.h:400
PxsCCDBlockArray< PxsCCDShape, 128 > PxsCCDShapeArray
Block array of CCD shapes.
Definition PxsCCD.h:412
Definition GuCCDSweepConvexMesh.h:89
Enum
Definition PxGeometry.h:52
A header for a block of data.
Definition PxsCCD.h:187
A block of data.
Definition PxsCCD.h:182
a container class used in the CCD that minimizes frequency of hitting the allocator.
Definition PxsCCD.h:178
void clear_NoDelete()
Clears this block array but does not release the memory.
Definition PxsCCD.h:239
T & pushBack(T &data)
Pushes a new element onto the back of this array, intitializing it to match the data.
Definition PxsCCD.h:272
void popBack()
Pops the last element from the list.
Definition PxsCCD.h:293
T & pushBack()
Push a new element onto the back of the block array.
Definition PxsCCD.h:249
void clear()
Clears this block array.
Definition PxsCCD.h:225
PxU32 size() const
Returns the current size of the array.
Definition PxsCCD.h:310
T & operator[](PxU32 index) const
Returns the element at a given index in the array.
Definition PxsCCD.h:320
PxsCCDBlockArray()
Constructor.
Definition PxsCCD.h:204
~PxsCCDBlockArray()
Destructor.
Definition PxsCCD.h:212
PxU32 currentBlock
The current block.
Definition PxsCCD.h:199
Structure to represent a body in the CCD system.
Definition PxsCCD.h:123
bool overlaps(PxsCCDBody *body) const
Tests whether this body has already registered an overlap with a given body.
Definition PxsCCD.h:145
void addOverlap(PxsCCDOverlap *overlap)
Registers an overlap with a given body.
Definition PxsCCD.h:162
PX_FORCE_INLINE PxU32 getIndex() const
Returns the CCD body's index.
Definition PxsCCD.h:138
structure to represent interactions between a given body and another body.
Definition PxsCCD.h:87
A structure to represent a potential CCD interaction between a pair of shapes.
Definition PxsCCD.h:332
bool sweepAdvanceToToi(PxReal dt, bool clipTrajectoryToToi)
Advances this pair to the TOI.
Definition PxsCCD.cpp:644
PxReal sweepFindToi(PxcNpThreadContext &threadContext, PxReal dt, PxU32 pass, PxReal ccdThreshold)
Perform a precise sweep for this pair.
Definition PxsCCD.cpp:358
E_TOIType
Defines whether this is an estimated TOI or an accurate TOI.
Definition PxsCCD.h:340
PxReal sweepEstimateToi(PxReal ccdThreshold)
Performs a sweep estimation for this pair.
Definition PxsCCD.cpp:570
void updateShapes()
Updates the transforms of the shapes involved in this pair.
Definition PxsCCD.cpp:525
Temporary CCD representation for a shape.
Definition PxsCCD.h:101
PxTransform getLastCCDAbsPose(const PxsRigidBody *atom) const
Returns the world-space previous pose for this shape.
Definition PxsCCD.cpp:351
PxTransform getAbsPose(const PxsRigidBody *atom) const
Returns the world-space pose for this shape.
Definition PxsCCD.cpp:341
Definition PxvDynamics.h:48
Definition PxvGeometry.h:221