| 303 | } |
| 304 | |
| 305 | Joint* 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 | |
| 336 | Joint* Joint::weld( |
| 337 | bool collideConnected, |
nothing calls this directly
no test coverage detected