Update WeldJoint for new soft constraint options

--HG--
branch : box2d-update
This commit is contained in:
Bill Meltsner
2011-09-23 16:17:29 -04:00
parent 3c7310e76d
commit a956f9b0c1
4 changed files with 82 additions and 0 deletions
+20
View File
@@ -47,6 +47,26 @@ namespace box2d
destroyJoint(joint);
joint = 0;
}
void WeldJoint::setFrequency(float hz)
{
joint->SetFrequency(hz);
}
float WeldJoint::getFrequency() const
{
return joint->GetFrequency();
}
void WeldJoint::setDampingRatio(float d)
{
joint->SetDampingRatio(d);
}
float WeldJoint::getDampingRatio() const
{
return joint->GetDampingRatio();
}
} // box2d
} // physics
+22
View File
@@ -49,6 +49,28 @@ namespace box2d
virtual ~WeldJoint();
/**
* 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
@@ -31,7 +31,41 @@ namespace box2d
return luax_checktype<WeldJoint>(L, idx, "WeldJoint", PHYSICS_WELD_JOINT_T);
}
int w_WeldJoint_setFrequency(lua_State * L)
{
WeldJoint * t = luax_checkweldjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
t->setFrequency(arg1);
return 0;
}
int w_WeldJoint_getFrequency(lua_State * L)
{
WeldJoint * t = luax_checkweldjoint(L, 1);
lua_pushnumber(L, t->getFrequency());
return 1;
}
int w_WeldJoint_setDampingRatio(lua_State * L)
{
WeldJoint * t = luax_checkweldjoint(L, 1);
float arg1 = (float)luaL_checknumber(L, 2);
t->setDampingRatio(arg1);
return 0;
}
int w_WeldJoint_getDampingRatio(lua_State * L)
{
WeldJoint * t = luax_checkweldjoint(L, 1);
lua_pushnumber(L, t->getDampingRatio());
return 1;
}
static const luaL_Reg functions[] = {
{ "setFrequency", w_WeldJoint_setFrequency },
{ "getFrequency", w_WeldJoint_getFrequency },
{ "setDampingRatio", w_WeldJoint_setDampingRatio },
{ "getDampingRatio", w_WeldJoint_getDampingRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getAnchors", w_Joint_getAnchors },
@@ -33,6 +33,12 @@ namespace physics
namespace box2d
{
WeldJoint * luax_checkweldjoint(lua_State * L, int idx);
int w_WeldJoint_setFrequency(lua_State * L);
int w_WeldJoint_getFrequency(lua_State * L);
int w_WeldJoint_setDampingRatio(lua_State * L);
int w_WeldJoint_getDampingRatio(lua_State * L);
int luaopen_weldjoint(lua_State * L);
} // box2d