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

Method pulley

Source/Physics/Joint.cpp:235–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235Joint* Joint::pulley(
236 bool collideConnected,
237 Body* bodyA,
238 Body* bodyB,
239 const Vec2& anchorA,
240 const Vec2& anchorB,
241 const Vec2& groundAnchorA,
242 const Vec2& groundAnchorB,
243 float ratio) {
244 if (bodyA->getPhysicsWorld() != bodyB->getPhysicsWorld()) {
245 return nullptr;
246 }
247 pr::BodyID bA = bodyA->getPrBody();
248 pr::BodyID bB = bodyB->getPrBody();
249 auto world = bodyA->getPhysicsWorld();
250 if (!world || !world->getPrWorld()) {
251 return nullptr;
252 }
253 auto& prWorld = *world->getPrWorld();
254 pr::Vec2 aA = pd::GetWorldPoint(prWorld, bA, PhysicsWorld::prVal(anchorA));
255 pr::Vec2 aB = pd::GetWorldPoint(prWorld, bB, PhysicsWorld::prVal(anchorB));
256 pr::Vec2 gA = PhysicsWorld::prVal(groundAnchorA);
257 pr::Vec2 gB = PhysicsWorld::prVal(groundAnchorB);
258 Joint* joint = Joint::create();
259 joint->_world = world;
260 joint->_joint = pd::CreateJoint(prWorld,
261 pd::GetPulleyJointConf(prWorld, bA, bB, gA, gB, aA, aB)
262 .UseRatio(ratio)
263 .UseCollideConnected(collideConnected));
264 world->setJointData(joint->_joint, joint);
265 return joint;
266}
267
268MotorJoint* Joint::revolute(
269 bool collideConnected,

Callers

nothing calls this directly

Calls 9

GetPulleyJointConfFunction · 0.85
getPrBodyMethod · 0.80
getPrWorldMethod · 0.80
UseCollideConnectedMethod · 0.80
setJointDataMethod · 0.80
GetWorldPointFunction · 0.50
createFunction · 0.50
CreateJointFunction · 0.50
getPhysicsWorldMethod · 0.45

Tested by

no test coverage detected