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

Method createJoints

testbed/scenes/bridge/BridgeScene.cpp:58–78  ·  view source on GitHub ↗

Create the joints

Source from the content-addressed store, hash-verified

56
57// Create the joints
58void BridgeScene::createJoints() {
59
60 for (int b=0; b < NB_BRIDGES; b++) {
61
62 for (int i=0; i < NB_BOXES-1; i++) {
63
64 const uint box1Index = b * NB_BOXES + i;
65 const uint box2Index = b * NB_BOXES + i + 1;
66
67 // Create the joint info object
68 rp3d::RigidBody* body1 = mBoxes[box1Index]->getRigidBody();
69 rp3d::RigidBody* body2 = mBoxes[box2Index]->getRigidBody();
70 rp3d::Vector3 body1Position = body1->getTransform().getPosition();
71 const rp3d::Vector3 anchorPointWorldSpace = body1Position + rp3d::Vector3(BOX_SIZE.x / 2.0f, 0, 0);
72 rp3d::HingeJointInfo jointInfo(body1, body2, anchorPointWorldSpace, rp3d::Vector3(0, 0, 1));
73 jointInfo.isCollisionEnabled = false;
74 rp3d::HingeJoint* joint = dynamic_cast<rp3d::HingeJoint*>(mPhysicsWorld->createJoint(jointInfo));
75 mHingeJoints.push_back(joint);
76 }
77 }
78}
79
80// Update the physics simulation
81void BridgeScene::updatePhysics() {

Callers

nothing calls this directly

Calls 3

createJointMethod · 0.80
Vector3Class · 0.50
getRigidBodyMethod · 0.45

Tested by

no test coverage detected