mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
more joint updates to better match the API
--HG-- branch : box2d-update
This commit is contained in:
@@ -111,6 +111,11 @@ namespace box2d
|
||||
if (joint != NULL)
|
||||
world->world->DestroyJoint(joint);
|
||||
}
|
||||
|
||||
bool Joint::isActive() const
|
||||
{
|
||||
return joint->IsActive();
|
||||
}
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
|
||||
@@ -98,6 +98,8 @@ namespace box2d
|
||||
* Gets the reaction torque on body2.
|
||||
**/
|
||||
float getReactionTorque(float dt);
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -69,6 +69,26 @@ namespace box2d
|
||||
{
|
||||
return joint->GetMaxForce();
|
||||
}
|
||||
|
||||
void MouseJoint::setFrequency(float hz)
|
||||
{
|
||||
joint->SetFrequency(hz);
|
||||
}
|
||||
|
||||
float MouseJoint::getFrequency() const
|
||||
{
|
||||
return joint->GetFrequency();
|
||||
}
|
||||
|
||||
void MouseJoint::setDampingRatio(float d)
|
||||
{
|
||||
joint->SetDampingRatio(d);
|
||||
}
|
||||
|
||||
float MouseJoint::getDampingRatio() const
|
||||
{
|
||||
return joint->GetDampingRatio();
|
||||
}
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
|
||||
@@ -74,6 +74,28 @@ namespace box2d
|
||||
* to move the candidate body.
|
||||
**/
|
||||
float getMaxForce() const;
|
||||
|
||||
/**
|
||||
* Sets the response speed.
|
||||
**/
|
||||
void setFrequency(float hz);
|
||||
|
||||
/**
|
||||
* Gets the response speed.
|
||||
**/
|
||||
float getFrequency() const;
|
||||
|
||||
/**
|
||||
* Sets the damping ratio.
|
||||
* 0 = no damping, 1 = critical damping.
|
||||
**/
|
||||
void setDampingRatio(float d);
|
||||
|
||||
/**
|
||||
* Gets the damping ratio.
|
||||
* 0 = no damping, 1 = critical damping.
|
||||
**/
|
||||
float getDampingRatio() const;
|
||||
};
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace box2d
|
||||
/**
|
||||
* Enable/disable the joint motor.
|
||||
**/
|
||||
void setMotorEnabled(bool motor);
|
||||
void enableMotor(bool motor);
|
||||
|
||||
/**
|
||||
* Checks whether the motor is enabled.
|
||||
@@ -93,12 +93,12 @@ namespace box2d
|
||||
/**
|
||||
* Enable/disable the joint limit.
|
||||
**/
|
||||
void setLimitsEnabled(bool limit);
|
||||
void enableLimit(bool limit);
|
||||
|
||||
/**
|
||||
* Checks whether limits are enabled.
|
||||
**/
|
||||
bool isLimitsEnabled() const;
|
||||
bool isLimitEnabled() const;
|
||||
|
||||
/**
|
||||
* Sets the upper limit, usually in meters.
|
||||
|
||||
@@ -66,11 +66,6 @@ namespace box2d
|
||||
**/
|
||||
float getLength2() const;
|
||||
|
||||
/**
|
||||
* Sets the pulley ratio.
|
||||
**/
|
||||
void setRatio(float ratio);
|
||||
|
||||
/**
|
||||
* Gets the pulley ratio.
|
||||
**/
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace box2d
|
||||
return joint->GetJointSpeed();
|
||||
}
|
||||
|
||||
void RevoluteJoint::setMotorEnabled(bool motor)
|
||||
void RevoluteJoint::enableMotor(bool motor)
|
||||
{
|
||||
return joint->EnableMotor(motor);
|
||||
}
|
||||
@@ -86,12 +86,12 @@ namespace box2d
|
||||
return joint->GetMotorTorque();
|
||||
}
|
||||
|
||||
void RevoluteJoint::setLimitsEnabled(bool limit)
|
||||
void RevoluteJoint::enableLimit(bool limit)
|
||||
{
|
||||
joint->EnableLimit(limit);
|
||||
}
|
||||
|
||||
bool RevoluteJoint::isLimitsEnabled() const
|
||||
bool RevoluteJoint::isLimitEnabled() const
|
||||
{
|
||||
return joint->IsLimitEnabled();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace box2d
|
||||
/**
|
||||
* Enable/disable the joint motor.
|
||||
**/
|
||||
void setMotorEnabled(bool motor);
|
||||
void enableMotor(bool motor);
|
||||
|
||||
/**
|
||||
* Checks whether the motor is enabled.
|
||||
@@ -93,12 +93,12 @@ namespace box2d
|
||||
/**
|
||||
* Enable/disable the joint limit.
|
||||
**/
|
||||
void setLimitsEnabled(bool limit);
|
||||
void enableLimit(bool limit);
|
||||
|
||||
/**
|
||||
* Checks whether limits are enabled.
|
||||
**/
|
||||
bool isLimitsEnabled() const;
|
||||
bool isLimitEnabled() const;
|
||||
|
||||
/**
|
||||
* Sets the upper limit in degrees.
|
||||
|
||||
@@ -81,8 +81,8 @@ namespace box2d
|
||||
{ "getLength", w_DistanceJoint_getLength },
|
||||
{ "setFrequency", w_DistanceJoint_setFrequency },
|
||||
{ "getFrequency", w_DistanceJoint_getFrequency },
|
||||
{ "setDamping", w_DistanceJoint_setDampingRatio },
|
||||
{ "getDamping", w_DistanceJoint_getDampingRatio },
|
||||
{ "setDampingRatio", w_DistanceJoint_setDampingRatio },
|
||||
{ "getDampingRatio", w_DistanceJoint_getDampingRatio },
|
||||
// From Joint.
|
||||
{ "getType", w_Joint_getType },
|
||||
{ "getAnchors", w_Joint_getAnchors },
|
||||
|
||||
@@ -61,12 +61,46 @@ namespace box2d
|
||||
lua_pushnumber(L, t->getMaxForce());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_MouseJoint_setFrequency(lua_State * L)
|
||||
{
|
||||
MouseJoint * t = luax_checkmousejoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setFrequency(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_MouseJoint_getFrequency(lua_State * L)
|
||||
{
|
||||
MouseJoint * t = luax_checkmousejoint(L, 1);
|
||||
lua_pushnumber(L, t->getFrequency());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_MouseJoint_setDampingRatio(lua_State * L)
|
||||
{
|
||||
MouseJoint * t = luax_checkmousejoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setDampingRatio(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_MouseJoint_getDampingRatio(lua_State * L)
|
||||
{
|
||||
MouseJoint * t = luax_checkmousejoint(L, 1);
|
||||
lua_pushnumber(L, t->getDampingRatio());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "setTarget", w_MouseJoint_setTarget },
|
||||
{ "getTarget", w_MouseJoint_getTarget },
|
||||
{ "setMaxForce", w_MouseJoint_setMaxForce },
|
||||
{ "getMaxForce", w_MouseJoint_getMaxForce },
|
||||
{ "setFrequency", w_MouseJoint_setFrequency },
|
||||
{ "getFrequency", w_MouseJoint_getFrequency },
|
||||
{ "setDampingRatio", w_MouseJoint_setDampingRatio },
|
||||
{ "getDampingRatio", w_MouseJoint_getDampingRatio },
|
||||
// From Joint.
|
||||
{ "getType", w_Joint_getType },
|
||||
{ "getAnchors", w_Joint_getAnchors },
|
||||
|
||||
@@ -37,6 +37,10 @@ namespace box2d
|
||||
int w_MouseJoint_getTarget(lua_State * L);
|
||||
int w_MouseJoint_setMaxForce(lua_State * L);
|
||||
int w_MouseJoint_getMaxForce(lua_State * L);
|
||||
int w_MouseJoint_setFrequency(lua_State * L);
|
||||
int w_MouseJoint_getFrequency(lua_State * L);
|
||||
int w_MouseJoint_setDampingRatio(lua_State * L);
|
||||
int w_MouseJoint_getDampingRatio(lua_State * L);
|
||||
int luaopen_mousejoint(lua_State * L);
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -45,11 +45,11 @@ namespace box2d
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_PrismaticJoint_setMotorEnabled(lua_State * L)
|
||||
int w_PrismaticJoint_enableMotor(lua_State * L)
|
||||
{
|
||||
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
|
||||
bool arg1 = luax_toboolean(L, 2);
|
||||
t->setMotorEnabled(arg1);
|
||||
t->enableMotor(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,18 +90,18 @@ namespace box2d
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_PrismaticJoint_setLimitsEnabled(lua_State * L)
|
||||
int w_PrismaticJoint_enableLimit(lua_State * L)
|
||||
{
|
||||
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
|
||||
bool arg1 = luax_toboolean(L, 2);
|
||||
t->setLimitsEnabled(arg1);
|
||||
t->enableLimit(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_PrismaticJoint_isLimitsEnabled(lua_State * L)
|
||||
int w_PrismaticJoint_isLimitEnabled(lua_State * L)
|
||||
{
|
||||
PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
|
||||
luax_pushboolean(L, t->isLimitsEnabled());
|
||||
luax_pushboolean(L, t->isLimitEnabled());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -154,14 +154,14 @@ namespace box2d
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getJointTranslation", w_PrismaticJoint_getJointTranslation },
|
||||
{ "getJointSpeed", w_PrismaticJoint_getJointSpeed },
|
||||
{ "setMotorEnabled", w_PrismaticJoint_setMotorEnabled },
|
||||
{ "enableMotor", w_PrismaticJoint_enableMotor },
|
||||
{ "isMotorEnabled", w_PrismaticJoint_isMotorEnabled },
|
||||
{ "setMaxMotorForce", w_PrismaticJoint_setMaxMotorForce },
|
||||
{ "setMotorSpeed", w_PrismaticJoint_setMotorSpeed },
|
||||
{ "getMotorSpeed", w_PrismaticJoint_getMotorSpeed },
|
||||
{ "getMotorForce", w_PrismaticJoint_getMotorForce },
|
||||
{ "setLimitsEnabled", w_PrismaticJoint_setLimitsEnabled },
|
||||
{ "isLimitsEnabled", w_PrismaticJoint_isLimitsEnabled },
|
||||
{ "enableLimit", w_PrismaticJoint_enableLimit },
|
||||
{ "isLimitEnabled", w_PrismaticJoint_isLimitEnabled },
|
||||
{ "setUpperLimit", w_PrismaticJoint_setUpperLimit },
|
||||
{ "setLowerLimit", w_PrismaticJoint_setLowerLimit },
|
||||
{ "setLimits", w_PrismaticJoint_setLimits },
|
||||
|
||||
@@ -35,14 +35,14 @@ namespace box2d
|
||||
PrismaticJoint * luax_checkprismaticjoint(lua_State * L, int idx);
|
||||
int w_PrismaticJoint_getJointTranslation(lua_State * L);
|
||||
int w_PrismaticJoint_getJointSpeed(lua_State * L);
|
||||
int w_PrismaticJoint_setMotorEnabled(lua_State * L);
|
||||
int w_PrismaticJoint_enableMotor(lua_State * L);
|
||||
int w_PrismaticJoint_isMotorEnabled(lua_State * L);
|
||||
int w_PrismaticJoint_setMaxMotorForce(lua_State * L);
|
||||
int w_PrismaticJoint_setMotorSpeed(lua_State * L);
|
||||
int w_PrismaticJoint_getMotorSpeed(lua_State * L);
|
||||
int w_PrismaticJoint_getMotorForce(lua_State * L);
|
||||
int w_PrismaticJoint_setLimitsEnabled(lua_State * L);
|
||||
int w_PrismaticJoint_isLimitsEnabled(lua_State * L);
|
||||
int w_PrismaticJoint_enableLimit(lua_State * L);
|
||||
int w_PrismaticJoint_isLimitEnabled(lua_State * L);
|
||||
int w_PrismaticJoint_setUpperLimit(lua_State * L);
|
||||
int w_PrismaticJoint_setLowerLimit(lua_State * L);
|
||||
int w_PrismaticJoint_setLimits(lua_State * L);
|
||||
|
||||
@@ -45,11 +45,11 @@ namespace box2d
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_RevoluteJoint_setMotorEnabled(lua_State * L)
|
||||
int w_RevoluteJoint_enableMotor(lua_State * L)
|
||||
{
|
||||
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
|
||||
bool arg1 = luax_toboolean(L, 2);
|
||||
t->setMotorEnabled(arg1);
|
||||
t->enableMotor(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,18 +90,18 @@ namespace box2d
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_RevoluteJoint_setLimitsEnabled(lua_State * L)
|
||||
int w_RevoluteJoint_enableLimit(lua_State * L)
|
||||
{
|
||||
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
|
||||
bool arg1 = luax_toboolean(L, 2);
|
||||
t->setLimitsEnabled(arg1);
|
||||
t->enableLimit(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_RevoluteJoint_isLimitsEnabled(lua_State * L)
|
||||
int w_RevoluteJoint_isLimitEnabled(lua_State * L)
|
||||
{
|
||||
RevoluteJoint * t = luax_checkrevolutejoint(L, 1);
|
||||
luax_pushboolean(L, t->isLimitsEnabled());
|
||||
luax_pushboolean(L, t->isLimitEnabled());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -154,14 +154,14 @@ namespace box2d
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getJointAngle", w_RevoluteJoint_getJointAngle },
|
||||
{ "getJointSpeed", w_RevoluteJoint_getJointSpeed },
|
||||
{ "setMotorEnabled", w_RevoluteJoint_setMotorEnabled },
|
||||
{ "enableMotor", w_RevoluteJoint_enableMotor },
|
||||
{ "isMotorEnabled", w_RevoluteJoint_isMotorEnabled },
|
||||
{ "setMaxMotorTorque", w_RevoluteJoint_setMaxMotorTorque },
|
||||
{ "setMotorSpeed", w_RevoluteJoint_setMotorSpeed },
|
||||
{ "getMotorSpeed", w_RevoluteJoint_getMotorSpeed },
|
||||
{ "getMotorTorque", w_RevoluteJoint_getMotorTorque },
|
||||
{ "setLimitsEnabled", w_RevoluteJoint_setLimitsEnabled },
|
||||
{ "isLimitsEnabled", w_RevoluteJoint_isLimitsEnabled },
|
||||
{ "enableLimit", w_RevoluteJoint_enableLimit },
|
||||
{ "isLimitEnabled", w_RevoluteJoint_isLimitEnabled },
|
||||
{ "setUpperLimit", w_RevoluteJoint_setUpperLimit },
|
||||
{ "setLowerLimit", w_RevoluteJoint_setLowerLimit },
|
||||
{ "setLimits", w_RevoluteJoint_setLimits },
|
||||
|
||||
@@ -35,14 +35,14 @@ namespace box2d
|
||||
RevoluteJoint * luax_checkrevolutejoint(lua_State * L, int idx);
|
||||
int w_RevoluteJoint_getJointAngle(lua_State * L);
|
||||
int w_RevoluteJoint_getJointSpeed(lua_State * L);
|
||||
int w_RevoluteJoint_setMotorEnabled(lua_State * L);
|
||||
int w_RevoluteJoint_enableMotor(lua_State * L);
|
||||
int w_RevoluteJoint_isMotorEnabled(lua_State * L);
|
||||
int w_RevoluteJoint_setMaxMotorTorque(lua_State * L);
|
||||
int w_RevoluteJoint_setMotorSpeed(lua_State * L);
|
||||
int w_RevoluteJoint_getMotorSpeed(lua_State * L);
|
||||
int w_RevoluteJoint_getMotorTorque(lua_State * L);
|
||||
int w_RevoluteJoint_setLimitsEnabled(lua_State * L);
|
||||
int w_RevoluteJoint_isLimitsEnabled(lua_State * L);
|
||||
int w_RevoluteJoint_enableLimit(lua_State * L);
|
||||
int w_RevoluteJoint_isLimitEnabled(lua_State * L);
|
||||
int w_RevoluteJoint_setUpperLimit(lua_State * L);
|
||||
int w_RevoluteJoint_setLowerLimit(lua_State * L);
|
||||
int w_RevoluteJoint_setLimits(lua_State * L);
|
||||
|
||||
Reference in New Issue
Block a user