MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / deactivate

Method deactivate

physx/source/simulationcontroller/src/ScBodySim.cpp:437–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437void BodySim::deactivate()
438{
439 // Deactivate interactions
440 {
441 const PxU32 nbInteractions = getActorInteractionCount();
442
443 for(PxU32 i=0; i<nbInteractions; ++i)
444 {
445 Ps::prefetchLine(mInteractions[PxMin(i+1,nbInteractions-1)]);
446 Interaction* interaction = mInteractions[i];
447
448 const bool isNotIGControlled = interaction->getType() != InteractionType::eOVERLAP &&
449 interaction->getType() != InteractionType::eMARKER;
450
451 if (interaction->readInteractionFlag(InteractionFlag::eIS_ACTIVE) && isNotIGControlled)
452 {
453 const bool proceed = deactivateInteraction(interaction);
454 if (proceed && (interaction->getType() < InteractionType::eTRACKED_IN_SCENE_COUNT))
455 getScene().notifyInteractionDeactivated(interaction);
456 }
457 }
458 }
459
460 // Deactivate body
461 {
462 PX_ASSERT((!isKinematic()) || notInScene() || !readInternalFlag(BF_KINEMATIC_MOVED)); // kinematics should only get deactivated when no target is set.
463 // exception: object gets newly added, then the state change will happen later
464 BodyCore& core = getBodyCore();
465 if(!readInternalFlag(BF_ON_DEATHROW))
466 {
467 // Set velocity to 0.
468 // Note: this is also fine if the method gets called because the user puts something to sleep (this behavior is documented in the API)
469 PX_ASSERT(core.getWakeCounter() == 0.0f);
470 const PxVec3 zero(0.0f);
471 core.setLinearVelocityInternal(zero);
472 core.setAngularVelocityInternal(zero);
473
474 setForcesToDefaults(!(mLLBody.mInternalFlags & PxsRigidBody::eDISABLE_GRAVITY));
475 }
476
477 if(!isArticulationLink()) // Articulations have their own sleep logic.
478 getScene().onBodySleep(this);
479
480 if(core.getFlags() & PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW)
481 {
482 PX_ASSERT(getScene().isInPosePreviewList(*this));
483 getScene().removeFromPosePreviewList(*this);
484 }
485 destroySqBounds();
486 }
487}
488
489void BodySim::setActive(bool active, PxU32 infoFlag)
490{

Callers

nothing calls this directly

Calls 11

PxMinFunction · 0.85
isKinematicFunction · 0.85
notInSceneFunction · 0.85
onBodySleepMethod · 0.80
prefetchLineFunction · 0.50
getTypeMethod · 0.45
getWakeCounterMethod · 0.45
getFlagsMethod · 0.45

Tested by

no test coverage detected