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

Method BodySim

physx/source/simulationcontroller/src/ScBodySim.cpp:49–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47#define PX_FREEZE_SCALE 0.9f
48
49BodySim::BodySim(Scene& scene, BodyCore& core, bool compound) :
50 RigidSim (scene, core),
51 mLLBody (&core.getCore()),
52 mNodeIndex (IG_INVALID_NODE),
53 mInternalFlags (0),
54 mVelModState (VMF_GRAVITY_DIRTY),
55 mActiveListIndex (SC_NOT_IN_SCENE_INDEX),
56 mActiveCompoundListIndex (SC_NOT_IN_SCENE_INDEX),
57 mArticulation (NULL),
58 mConstraintGroup (NULL)
59{
60 // For 32-bit, sizeof(BodyCore) = 160 bytes, sizeof(BodySim) = 192 bytes
61 mLLBody.sleepLinVelAcc = PxVec3(0);
62 mLLBody.sleepAngVelAcc = PxVec3(0);
63 mLLBody.freezeCount = PX_FREEZE_INTERVAL;
64 mLLBody.accelScale = 1.f;
65 mLLBody.solverIterationCounts = core.getCore().solverIterationCounts;
66 core.getCore().numCountedInteractions = 0;
67 core.getCore().numBodyInteractions = 0;
68 mLLBody.mInternalFlags = 0;
69 if (core.getActorFlags()&PxActorFlag::eDISABLE_GRAVITY)
70 mLLBody.mInternalFlags |= PxsRigidBody::eDISABLE_GRAVITY;
71 if (core.getFlags() & PxRigidBodyFlag::eENABLE_SPECULATIVE_CCD)
72 mLLBody.mInternalFlags |= PxsRigidBody::eSPECULATIVE_CCD;
73
74 //If a body pending insertion was given a force/torque then it will have
75 //the dirty flags stored in a separate structure. Copy them across
76 //so we can use them now that the BodySim is constructed.
77 SimStateData* simStateData = core.getSimStateData(false);
78 bool hasPendingForce = false;
79 if(simStateData)
80 {
81 VelocityMod* velmod = simStateData->getVelocityModData();
82 hasPendingForce = (velmod->flags != 0) &&
83 (!velmod->getLinearVelModPerSec().isZero() || !velmod->getAngularVelModPerSec().isZero() ||
84 !velmod->getLinearVelModPerStep().isZero() || !velmod->getAngularVelModPerStep().isZero());
85 mVelModState = velmod->flags;
86 velmod->flags = 0;
87 }
88
89 // PT: don't read the core ptr we just wrote, use input param
90 // PT: at time of writing we get a big L2 here because even though bodycore has been prefetched, the wake counter is 160 bytes away
91 const bool isAwake = (core.getWakeCounter() > 0) ||
92 (!core.getLinearVelocity().isZero()) ||
93 (!core.getAngularVelocity().isZero()) ||
94 hasPendingForce;
95
96 const bool isKine = isKinematic();
97
98 IG::SimpleIslandManager* simpleIslandManager = scene.getSimpleIslandManager();
99 if (!isArticulationLink())
100 {
101 mNodeIndex = simpleIslandManager->addRigidBody(&mLLBody, isKine, isAwake);
102 }
103 else
104 {
105 if(mArticulation)
106 {

Callers

nothing calls this directly

Calls 15

isKinematicFunction · 0.85
raiseInternalFlagFunction · 0.85
setActiveFunction · 0.85
getSimStateDataMethod · 0.80
getVelocityModDataMethod · 0.80
getLinkHandleMethod · 0.80
getIslandNodeIndexMethod · 0.80
indexMethod · 0.80
growAndSetMethod · 0.80
addToActiveBodyListMethod · 0.80
setupSimStateDataMethod · 0.80
isKineMethod · 0.80

Tested by

no test coverage detected