diff options
| author | Sheikh Dawood Abdul Ajees <[email protected]> | 2017-09-15 15:41:57 -0500 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <[email protected]> | 2017-09-15 15:41:57 -0500 |
| commit | d1c812f1162e5fdb13c215792725b2591d7428f5 (patch) | |
| tree | 407056c45c7e9320c48fca6a3697d81a061c4ea0 /PhysX_3.4/Source/SimulationController/src | |
| parent | PhysX 3.4, APEX 1.4 patch release @22121272 (diff) | |
| download | physx-3.4-d1c812f1162e5fdb13c215792725b2591d7428f5.tar.xz physx-3.4-d1c812f1162e5fdb13c215792725b2591d7428f5.zip | |
PhysX 3.4.1, APEX 1.4.1 Release @22845541v3.4.1
Diffstat (limited to 'PhysX_3.4/Source/SimulationController/src')
9 files changed, 103 insertions, 61 deletions
diff --git a/PhysX_3.4/Source/SimulationController/src/ScBodySim.cpp b/PhysX_3.4/Source/SimulationController/src/ScBodySim.cpp index 4ce57c13..579c5438 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScBodySim.cpp +++ b/PhysX_3.4/Source/SimulationController/src/ScBodySim.cpp @@ -1012,9 +1012,3 @@ void Sc::BodySim::freezeTransforms(Cm::BitMapPinned* shapeChangedMap) } } -void Sc::BodySim::postShapeChange(bool /*asPartOfActorTransformChange*/) -{ - // shape geometry or transform changes can cause connectivity changes and thus a second island gen pass is needed. - /*if (!asPartOfActorTransformChange) - internalNotifySecondIslandGenPassNeeded();*/ -} diff --git a/PhysX_3.4/Source/SimulationController/src/ScBodySim.h b/PhysX_3.4/Source/SimulationController/src/ScBodySim.h index 24f1591a..375e58b9 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScBodySim.h +++ b/PhysX_3.4/Source/SimulationController/src/ScBodySim.h @@ -228,7 +228,6 @@ namespace Sc return (getFlagsFast()&ktFlags) == ktFlags; } - void postShapeChange(bool asPartOfActorTransformChange); void createSqBounds(); void destroySqBounds(); void freezeTransforms(Cm::BitMapPinned* shapeChangedMap); diff --git a/PhysX_3.4/Source/SimulationController/src/ScElementSim.h b/PhysX_3.4/Source/SimulationController/src/ScElementSim.h index e04c136d..aace946b 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScElementSim.h +++ b/PhysX_3.4/Source/SimulationController/src/ScElementSim.h @@ -105,7 +105,6 @@ namespace Sc // Get an iterator to the interactions connected to the element PX_FORCE_INLINE ElementInteractionIterator getElemInteractions() const { return ElementInteractionIterator(*this, mActor.getActorInteractionCount(), mActor.getActorInteractions()); } PX_FORCE_INLINE ElementInteractionReverseIterator getElemInteractionsReverse() const { return ElementInteractionReverseIterator(*this, mActor.getActorInteractionCount(), mActor.getActorInteractions()); } - PX_FORCE_INLINE PxU32 getElemInteractionCount() const { return mActor.getActorInteractionCount(); } PX_FORCE_INLINE ActorSim& getActor() const { return mActor; } diff --git a/PhysX_3.4/Source/SimulationController/src/ScRigidCore.cpp b/PhysX_3.4/Source/SimulationController/src/ScRigidCore.cpp index 4a6c6def..824f2ce9 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScRigidCore.cpp +++ b/PhysX_3.4/Source/SimulationController/src/ScRigidCore.cpp @@ -76,13 +76,13 @@ void Sc::RigidCore::onShapeChange(Sc::ShapeCore& shape, ShapeChangeNotifyFlags n Sc::ShapeSim& s = sim->getSimForShape(shape); if(notifyFlags & ShapeChangeNotifyFlag::eGEOMETRY) - s.onVolumeOrTransformChange(false, forceBoundsUpdate); + s.onVolumeOrTransformChange(forceBoundsUpdate); if(notifyFlags & ShapeChangeNotifyFlag::eMATERIAL) s.onMaterialChange(); if(notifyFlags & ShapeChangeNotifyFlag::eRESET_FILTERING) s.onResetFiltering(); if(notifyFlags & ShapeChangeNotifyFlag::eSHAPE2BODY) - s.onVolumeOrTransformChange(false, forceBoundsUpdate); + s.onVolumeOrTransformChange(forceBoundsUpdate); if(notifyFlags & ShapeChangeNotifyFlag::eFILTERDATA) s.onFilterDataChange(); if(notifyFlags & ShapeChangeNotifyFlag::eFLAGS) diff --git a/PhysX_3.4/Source/SimulationController/src/ScRigidSim.cpp b/PhysX_3.4/Source/SimulationController/src/ScRigidSim.cpp index dd4829bd..573f7bb1 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScRigidSim.cpp +++ b/PhysX_3.4/Source/SimulationController/src/ScRigidSim.cpp @@ -68,12 +68,31 @@ Sc::RigidSim::~RigidSim() scScene.getRigidIDTracker().releaseID(mRigidId); } +bool notifyActorInteractionsOfTransformChange(Sc::ActorSim& actor); void Sc::RigidSim::notifyShapesOfTransformChange() { - for(ElementSim* e = getElements_(); e!=0; e = e->mNextInActor) + if(0) { - if(e->getElementType() == ElementType::eSHAPE) - static_cast<Sc::ShapeSim*>(e)->onVolumeOrTransformChange(true); + for(ElementSim* e = getElements_(); e!=0; e = e->mNextInActor) + { + if(e->getElementType() == ElementType::eSHAPE) + static_cast<Sc::ShapeSim*>(e)->onVolumeOrTransformChange(true); + } + } + else + { + const bool isDynamic = notifyActorInteractionsOfTransformChange(*this); + + ElementSim* current = getElements_(); + while(current) + { + if(current->getElementType() == ElementType::eSHAPE) + { + ShapeSim* sim = static_cast<ShapeSim*>(current); + sim->markBoundsForUpdate(false, isDynamic); + } + current = current->mNextInActor; + } } } diff --git a/PhysX_3.4/Source/SimulationController/src/ScScene.cpp b/PhysX_3.4/Source/SimulationController/src/ScScene.cpp index 1f161f18..2099b86d 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScScene.cpp +++ b/PhysX_3.4/Source/SimulationController/src/ScScene.cpp @@ -619,6 +619,7 @@ Sc::Scene::Scene(const PxSceneDesc& desc, PxU64 contextID) : mCollideStep (contextID, this, "ScScene.collideStep"), mTaskPool (16384), mContactReportsNeedPostSolverVelocity(false), + mUseGpuRigidBodies (false), mSimulationStage (SimulationStage::eCOMPLETE), mTmpConstraintGroupRootBuffer (NULL), mPosePreviewBodies (PX_DEBUG_EXP("scenePosePreviewBodies")) @@ -694,6 +695,8 @@ Sc::Scene::Scene(const PxSceneDesc& desc, PxU64 contextID) : } #endif + mUseGpuRigidBodies = useGpuBroadphase || useGpuDynamics; + mLLContext = PX_NEW(PxsContext)(desc, mTaskManager, mTaskPool, contextID); if (mLLContext == 0) @@ -773,7 +776,7 @@ Sc::Scene::Scene(const PxSceneDesc& desc, PxU64 contextID) : mDynamicsContext = createDynamicsContext (&mLLContext->getNpMemBlockPool(), mLLContext->getScratchAllocator(), mLLContext->getTaskPool(), mLLContext->getSimStats(), &mLLContext->getTaskManager(), allocatorCallback, &getMaterialManager(), - &mSimpleIslandManager->getAccurateIslandSim(), contextID, mEnableStabilization, useEnhancedDeterminism, useAdaptiveForce); + &mSimpleIslandManager->getAccurateIslandSim(), contextID, mEnableStabilization, useEnhancedDeterminism, useAdaptiveForce, desc.maxBiasCoefficient); mLLContext->setNphaseImplementationContext(createNphaseImplementationContext(*mLLContext, &mSimpleIslandManager->getAccurateIslandSim())); @@ -786,7 +789,7 @@ Sc::Scene::Scene(const PxSceneDesc& desc, PxU64 contextID) : { #if PX_SUPPORT_GPU_PHYSX mDynamicsContext = PxvGetPhysXGpu(true)->createGpuDynamicsContext(mLLContext->getTaskPool(), mGpuWranglerManagers, mLLContext->getTaskManager().getGpuDispatcher(), NULL, - desc.gpuDynamicsConfig, &mSimpleIslandManager->getAccurateIslandSim(), desc.gpuMaxNumPartitions, mEnableStabilization, useEnhancedDeterminism, useAdaptiveForce, desc.gpuComputeVersion, mLLContext->getSimStats(), + desc.gpuDynamicsConfig, &mSimpleIslandManager->getAccurateIslandSim(), desc.gpuMaxNumPartitions, mEnableStabilization, useEnhancedDeterminism, useAdaptiveForce, desc.maxBiasCoefficient, desc.gpuComputeVersion, mLLContext->getSimStats(), mHeapMemoryAllocationManager); void* contactStreamBase = NULL; @@ -838,6 +841,7 @@ Sc::Scene::Scene(const PxSceneDesc& desc, PxU64 contextID) : setSolverBatchSize(desc.solverBatchSize); mDynamicsContext->setFrictionOffsetThreshold(desc.frictionOffsetThreshold); mDynamicsContext->setCCDSeparationThreshold(desc.ccdMaxSeparation); + mDynamicsContext->setSolverOffsetSlop(desc.solverOffsetSlop); const PxTolerancesScale& scale = Physics::getInstance().getTolerancesScale(); mDynamicsContext->setCorrelationDistance(0.025f * scale.length); @@ -2129,6 +2133,8 @@ void Sc::Scene::postBroadPhase(PxBaseTask* continuation) void Sc::Scene::postBroadPhaseStage2(PxBaseTask* continuation) { + // - Wakes actors that lost touch if appropriate + processLostTouchPairs(); //Release unused Cms back to the pool (later, this needs to be done in a thread-safe way from multiple worker threads mIslandInsertion.setContinuation(continuation); mRegisterContactManagers.setContinuation(continuation); @@ -6056,8 +6062,8 @@ void Sc::Scene::islandInsertion(PxBaseTask* /*continuation*/) } } - // - Wakes actors that lost touch if appropriate - processLostTouchPairs(); + //// - Wakes actors that lost touch if appropriate + //processLostTouchPairs(); if(mCCDPass == 0) { diff --git a/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp b/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp index cb3b5f66..159450ce 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp +++ b/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp @@ -443,64 +443,89 @@ Ps::IntBool Sc::ShapeSim::updateSweptBounds() return isFastMoving; } -void Sc::ShapeSim::onVolumeOrTransformChange(bool asPartOfActorTransformChange, bool forceBoundsUpdate) +void Sc::ShapeSim::markBoundsForUpdate(bool forceBoundsUpdate, bool isDynamic) { + PX_UNUSED(isDynamic); + Sc::Scene& scene = getScene(); - Sc::BodySim* body = getBodySim(); - const bool isDynamic = (body != NULL); - bool isAsleep; - if (body) + const PxU32 elementID = getElementID(); + + if(forceBoundsUpdate) + updateCached(0, &scene.getAABBManager()->getChangedAABBMgActorHandleMap()); + else if(isInBroadPhase()) + scene.getDirtyShapeSimMap().growAndSet(elementID); + +#if PX_USE_PARTICLE_SYSTEM_API +#if PX_SUPPORT_GPU_PHYSX + // PT: onShapeChange currently only used for GPU physics. Inlined 'getSceneGpu' call avoids + // extra function calls and additional work from getPxsRigidCore(), etc + Pt::Context* context = scene.getParticleContext(); + if(context->getSceneGpuFast()) + context->getSceneGpuFast()->onShapeChange(size_t(&mCore.getCore()), size_t(&getPxsRigidCore()), isDynamic); +#endif +#endif +} + +static PX_FORCE_INLINE void updateInteraction(Sc::Scene& scene, Sc::Interaction* i, const bool isDynamic, const bool isAsleep) +{ + if(i->getType() == Sc::InteractionType::eOVERLAP) { - isAsleep = !body->isActive(); - body->postShapeChange(asPartOfActorTransformChange); + Sc::ShapeInteraction* si = static_cast<Sc::ShapeInteraction*>(i); + si->resetManagerCachedState(); + + if(isAsleep) + si->onShapeChangeWhileSleeping(isDynamic); } - else - isAsleep = true; + else if(i->getType() == Sc::InteractionType::eTRIGGER) + (static_cast<Sc::TriggerInteraction*>(i))->forceProcessingThisFrame(scene); // trigger pairs need to be checked next frame +#if PX_USE_PARTICLE_SYSTEM_API + else if(i->getType() == Sc::InteractionType::ePARTICLE_BODY) + (static_cast<Sc::ParticleElementRbElementInteraction *>(i))->onRbShapeChange(); +#endif +} + +void Sc::ShapeSim::onVolumeOrTransformChange(bool forceBoundsUpdate) +{ + Sc::Scene& scene = getScene(); + Sc::BodySim* body = getBodySim(); + const bool isDynamic = (body != NULL); + const bool isAsleep = body ? !body->isActive() : true; ElementSim::ElementInteractionIterator iter = getElemInteractions(); ElementSimInteraction* i = iter.getNext(); while(i) { - if(i->getType() == InteractionType::eOVERLAP) - { - Sc::ShapeInteraction* si = static_cast<Sc::ShapeInteraction*>(i); - si->resetManagerCachedState(); - - if (isAsleep) - si->onShapeChangeWhileSleeping(isDynamic); - } - else if (i->getType() == InteractionType::eTRIGGER) - (static_cast<Sc::TriggerInteraction*>(i))->forceProcessingThisFrame(scene); // trigger pairs need to be checked next frame -#if PX_USE_PARTICLE_SYSTEM_API - else if (i->getType() == InteractionType::ePARTICLE_BODY) - (static_cast<Sc::ParticleElementRbElementInteraction *>(i))->onRbShapeChange(); -#endif - + updateInteraction(scene, i, isDynamic, isAsleep); i = iter.getNext(); } + markBoundsForUpdate(forceBoundsUpdate, isDynamic); +} - const PxU32 elementID = getElementID(); - - if (forceBoundsUpdate) +bool notifyActorInteractionsOfTransformChange(Sc::ActorSim& actor) +{ + bool isDynamic; + bool isAsleep; + if(actor.isDynamicRigid()) { - updateCached(0, &scene.getAABBManager()->getChangedAABBMgActorHandleMap()); + isDynamic = true; + isAsleep = !static_cast<Sc::BodySim&>(actor).isActive(); } - else if (isInBroadPhase()) - scene.getDirtyShapeSimMap().growAndSet(elementID); - -#if PX_USE_PARTICLE_SYSTEM_API -#if PX_SUPPORT_GPU_PHYSX - // PT: onShapeChange currently only used for GPU physics. Inlined 'getSceneGpu' call avoids - // extra function calls and additional work from getPxsRigidCore(), etc - Pt::Context* context = scene.getParticleContext(); - if(context->getSceneGpuFast()) + else { - context->getSceneGpuFast()->onShapeChange(size_t(&mCore.getCore()), size_t(&getPxsRigidCore()), (body != NULL)); + isDynamic = false; + isAsleep = true; } -#endif -#endif + + Sc::Scene& scene = actor.getScene(); + + PxU32 nbInteractions = actor.getActorInteractionCount(); + Sc::Interaction** interactions = actor.getActorInteractions(); + while(nbInteractions--) + updateInteraction(scene, *interactions++, isDynamic, isAsleep); + + return isDynamic; } void Sc::ShapeSim::createSqBounds() diff --git a/PhysX_3.4/Source/SimulationController/src/ScShapeSim.h b/PhysX_3.4/Source/SimulationController/src/ScShapeSim.h index 86d29f15..e185703f 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScShapeSim.h +++ b/PhysX_3.4/Source/SimulationController/src/ScShapeSim.h @@ -106,9 +106,10 @@ namespace Sc void onRestOffsetChange(); void onFlagChange(PxShapeFlags oldFlags); void onResetFiltering(); - void onVolumeOrTransformChange(bool asPartOfActorTransformChange, bool forceBoundsUpdate = false); + void onVolumeOrTransformChange(bool forceBoundsUpdate = false); void onMaterialChange(); // remove when material properties are gone from PxcNpWorkUnit void onContactOffsetChange(); + void markBoundsForUpdate(bool forceBoundsUpdate, bool isDynamic); void getAbsPoseAligned(PxTransform* PX_RESTRICT globalPose) const; diff --git a/PhysX_3.4/Source/SimulationController/src/particles/ScParticleSystemSim.cpp b/PhysX_3.4/Source/SimulationController/src/particles/ScParticleSystemSim.cpp index 5fb2a990..c0ba7cd8 100644 --- a/PhysX_3.4/Source/SimulationController/src/particles/ScParticleSystemSim.cpp +++ b/PhysX_3.4/Source/SimulationController/src/particles/ScParticleSystemSim.cpp @@ -718,6 +718,8 @@ void Sc::ParticleSystemSim::visualizeInteractions(Cm::RenderOutput& out) } } +#endif // PX_ENABLE_DEBUG_VISUALIZATION + //----------------------------------------------------------------------------// PxBaseTask& Sc::ParticleSystemSim::scheduleShapeGeneration(Pt::Context& context, const Ps::Array<ParticleSystemSim*>& particleSystems, PxBaseTask& continuation) @@ -862,7 +864,4 @@ void Sc::ParticleSystemSim::prepareCollisionInput(PxBaseTask* /*continuation*/) //----------------------------------------------------------------------------// -#endif // PX_ENABLE_DEBUG_VISUALIZATION - - #endif // PX_USE_PARTICLE_SYSTEM_API |