| 197 | } |
| 198 | |
| 199 | MotorJoint* 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 | |
| 235 | Joint* Joint::pulley( |
| 236 | bool collideConnected, |
nothing calls this directly
no test coverage detected