MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / rope

Method rope

Source/Physics/Joint.cpp:305–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305Joint* Joint::rope(
306 bool collideConnected,
307 Body* bodyA,
308 Body* bodyB,
309 const Vec2& anchorA,
310 const Vec2& anchorB,
311 float maxLength) {
312 if (bodyA->getPhysicsWorld() != bodyB->getPhysicsWorld()) {
313 return nullptr;
314 }
315 pr::BodyID bA = bodyA->getPrBody();
316 pr::BodyID bB = bodyB->getPrBody();
317 pr::Vec2 aA = PhysicsWorld::prVal(anchorA);
318 pr::Vec2 aB = PhysicsWorld::prVal(anchorB);
319 auto world = bodyA->getPhysicsWorld();
320 if (!world || !world->getPrWorld()) {
321 return nullptr;
322 }
323 auto& prWorld = *world->getPrWorld();
324 pd::RopeJointConf conf{bA, bB};
325 conf.localAnchorA = aA;
326 conf.localAnchorB = aB;
327 conf.maxLength = PhysicsWorld::prVal(maxLength);
328 conf.UseCollideConnected(collideConnected);
329 Joint* joint = Joint::create();
330 joint->_world = world;
331 joint->_joint = pd::CreateJoint(prWorld, conf);
332 world->setJointData(joint->_joint, joint);
333 return joint;
334}
335
336Joint* Joint::weld(
337 bool collideConnected,

Callers

nothing calls this directly

Calls 7

getPrBodyMethod · 0.80
getPrWorldMethod · 0.80
UseCollideConnectedMethod · 0.80
setJointDataMethod · 0.80
createFunction · 0.50
CreateJointFunction · 0.50
getPhysicsWorldMethod · 0.45

Tested by

no test coverage detected