MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / enableDisableJoints

Method enableDisableJoints

src/engine/PhysicsWorld.cpp:363–394  ·  view source on GitHub ↗

Enable or disable the joints

Source from the content-addressed store, hash-verified

361
362// Enable or disable the joints
363void PhysicsWorld::enableDisableJoints() {
364
365 const uint32 nbJointComponents = mJointsComponents.getNbComponents();
366
367 Array<Entity> jointsEntites(mMemoryManager.getHeapAllocator(), nbJointComponents);
368
369 // Get all the joints entities
370 for (uint32 i = 0; i < nbJointComponents; i++) {
371 jointsEntites.add(mJointsComponents.mJointEntities[i]);
372 }
373
374 // For each joint
375 for (uint32 i = 0; i < nbJointComponents; i++) {
376
377 uint32 jointEntityIndex = mJointsComponents.getEntityIndex(jointsEntites[i]);
378
379 Entity body1 = mJointsComponents.mBody1Entities[jointEntityIndex];
380 Entity body2 = mJointsComponents.mBody2Entities[jointEntityIndex];
381
382 // If both bodies of the joint are disabled
383 if (mBodyComponents.getIsEntityDisabled(body1) && mBodyComponents.getIsEntityDisabled(body2)) {
384
385 // Disable the joint
386 setJointDisabled(jointsEntites[i], true);
387 }
388 else {
389
390 // Enable the joint
391 setJointDisabled(jointsEntites[i], false);
392 }
393 }
394}
395
396// Create a rigid body into the physics world
397/**

Callers

nothing calls this directly

Calls 4

getNbComponentsMethod · 0.80
getEntityIndexMethod · 0.80
getIsEntityDisabledMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected