mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Support reference angle on revolute, prismatic, and weld joints (fixes #1194)
This commit is contained in:
@@ -37,18 +37,32 @@ PrismaticJoint::PrismaticJoint(Body *body1, Body *body2, float xA, float yA, flo
|
||||
, joint(NULL)
|
||||
{
|
||||
b2PrismaticJointDef def;
|
||||
init(def, body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
|
||||
joint = (b2PrismaticJoint *)createJoint(&def);
|
||||
}
|
||||
|
||||
PrismaticJoint::PrismaticJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, float ax, float ay, bool collideConnected, float referenceAngle)
|
||||
: Joint(body1, body2)
|
||||
, joint(NULL)
|
||||
{
|
||||
b2PrismaticJointDef def;
|
||||
init(def, body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
|
||||
def.referenceAngle = referenceAngle;
|
||||
joint = (b2PrismaticJoint *)createJoint(&def);
|
||||
}
|
||||
|
||||
PrismaticJoint::~PrismaticJoint()
|
||||
{
|
||||
}
|
||||
|
||||
void PrismaticJoint::init(b2PrismaticJointDef &def, Body *body1, Body *body2, float xA, float yA, float xB, float yB, float ax, float ay, bool collideConnected)
|
||||
{
|
||||
def.Initialize(body1->body, body2->body, Physics::scaleDown(b2Vec2(xA,yA)), b2Vec2(ax,ay));
|
||||
def.localAnchorB = body2->body->GetLocalPoint(Physics::scaleDown(b2Vec2(xB, yB)));
|
||||
def.lowerTranslation = 0.0f;
|
||||
def.upperTranslation = 100.0f;
|
||||
def.enableLimit = true;
|
||||
def.collideConnected = collideConnected;
|
||||
joint = (b2PrismaticJoint *)createJoint(&def);
|
||||
}
|
||||
|
||||
PrismaticJoint::~PrismaticJoint()
|
||||
{
|
||||
}
|
||||
|
||||
float PrismaticJoint::getJointTranslation() const
|
||||
@@ -147,6 +161,11 @@ int PrismaticJoint::getAxis(lua_State *L)
|
||||
return 2;
|
||||
}
|
||||
|
||||
float PrismaticJoint::getReferenceAngle() const
|
||||
{
|
||||
return joint->GetReferenceAngle();
|
||||
}
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user