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

Method prismatic

Source/Physics/Joint.cpp:199–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199MotorJoint* Joint::prismatic(
200 bool collideConnected,
201 Body* bodyA,
202 Body* bodyB,
203 const Vec2& worldAnchor,
204 float axisAngle,
205 float lowerTranslation,
206 float upperTranslation,
207 float maxMotorForce,
208 float motorSpeed) {
209 if (bodyA->getPhysicsWorld() != bodyB->getPhysicsWorld()) {
210 return nullptr;
211 }
212 pr::BodyID bA = bodyA->getPrBody();
213 pr::BodyID bB = bodyB->getPrBody();
214 auto world = bodyA->getPhysicsWorld();
215 if (!world || !world->getPrWorld()) {
216 return nullptr;
217 }
218 auto& prWorld = *world->getPrWorld();
219 pr::Vec2 a = PhysicsWorld::prVal(worldAnchor);
220 pd::PrismaticJointConf conf = pd::GetPrismaticJointConf(prWorld,
221 bA, bB, a, pd::UnitVec::Get(-bx::toRad(axisAngle)))
222 .UseLowerLength(PhysicsWorld::prVal(lowerTranslation))
223 .UseUpperLength(PhysicsWorld::prVal(upperTranslation))
224 .UseEnableLimit((lowerTranslation || upperTranslation) && (lowerTranslation <= upperTranslation))
225 .UseCollideConnected(collideConnected);
226 conf.maxMotorForce = maxMotorForce;
227 conf.motorSpeed = PhysicsWorld::prVal(motorSpeed);
228 MotorJoint* joint = MotorJoint::create();
229 joint->_world = world;
230 joint->_joint = pd::CreateJoint(prWorld, conf);
231 world->setJointData(joint->_joint, joint);
232 return joint;
233}
234
235Joint* Joint::pulley(
236 bool collideConnected,

Callers

nothing calls this directly

Calls 10

GetPrismaticJointConfFunction · 0.85
toRadFunction · 0.85
getPrBodyMethod · 0.80
getPrWorldMethod · 0.80
UseCollideConnectedMethod · 0.80
setJointDataMethod · 0.80
GetFunction · 0.50
createFunction · 0.50
CreateJointFunction · 0.50
getPhysicsWorldMethod · 0.45

Tested by

no test coverage detected