b2JointDef* ConstraintRope2D::GetJointDef() { if (!ownerBody_ || !otherBody_) return 0; b2Body* bodyA = ownerBody_->GetBody(); b2Body* bodyB = otherBody_->GetBody(); if (!bodyA || !bodyB) return 0; InitializeJointDef(&jointDef_); jointDef_.localAnchorA = ToB2Vec2(ownerBodyAnchor_); jointDef_.localAnchorB = ToB2Vec2(otherBodyAnchor_); return &jointDef_; }
b2JointDef* ConstraintRope2D::CreateJointDef() { if (!ownerBody_ || !otherBody_) return 0; b2Body* bodyA = ownerBody_->GetBody(); b2Body* bodyB = otherBody_->GetBody(); if (!bodyA || !bodyB) return 0; b2RopeJointDef* jointDef = new b2RopeJointDef; InitializeJointDef(jointDef); jointDef->localAnchorA = ToB2Vec2(ownerBodyAnchor_); jointDef->localAnchorB = ToB2Vec2(otherBodyAnchor_); jointDef->maxLength = maxLength_; return jointDef; }
b2JointDef* ConstraintGear2D::GetJointDef() { if (!ownerBody_ || !otherBody_) return nullptr; b2Body* bodyA = ownerBody_->GetBody(); b2Body* bodyB = otherBody_->GetBody(); if (!bodyA || !bodyB) return nullptr; if (!ownerConstraint_ || !otherConstraint_) return nullptr; b2Joint* jointA = ownerConstraint_->GetJoint(); b2Joint* jointB = otherConstraint_->GetJoint(); if (!jointA || !jointB) return nullptr; InitializeJointDef(&jointDef_); jointDef_.joint1 = jointA; jointDef_.joint2 = jointB; return &jointDef_; }