241 struct SimpleBodyPair
259 PX_FORCE_INLINE void setElapsedTime(
const PxReal t) { mDt = t; mOneOverDt = t > 0.0f ? 1.0f/t : 0.0f; }
261 void setBounceThresholdVelocity(
const PxReal t);
262 PxReal getBounceThresholdVelocity()
const;
272 PX_FORCE_INLINE void setPCM(
bool enabled) { mLLContext->setPCM(enabled); }
273 PX_FORCE_INLINE void setContactCache(
bool enabled) { mLLContext->setContactCache(enabled); }
278 void addBody(
BodyCore&,
NpShape*
const *shapes, PxU32 nbShapes,
size_t shapePtrOffset,
PxBounds3* uninflatedBounds,
bool compound);
336 void updateBodySim(
BodySim& sim);
338 PX_FORCE_INLINE PxU32 getNbArticulations()
const {
return mArticulations.size(); }
341#if PX_SUPPORT_GPU_PHYSX
342 PX_FORCE_INLINE PxU32 getNbSoftBodies()
const {
return mSoftBodies.size(); }
345 PX_FORCE_INLINE PxU32 getNbFEMCloths()
const {
return mFEMCloths.size(); }
348 PX_FORCE_INLINE PxU32 getNbParticleSystems()
const {
return mParticleSystems.size(); }
351 PX_FORCE_INLINE PxU32 getNbHairSystems()
const {
return mHairSystems.size(); }
355 PX_FORCE_INLINE PxU32 getNbConstraints()
const {
return mConstraints.size(); }
372 void setCCDMaxPasses(PxU32 ccdMaxPasses);
373 PxU32 getCCDMaxPasses()
const;
375 void setCCDThreshold(PxReal t);
376 PxReal getCCDThreshold()
const;
383 void finishBroadPhase(
PxBaseTask* continuation);
384 void finishBroadPhaseStage2(
const PxU32 ccdPass);
385 void preallocateContactManagers(
PxBaseTask* continuation);
387 void islandInsertion(
PxBaseTask* continuation);
388 void registerContactManagers(
PxBaseTask* continuation);
389 void registerInteractions(
PxBaseTask* continuation);
390 void registerSceneInteractions(
PxBaseTask* continuation);
392 void secondPassNarrowPhase(
PxBaseTask* continuation);
398 void setSolverBatchSize(PxU32 solverBatchSize);
399 PxU32 getSolverBatchSize()
const;
401 void setSolverArticBatchSize(PxU32 solverBatchSize);
402 PxU32 getSolverArticBatchSize()
const;
404 void setDynamicsDirty();
408 mVisualizationParameterChanged =
true;
409 mLLContext->setVisualizationParameter(param, value);
413 PX_FORCE_INLINE void setVisualizationCullingBox(
const PxBounds3& box) { mLLContext->setVisualizationCullingBox(box); }
414 PX_FORCE_INLINE const PxBounds3& getVisualizationCullingBox()
const {
return mLLContext->getVisualizationCullingBox(); }
415 PX_FORCE_INLINE PxReal getVisualizationScale()
const {
return mLLContext->getRenderScale(); }
418 void simulate(PxReal timeStep,
PxBaseTask* continuation);
419 void advance(PxReal timeStep,
PxBaseTask* continuation);
420 void collide(PxReal timeStep,
PxBaseTask* continuation);
421 void endSimulation();
422 void flush(
bool sendPendingReports);
423 void fireBrokenConstraintCallbacks();
424 void fireTriggerCallbacks();
425 void fireQueuedContactCallbacks();
426 void fireOnAdvanceCallback();
429 getQueuedContactPairHeaders();
431 bool fireOutOfBoundsCallbacks();
432 void prepareOutOfBoundsCallbacks();
433 void postCallbacksPreSync();
434 void postReportsCleanup();
435 void fireCallbacksPostSync();
438 PxU32 getDefaultContactReportStreamBufferSize()
const;
440 void setCCDMaxSeparation(PxReal separation);
441 PxReal getCCDMaxSeparation()
const;
442 void setMaxBiasCoefficient(PxReal coeff);
443 PxReal getMaxBiasCoefficient()
const;
444 void setFrictionOffsetThreshold(PxReal t);
445 PxReal getFrictionOffsetThreshold()
const;
446 void setFrictionCorrelationDistance(PxReal t);
447 PxReal getFrictionCorrelationDistance()
const;
455 void setNbContactDataBlocks(PxU32 blockCount);
456 PxU32 getNbContactDataBlocksUsed()
const;
457 PxU32 getMaxNbContactDataBlocksUsed()
const;
458 PxU32 getMaxNbConstraintDataBlocksUsed()
const;
460 void setMaxArticulationLinks(
const PxU32 maxLinks) { mMaxNbArticulationLinks = maxLinks; }
461 PxU32 getMaxArticulationLinks()
const {
return mMaxNbArticulationLinks; }
463 void setScratchBlock(
void* addr, PxU32 size);
470 void buildActiveActors();
471 void buildActiveAndFrozenActors();
472 PxActor** getActiveActors(PxU32& nbActorsOut);
473 void setActiveActors(
PxActor** actors, PxU32 nbActors);
475 PxActor** getActiveSoftBodyActors(PxU32& nbActorsOut);
476 void setActiveSoftBodyActors(
PxActor** actors, PxU32 nbActors);
481 PxActor** getFrozenActors(PxU32& nbActorsOut);
487 PxTaskManager* getTaskManagerPtr()
const {
return mTaskManager; }
488 PxCudaContextManager* getCudaContextManager()
const {
return mCudaContextManager; }
490 void shiftOrigin(
const PxVec3& shift);
494 PX_FORCE_INLINE bool isCollisionPhaseActive()
const {
return mIsCollisionPhaseActive; }
495 PX_FORCE_INLINE void setCollisionPhaseToActive() { PX_ASSERT(!mIsCollisionPhaseActive); mIsCollisionPhaseActive =
true; }
496 PX_FORCE_INLINE void setCollisionPhaseToInactive() { PX_ASSERT(mIsCollisionPhaseActive); mIsCollisionPhaseActive =
false; }
506 void preAllocate(PxU32 nbStatics, PxU32 nbBodies, PxU32 nbStaticShapes, PxU32 nbDynamicShapes);
524 PX_FORCE_INLINE SimulationStage::Enum getSimulationStage()
const {
return mSimulationStage; }
525 PX_FORCE_INLINE void setSimulationStage(SimulationStage::Enum stage) { mSimulationStage = stage; }
528 void removeShape_(
ShapeSim&,
bool wakeOnLostTouch);
530 void registerShapeInNphase(
RigidCore* rigidCore,
const ShapeCore& shapeCore,
const PxU32 transformCacheID);
531 void unregisterShapeFromNphase(
const ShapeCore& shapeCore,
const PxU32 transformCacheID);
533 void notifyNphaseOnUpdateShapeMaterial(
const ShapeCore& shapeCore);
537 PX_FORCE_INLINE PxU32 getNumActiveBodies()
const {
return mActiveBodies.size(); }
539#if PX_SUPPORT_GPU_PHYSX
541 PX_FORCE_INLINE PxU32 getNumActiveSoftBodies()
const {
return mActiveSoftBodies.size(); }
544 PX_FORCE_INLINE PxU32 getNumActiveFEMCloths()
const {
return mActiveFEMCloths.size(); }
547 PX_FORCE_INLINE PxU32 getNumActiveHairSystems()
const {
return mActiveHairSystems.size(); }
551 PX_FORCE_INLINE PxU32 getNumActiveCompoundBodies()
const {
return mActiveCompoundBodies.size(); }
553 PX_FORCE_INLINE PxU32 getNbInteractions(InteractionType::Enum type)
const {
return mInteractions[type].size(); }
554 PX_FORCE_INLINE PxU32 getNbActiveInteractions(InteractionType::Enum type)
const {
return mActiveInteractionCount[type]; }
559 void registerInteraction(
Interaction* interaction,
bool active);
560 void unregisterInteraction(
Interaction* interaction);
562 void notifyInteractionActivated(
Interaction* interaction);
563 void notifyInteractionDeactivated(
Interaction* interaction);
566 void** allocatePointerBlock(PxU32 size);
567 void deallocatePointerBlock(
void**, PxU32 size);
570 PX_FORCE_INLINE PxU32 getActiveKinematicBodiesCount()
const {
return mActiveKinematicBodyCount; }
576 PX_FORCE_INLINE PxU32 getActiveDynamicBodiesCount()
const {
return mActiveBodies.size() - mActiveKinematicBodyCount; }
579 PX_FORCE_INLINE BodyCore*
const* getActiveDynamicBodies()
const {
return mActiveBodies.begin() + mActiveKinematicBodyCount; }
581#if PX_SUPPORT_GPU_PHYSX
589 void swapInteractionArrayIndices(PxU32 id1, PxU32 id2, InteractionType::Enum type);
591 PxReal getLengthScale()
const;
598 void addToActiveList(
ActorSim& actor);
599 void removeFromActiveList(
ActorSim& actor);
600 void removeFromActiveCompoundBodyList(
BodySim& actor);
601 void swapInActiveBodyList(
BodySim& body);
609 void raiseSceneFlag(SceneInternalFlag::Enum flag) { mInternalFlags |= flag; }
612 void onBodyWakeUp(
BodySim* body);
613 void onBodySleep(
BodySim* body);
619 PxU32 createAggregate(
void* userData, PxU32 maxNumShapes, PxAggregateFilterHint filterHint);
621 void deleteAggregate(PxU32
id);
626#if PX_SUPPORT_GPU_PHYSX
644#if PX_SUPPORT_GPU_PHYSX
664 void setFilterShaderData(
const void* data, PxU32 dataSize);
665 PX_FORCE_INLINE const void* getFilterShaderDataFast()
const {
return mFilterShaderData; }
666 PX_FORCE_INLINE PxU32 getFilterShaderDataSizeFast()
const {
return mFilterShaderDataSize; }
673 PX_FORCE_INLINE PxU32 getReportShapePairTimeStamp()
const {
return mReportShapePairTimeStamp; }
679 PX_FORCE_INLINE bool readFlag(SceneInternalFlag::Enum flag)
const {
return (mInternalFlags & flag) != 0; }
684 void checkConstraintBreakage();
687 getTriggerBufferExtraData() {
return *mTriggerBufferExtraData; }
693 PX_FORCE_INLINE void markReleasedBodyIDForLostTouch(PxU32
id) { mLostTouchPairsDeletedBodyIDs.growAndSet(
id); }
694 void resizeReleasedBodyIDMaps(PxU32 maxActors, PxU32 numActors);
701 PX_FORCE_INLINE void updateContactDistance(PxU32 idx, PxReal distance) { (*mContactDistance)[idx] = distance; mHasContactDistanceChanged =
true; }
704 PX_FORCE_INLINE BodyCore*
const* getSleepBodiesArray(PxU32& count) { count = mSleepBodies.size();
return mSleepBodies.getEntries(); }
706 PX_FORCE_INLINE SoftBodyCore*
const* getSleepSoftBodiesArray(PxU32& count) { count = mSleepSoftBodies.size();
return mSleepSoftBodies.getEntries(); }
712 PX_FORCE_INLINE bool getStabilizationEnabled()
const {
return mEnableStabilization; }
714 PX_FORCE_INLINE void setPostSolverVelocityNeeded() { mContactReportsNeedPostSolverVelocity =
true; }
720 void* allocateConstraintBlock(PxU32 size);
721 void deallocateConstraintBlock(
void* addr, PxU32 size);
723 void stepSetupCollide(
PxBaseTask* continuation);
724 PX_FORCE_INLINE void addToPosePreviewList(
BodySim& b) { PX_ASSERT(!mPosePreviewBodies.contains(&b)); mPosePreviewBodies.insert(&b); }
725 PX_FORCE_INLINE void removeFromPosePreviewList(
BodySim& b) { PX_ASSERT(mPosePreviewBodies.contains(&b)); mPosePreviewBodies.erase(&b); }
730 PX_FORCE_INLINE void setSpeculativeCCDRigidBody(
const PxU32 index) { mSpeculativeCCDRigidBodyBitMap.growAndSet(index); }
731 PX_FORCE_INLINE void resetSpeculativeCCDRigidBody(
const PxU32 index) {
if(index < mSpeculativeCCDRigidBodyBitMap.size()) mSpeculativeCCDRigidBodyBitMap.reset(index); }
733 PX_FORCE_INLINE void setSpeculativeCCDArticulationLink(
const PxU32 index) { mSpeculativeCDDArticulationBitMap.growAndSet(index); }
734 PX_FORCE_INLINE void resetSpeculativeCCDArticulationLink(
const PxU32 index) {
if(index < mSpeculativeCDDArticulationBitMap.size()) mSpeculativeCDDArticulationBitMap.reset(index); }
737 PX_FORCE_INLINE bool isUsingGpuDynamicsOrBp()
const {
return mUseGpuBp || mUseGpuDynamics; }
738 PX_FORCE_INLINE bool isUsingGpuDynamicsAndBp()
const {
return mUseGpuBp && mUseGpuDynamics; }
739 PX_FORCE_INLINE bool isUsingGpuDynamics()
const {
return mUseGpuDynamics; }
743 PX_FORCE_INLINE void increaseNumKinematicsCounter() { mNbRigidKinematic++; }
744 PX_FORCE_INLINE void decreaseNumKinematicsCounter() { mNbRigidKinematic--; }
745 PX_FORCE_INLINE void increaseNumDynamicsCounter() { mNbRigidDynamics++; }
746 PX_FORCE_INLINE void decreaseNumDynamicsCounter() { mNbRigidDynamics--; }
767 void addSoftBodyFilters(
SoftBodyCore& core,
SoftBodySim& sim, PxU32* tetIndices0, PxU32* tetIndices1, PxU32 tetIndicesSize);
768 void removeSoftBodyFilters(
SoftBodyCore& core,
SoftBodySim& sim, PxU32* tetIndices0, PxU32* tetIndices1, PxU32 tetIndicesSize);
809 void activateEdgesInternal(
const IG::EdgeIndex* activatingEdges,
const PxU32 nbActivatingEdges);
810 void releaseConstraints(
bool endOfScene);
811 PX_INLINE void clearBrokenConstraintBuffer();
815 void prepareCollide();
821 void kinematicsSetup(
PxBaseTask* continuation);
822 void stepSetupSolve(
PxBaseTask* continuation);
826 void processNarrowPhaseTouchEvents();
827 void processNarrowPhaseTouchEventsStage2(
PxBaseTask*);
829 void processNarrowPhaseLostTouchEvents(
PxBaseTask*);
830 void processNarrowPhaseLostTouchEventsIslands(
PxBaseTask*);
831 void processLostTouchPairs();
832 void integrateKinematicPose();
836 void checkForceThresholdContactEvents(
const PxU32 ccdPass);
839 void putObjectsToSleep(PxU32 infoFlag);
840 void wakeObjectsUp(PxU32 infoFlag);
842 void collectPostSolverVelocitiesBeforeCCD();
844 void clearSleepWakeBodies(
void);
849#if PX_SUPPORT_GPU_PHYSX
855 PX_INLINE void cleanUpSleepHairSystems();
856 PX_INLINE void cleanUpWokenHairSystems();
864#if PX_SUPPORT_GPU_PHYSX
880 PxU32 mActiveKinematicBodyCount;
881 PxU32 mActiveDynamicBodyCount;
885 PxU32 mActiveKinematicsCopyCapacity;
887#if PX_SUPPORT_GPU_PHYSX
894 PxU32 mActiveInteractionCount[InteractionType::eTRACKED_IN_SCENE_COUNT];
896 template <
typename T, PxU32 size>
899 PxU8 mem[
sizeof(T)*size];
903 typedef Block<void*, 8> PointerBlock8;
904 typedef Block<void*, 16> PointerBlock16;
905 typedef Block<void*, 32> PointerBlock32;
915 PxI32 mNumFastMovingShapes;
927#if PX_SUPPORT_GPU_PHYSX
939 PxU32 mBodyGravityDirty;
942 mQueuedContactPairHeaders;
949 PxU32 mReportShapePairTimeStamp;
958 bool mHasContactDistanceChanged;
969#if PX_SUPPORT_GPU_PHYSX
980 typedef Block<PxU8, 128> MemBlock128;
981 typedef Block<PxU8, 256> MemBlock256;
982 typedef Block<PxU8, 384> MemBlock384;
992 void* mFilterShaderData;
993 PxU32 mFilterShaderDataSize;
994 PxU32 mFilterShaderDataCapacity;
1008 bool mWokeBodyListValid;
1009 bool mSleepBodyListValid;
1010 bool mWokeSoftBodyListValid;
1011 bool mSleepSoftBodyListValid;
1012 bool mWokeHairSystemListValid;
1013 bool mSleepHairSystemListValid;
1014 const bool mEnableStabilization;
1019#if PX_SUPPORT_GPU_PHYSX
1034 PxU32 mInternalFlags;
1048#if PX_SUPPORT_GPU_PHYSX
1049 LLSoftBodyPool* mLLSoftBodyPool;
1050 LLFEMClothPool* mLLFEMClothPool;
1051 LLParticleSystemPool* mLLParticleSystemPool;
1052 LLHairSystemPool* mLLHairSystemPool;
1065 PxBitMap mLostTouchPairsDeletedBodyIDs;
1077 PxU32 mDominanceBitMatrix[PX_MAX_DOMINANCE_GROUP];
1079 bool mVisualizationParameterChanged;
1081 PxU32 mMaxNbArticulationLinks;
1084 PxU32 mNbRigidStatics;
1085 PxU32 mNbRigidDynamics;
1086 PxU32 mNbRigidKinematic;
1090 PxU32 mNumDeactivatingNodes[IG::Node::eTYPE_COUNT];
1094 void broadPhaseFirstPass(
PxBaseTask* continuation);
1095 void broadPhaseSecondPass(
PxBaseTask* continuation);
1096 void updateBroadPhase(
PxBaseTask* continuation);
1098 void postBroadPhase(
PxBaseTask* continuation);
1099 void postBroadPhaseContinuation(
PxBaseTask* continuation);
1100 void preRigidBodyNarrowPhase(
PxBaseTask* continuation);
1101 void postBroadPhaseStage2(
PxBaseTask* continuation);
1102 void postBroadPhaseStage3(
PxBaseTask* continuation);
1103 void updateBoundsAndShapes(
PxBaseTask* continuation);
1104 void rigidBodyNarrowPhase(
PxBaseTask* continuation);
1105 void unblockNarrowPhase(
PxBaseTask* continuation);
1107 void processLostSolverPatches(
PxBaseTask* continuation);
1108 void processFoundSolverPatches(
PxBaseTask* continuation);
1109 void postIslandGen(
PxBaseTask* continuation);
1114 void updateSimulationController(
PxBaseTask* continuation);
1115 void updateDynamics(
PxBaseTask* continuation);
1124 void constraintProjection(
PxBaseTask* continuation);
1125 void afterIntegration(
PxBaseTask* continuation);
1127 void ccdBroadPhaseAABB(
PxBaseTask* continuation);
1128 void ccdBroadPhase(
PxBaseTask* continuation);
1129 void updateCCDMultiPass(
PxBaseTask* continuation);
1130 void updateCCDSinglePass(
PxBaseTask* continuation);
1131 void updateCCDSinglePassStage2(
PxBaseTask* continuation);
1132 void updateCCDSinglePassStage3(
PxBaseTask* continuation);
1133 void finalizationPhase(
PxBaseTask* continuation);
1135 void postNarrowPhase(
PxBaseTask* continuation);
1142 void updateContactDistances(
PxBaseTask* continuation);
1172 &Scene::processNarrowPhaseLostTouchEventsIslands> mProcessNarrowPhaseLostTouchTasks;
1174 &Scene::processNarrowPhaseLostTouchEvents> mProcessNPLostTouchEvents;
1205 PxCudaContextManager* mCudaContextManager;
1207 bool mContactReportsNeedPostSolverVelocity;
1208 bool mUseGpuDynamics;
1212 SimulationStage::Enum mSimulationStage;
1224 PxBitMap mSpeculativeCCDRigidBodyBitMap;
1225 PxBitMap mSpeculativeCDDArticulationBitMap;
1227 bool mIsCollisionPhaseActive;
1233 typedef void(*SleepingStateChangedCallback)(
PxActor*, bool);
1234 SleepingStateChangedCallback mOnSleepingStateChanged;