updating the Joints

--HG--
branch : box2d-update
This commit is contained in:
Bill Meltsner
2011-03-13 13:16:02 -04:00
parent be146c5f61
commit b4fae893fd
20 changed files with 50 additions and 205 deletions
+5 -46
View File
@@ -48,49 +48,13 @@ namespace box2d
int PulleyJoint::getGroundAnchors(lua_State * L)
{
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchor1().x));
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchor1().y));
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchor2().x));
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchor2().y));
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchorA().x));
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchorA().y));
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchorB().x));
lua_pushnumber(L, world->scaleUp(joint->GetGroundAnchorB().y));
return 4;
}
void PulleyJoint::setMaxLengths(float maxlength1, float maxlength2)
{
// Apply Box2D's maximum lengths too. They know better.
if (maxlength1 > 0)
{
joint->m_maxLength1 = b2Min(world->scaleDown(maxlength1), joint->m_constant - joint->m_ratio * b2_minPulleyLength);
}
if (maxlength2 > 0)
{
joint->m_maxLength2 = b2Min(world->scaleDown(maxlength2), (joint->m_constant - b2_minPulleyLength) / joint->m_ratio);
}
}
int PulleyJoint::getMaxLengths(lua_State * L)
{
lua_pushnumber(L, world->scaleUp(joint->m_maxLength1));
lua_pushnumber(L, world->scaleUp(joint->m_maxLength2));
return 2;
}
void PulleyJoint::setConstant(float constant)
{
joint->m_constant = world->scaleDown(constant);
// Update the max lengths, as does Box2D
joint->m_maxLength1 = joint->m_constant - joint->m_ratio * b2_minPulleyLength;
joint->m_maxLength2 = (joint->m_constant - b2_minPulleyLength) / joint->m_ratio;
}
float PulleyJoint::getConstant() const
{
return world->scaleUp(joint->m_constant);
}
float PulleyJoint::getLength1() const
{
return world->scaleUp(joint->GetLength1());
@@ -101,14 +65,9 @@ namespace box2d
return world->scaleUp(joint->GetLength2());
}
void PulleyJoint::setRatio(float ratio)
{
joint->m_ratio = ratio;
}
float PulleyJoint::getRatio() const
{
return joint->m_ratio;
return joint->GetRatio();
}
} // box2d