diff --git a/src/modules/physics/box2d/WeldJoint.cpp b/src/modules/physics/box2d/WeldJoint.cpp index 1d1f39494..b2882d0be 100644 --- a/src/modules/physics/box2d/WeldJoint.cpp +++ b/src/modules/physics/box2d/WeldJoint.cpp @@ -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 diff --git a/src/modules/physics/box2d/WeldJoint.h b/src/modules/physics/box2d/WeldJoint.h index c8bb6856c..e8469dac2 100644 --- a/src/modules/physics/box2d/WeldJoint.h +++ b/src/modules/physics/box2d/WeldJoint.h @@ -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 diff --git a/src/modules/physics/box2d/wrap_WeldJoint.cpp b/src/modules/physics/box2d/wrap_WeldJoint.cpp index 4d0cbc16a..b3229323e 100644 --- a/src/modules/physics/box2d/wrap_WeldJoint.cpp +++ b/src/modules/physics/box2d/wrap_WeldJoint.cpp @@ -31,7 +31,41 @@ namespace box2d return luax_checktype(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 }, diff --git a/src/modules/physics/box2d/wrap_WeldJoint.h b/src/modules/physics/box2d/wrap_WeldJoint.h index bf875e85c..3874897c5 100644 --- a/src/modules/physics/box2d/wrap_WeldJoint.h +++ b/src/modules/physics/box2d/wrap_WeldJoint.h @@ -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