diff --git a/src/modules/physics/box2d/DistanceJoint.cpp b/src/modules/physics/box2d/DistanceJoint.cpp index ffe80a8d6..892ff34fd 100644 --- a/src/modules/physics/box2d/DistanceJoint.cpp +++ b/src/modules/physics/box2d/DistanceJoint.cpp @@ -56,9 +56,37 @@ float DistanceJoint::getLength() const return Physics::scaleUp(joint->GetLength()); } -void DistanceJoint::setStiffness(float hz) +void DistanceJoint::setFrequency(float hz) { - joint->SetStiffness(hz); + float stiffness, damping; + b2LinearStiffness(stiffness, damping, hz, getDampingRatio(), joint->GetBodyA(), joint->GetBodyB()); + joint->SetStiffness(stiffness); +} + +float DistanceJoint::getFrequency() const +{ + float frequency, ratio; + Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return frequency; +} + +void DistanceJoint::setDampingRatio(float ratio) +{ + float stiffness, damping; + b2LinearStiffness(stiffness, damping, getFrequency(), ratio, joint->GetBodyA(), joint->GetBodyB()); + joint->SetDamping(damping); +} + +float DistanceJoint::getDampingRatio() const +{ + float frequency, ratio; + Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return ratio; +} + +void DistanceJoint::setStiffness(float k) +{ + joint->SetStiffness(k); } float DistanceJoint::getStiffness() const diff --git a/src/modules/physics/box2d/DistanceJoint.h b/src/modules/physics/box2d/DistanceJoint.h index 3ca572525..45cb0a613 100644 --- a/src/modules/physics/box2d/DistanceJoint.h +++ b/src/modules/physics/box2d/DistanceJoint.h @@ -57,24 +57,42 @@ public: float getLength() const; /** - * Sets the response speed. + * Sets the response speed. Independent of mass **/ - void setStiffness(float hz); + void setFrequency(float hz); /** - * Gets the response speed. + * Gets the response speed. Independent of mass + **/ + float getFrequency() const; + + /** + * Set the spring damping ratio. Independent of mass + **/ + void setDampingRatio(float ratio); + + /** + * Get the spring damping ratio. Independent of mass + **/ + float getDampingRatio() const; + + /** + * Sets the response speed. Dependent of mass + **/ + void setStiffness(float k); + + /** + * Gets the response speed. Dependent of mass **/ float getStiffness() const; /** - * Sets the damping ratio. - * 0 = no damping, 1 = critical damping. + * Set the spring damping. Dependent of mass **/ - void setDamping(float d); + void setDamping(float ratio); /** - * Gets the damping ratio. - * 0 = no damping, 1 = critical damping. + * Get the spring damping. Dependent of mass **/ float getDamping() const; diff --git a/src/modules/physics/box2d/MouseJoint.cpp b/src/modules/physics/box2d/MouseJoint.cpp index 49f2d5f5f..4475dd53d 100644 --- a/src/modules/physics/box2d/MouseJoint.cpp +++ b/src/modules/physics/box2d/MouseJoint.cpp @@ -78,7 +78,7 @@ float MouseJoint::getMaxForce() const return Physics::scaleUp(joint->GetMaxForce()); } -void MouseJoint::setStiffness(float hz) +void MouseJoint::setFrequency(float hz) { // This is kind of a crappy check. The Stiffness is used in an internal // box2d calculation whose result must be > FLT_EPSILON, but other variables @@ -86,7 +86,41 @@ void MouseJoint::setStiffness(float hz) if (hz <= FLT_EPSILON * 2) throw love::Exception("MouseJoint Stiffness must be a positive number."); - joint->SetStiffness(hz); + float stiffness, damping; + b2LinearStiffness(stiffness, damping, hz, getDampingRatio(), joint->GetBodyA(), joint->GetBodyB()); + joint->SetStiffness(stiffness); +} + +float MouseJoint::getFrequency() const +{ + float frequency, ratio; + Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return frequency; +} + +void MouseJoint::setDampingRatio(float ratio) +{ + float stiffness, damping; + b2LinearStiffness(stiffness, damping, getFrequency(), ratio, joint->GetBodyA(), joint->GetBodyB()); + joint->SetDamping(damping); +} + +float MouseJoint::getDampingRatio() const +{ + float frequency, ratio; + Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return ratio; +} + +void MouseJoint::setStiffness(float k) +{ + // This is kind of a crappy check. The Stiffness is used in an internal + // box2d calculation whose result must be > FLT_EPSILON, but other variables + // go into that calculation... + if (k <= FLT_EPSILON * 2) + throw love::Exception("MouseJoint Stiffness must be a positive number."); + + joint->SetStiffness(k); } float MouseJoint::getStiffness() const diff --git a/src/modules/physics/box2d/MouseJoint.h b/src/modules/physics/box2d/MouseJoint.h index 633df0282..f308d7f78 100644 --- a/src/modules/physics/box2d/MouseJoint.h +++ b/src/modules/physics/box2d/MouseJoint.h @@ -76,24 +76,42 @@ public: float getMaxForce() const; /** - * Sets the response speed. + * Sets the response speed. Independent of mass **/ - void setStiffness(float hz); + void setFrequency(float hz); /** - * Gets the response speed. + * Gets the response speed. Independent of mass + **/ + float getFrequency() const; + + /** + * Set the spring damping ratio. Independent of mass + **/ + void setDampingRatio(float ratio); + + /** + * Get the spring damping ratio. Independent of mass + **/ + float getDampingRatio() const; + + /** + * Sets the response speed. Dependent of mass + **/ + void setStiffness(float k); + + /** + * Gets the response speed. Dependent of mass **/ float getStiffness() const; /** - * Sets the damping ratio. - * 0 = no damping, 1 = critical damping. + * Set the spring damping. Dependent of mass **/ - void setDamping(float d); + void setDamping(float ratio); /** - * Gets the damping ratio. - * 0 = no damping, 1 = critical damping. + * Get the spring damping. Dependent of mass **/ float getDamping() const; diff --git a/src/modules/physics/box2d/Physics.cpp b/src/modules/physics/box2d/Physics.cpp index 5d87fbe4a..da75cbf65 100644 --- a/src/modules/physics/box2d/Physics.cpp +++ b/src/modules/physics/box2d/Physics.cpp @@ -395,6 +395,66 @@ b2AABB Physics::scaleUp(const b2AABB &aabb) return t; } +void Physics::b2LinearFrequency(float& frequency, float& ratio, float stiffness, float damping, b2Body* bodyA, b2Body* bodyB) +{ + float massA = bodyA->GetMass(); + float massB = bodyB->GetMass(); + float mass; + if (massA > 0.0f && massB > 0.0f) + { + mass = massA * massB / (massA + massB); + } + else if (massA > 0.0f) + { + mass = massA; + } + else + { + mass = massB; + } + + if (mass == 0.0f || stiffness <= 0.0f) + { + frequency = 0.0f; + ratio = 0.0f; + return; + }; + + float omega = b2Sqrt(stiffness / mass); + frequency = omega / (2.0f * b2_pi); + ratio = damping / (mass * 2.0f * omega); +} + +void Physics::b2AngularFrequency(float& frequency, float& ratio, float stiffness, float damping, b2Body* bodyA, b2Body* bodyB) +{ + float IA = bodyA->GetInertia(); + float IB = bodyB->GetInertia(); + float I; + if (IA > 0.0f && IB > 0.0f) + { + I = IA * IB / (IA + IB); + } + else if (IA > 0.0f) + { + I = IA; + } + else + { + I = IB; + } + + if (I == 0.0f || stiffness <= 0.0f) + { + frequency = 0.0f; + ratio = 0.0f; + return; + }; + + float omega = b2Sqrt(stiffness / I); + frequency = omega / (2.0f * b2_pi); + ratio = damping / (I * 2.0f * omega); +} + } // box2d } // physics } // love diff --git a/src/modules/physics/box2d/Physics.h b/src/modules/physics/box2d/Physics.h index 151fb5f86..68518f9e0 100644 --- a/src/modules/physics/box2d/Physics.h +++ b/src/modules/physics/box2d/Physics.h @@ -354,7 +354,29 @@ public: * @param aabb The unscaled input AABB. * @return The scaled AABB. **/ - static b2AABB scaleUp(const b2AABB &aabb); + static b2AABB scaleUp(const b2AABB& aabb); + + /** + * Calculates linear frequency and damping radio from stiffness and damping + * @param frequency The output frequency + * @param ratio The output damping ratio + * @param stiffness The joint stiffness + * @param damping The joint damping + * @param bodyA The bodyA of the joint + * @param bodyB The bodyB of the joint + **/ + static void b2LinearFrequency(float& frequency, float& ratio, float stiffness, float damping, b2Body* bodyA, b2Body* bodyB); + + /** + * Calculates angular frequency and damping radio from stiffness and damping + * @param frequency The output frequency + * @param ratio The output damping ratio + * @param stiffness The joint stiffness + * @param damping The joint damping + * @param bodyA The bodyA of the joint + * @param bodyB The bodyB of the joint + **/ + static void b2AngularFrequency(float& frequency, float& ratio, float stiffness, float damping, b2Body* bodyA, b2Body* bodyB); private: diff --git a/src/modules/physics/box2d/WeldJoint.cpp b/src/modules/physics/box2d/WeldJoint.cpp index df304596a..30ead28ec 100644 --- a/src/modules/physics/box2d/WeldJoint.cpp +++ b/src/modules/physics/box2d/WeldJoint.cpp @@ -66,9 +66,37 @@ void WeldJoint::init(b2WeldJointDef &def, Body *body1, Body *body2, float xA, fl def.collideConnected = collideConnected; } -void WeldJoint::setStiffness(float hz) +void WeldJoint::setFrequency(float hz) { - joint->SetStiffness(hz); + float stiffness, damping; + b2LinearStiffness(stiffness, damping, hz, getDampingRatio(), joint->GetBodyA(), joint->GetBodyB()); + joint->SetStiffness(stiffness); +} + +float WeldJoint::getFrequency() const +{ + float frequency, ratio; + Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return frequency; +} + +void WeldJoint::setDampingRatio(float ratio) +{ + float stiffness, damping; + b2LinearStiffness(stiffness, damping, getFrequency(), ratio, joint->GetBodyA(), joint->GetBodyB()); + joint->SetDamping(damping); +} + +float WeldJoint::getDampingRatio() const +{ + float frequency, ratio; + Physics::b2LinearFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return ratio; +} + +void WeldJoint::setStiffness(float k) +{ + joint->SetStiffness(k); } float WeldJoint::getStiffness() const diff --git a/src/modules/physics/box2d/WeldJoint.h b/src/modules/physics/box2d/WeldJoint.h index d269549e3..e0bd27e68 100644 --- a/src/modules/physics/box2d/WeldJoint.h +++ b/src/modules/physics/box2d/WeldJoint.h @@ -50,24 +50,42 @@ public: virtual ~WeldJoint(); /** - * Sets the response speed. + * Sets the response speed. Independent of mass **/ - void setStiffness(float hz); + void setFrequency(float hz); /** - * Gets the response speed. + * Gets the response speed. Independent of mass + **/ + float getFrequency() const; + + /** + * Set the spring damping ratio. Independent of mass + **/ + void setDampingRatio(float ratio); + + /** + * Get the spring damping ratio. Independent of mass + **/ + float getDampingRatio() const; + + /** + * Sets the response speed. Dependent of mass + **/ + void setStiffness(float k); + + /** + * Gets the response speed. Dependent of mass **/ float getStiffness() const; /** - * Sets the damping ratio. - * 0 = no damping, 1 = critical damping. + * Set the spring damping. Dependent of mass **/ - void setDamping(float d); + void setDamping(float ratio); /** - * Gets the damping ratio. - * 0 = no damping, 1 = critical damping. + * Get the spring damping. Dependent of mass **/ float getDamping() const; diff --git a/src/modules/physics/box2d/WheelJoint.cpp b/src/modules/physics/box2d/WheelJoint.cpp index 092b6ccf8..52b61b998 100644 --- a/src/modules/physics/box2d/WheelJoint.cpp +++ b/src/modules/physics/box2d/WheelJoint.cpp @@ -95,9 +95,37 @@ float WheelJoint::getMotorTorque(float inv_dt) const return Physics::scaleUp(Physics::scaleUp(joint->GetMotorTorque(inv_dt))); } -void WheelJoint::setStiffness(float hz) +void WheelJoint::setFrequency(float hz) { - joint->SetStiffness(hz); + float stiffness, damping; + b2AngularStiffness(stiffness, damping, hz, getDampingRatio(), joint->GetBodyA(), joint->GetBodyB()); + joint->SetStiffness(stiffness); +} + +float WheelJoint::getFrequency() const +{ + float frequency, ratio; + Physics::b2AngularFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return frequency; +} + +void WheelJoint::setDampingRatio(float ratio) +{ + float stiffness, damping; + b2AngularStiffness(stiffness, damping, getFrequency(), ratio, joint->GetBodyA(), joint->GetBodyB()); + joint->SetDamping(damping); +} + +float WheelJoint::getDampingRatio() const +{ + float frequency, ratio; + Physics::b2AngularFrequency(frequency, ratio, joint->GetStiffness(), joint->GetDamping(), joint->GetBodyA(), joint->GetBodyB()); + return ratio; +} + +void WheelJoint::setStiffness(float k) +{ + joint->SetStiffness(k); } float WheelJoint::getStiffness() const diff --git a/src/modules/physics/box2d/WheelJoint.h b/src/modules/physics/box2d/WheelJoint.h index fe2ecc4a6..453ae9608 100644 --- a/src/modules/physics/box2d/WheelJoint.h +++ b/src/modules/physics/box2d/WheelJoint.h @@ -96,23 +96,42 @@ public: float getMotorTorque(float inv_dt) const; /** - * Set the spring frequency, in hertz. Setting the frequency to 0 - * disables the spring. + * Sets the response speed. Independent of mass **/ - void setStiffness(float hz); + void setFrequency(float hz); /** - * Get the spring frequency, in hertz. + * Gets the response speed. Independent of mass + **/ + float getFrequency() const; + + /** + * Set the spring damping ratio. Independent of mass + **/ + void setDampingRatio(float ratio); + + /** + * Get the spring damping ratio. Independent of mass + **/ + float getDampingRatio() const; + + /** + * Sets the response speed. Dependent of mass + **/ + void setStiffness(float k); + + /** + * Gets the response speed. Dependent of mass **/ float getStiffness() const; /** - * Set the spring damping ratio. + * Set the spring damping. Dependent of mass **/ void setDamping(float ratio); /** - * Get the spring damping ratio. + * Get the spring damping. Dependent of mass **/ float getDamping() const; diff --git a/src/modules/physics/box2d/wrap_DistanceJoint.cpp b/src/modules/physics/box2d/wrap_DistanceJoint.cpp index 242e555b2..d49648d39 100644 --- a/src/modules/physics/box2d/wrap_DistanceJoint.cpp +++ b/src/modules/physics/box2d/wrap_DistanceJoint.cpp @@ -54,14 +54,14 @@ int w_DistanceJoint_setFrequency(lua_State *L) { DistanceJoint *t = luax_checkdistancejoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); - t->setStiffness(arg1); + t->setFrequency(arg1); return 0; } int w_DistanceJoint_getFrequency(lua_State *L) { DistanceJoint *t = luax_checkdistancejoint(L, 1); - lua_pushnumber(L, t->getStiffness()); + lua_pushnumber(L, t->getFrequency()); return 1; } @@ -69,11 +69,41 @@ int w_DistanceJoint_setDampingRatio(lua_State *L) { DistanceJoint *t = luax_checkdistancejoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); - t->setDamping(arg1); + t->setDampingRatio(arg1); return 0; } int w_DistanceJoint_getDampingRatio(lua_State *L) +{ + DistanceJoint *t = luax_checkdistancejoint(L, 1); + lua_pushnumber(L, t->getDampingRatio()); + return 1; +} + +int w_DistanceJoint_setStiffness(lua_State *L) +{ + DistanceJoint *t = luax_checkdistancejoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + t->setStiffness(arg1); + return 0; +} + +int w_DistanceJoint_getStiffness(lua_State *L) +{ + DistanceJoint *t = luax_checkdistancejoint(L, 1); + lua_pushnumber(L, t->getStiffness()); + return 1; +} + +int w_DistanceJoint_setDamping(lua_State *L) +{ + DistanceJoint *t = luax_checkdistancejoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + t->setDamping(arg1); + return 0; +} + +int w_DistanceJoint_getDamping(lua_State *L) { DistanceJoint *t = luax_checkdistancejoint(L, 1); lua_pushnumber(L, t->getDamping()); @@ -88,6 +118,10 @@ static const luaL_Reg w_DistanceJoint_functions[] = { "getFrequency", w_DistanceJoint_getFrequency }, { "setDampingRatio", w_DistanceJoint_setDampingRatio }, { "getDampingRatio", w_DistanceJoint_getDampingRatio }, + { "setStiffness", w_DistanceJoint_setStiffness }, + { "getStiffness", w_DistanceJoint_getStiffness }, + { "setDamping", w_DistanceJoint_setDamping }, + { "getDamping", w_DistanceJoint_getDamping }, { 0, 0 } }; diff --git a/src/modules/physics/box2d/wrap_MouseJoint.cpp b/src/modules/physics/box2d/wrap_MouseJoint.cpp index f30e7c9f4..e6bce8307 100644 --- a/src/modules/physics/box2d/wrap_MouseJoint.cpp +++ b/src/modules/physics/box2d/wrap_MouseJoint.cpp @@ -70,14 +70,14 @@ int w_MouseJoint_setFrequency(lua_State *L) { MouseJoint *t = luax_checkmousejoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); - luax_catchexcept(L, [&]() { t->setStiffness(arg1); }); + luax_catchexcept(L, [&]() { t->setFrequency(arg1); }); return 0; } int w_MouseJoint_getFrequency(lua_State *L) { MouseJoint *t = luax_checkmousejoint(L, 1); - lua_pushnumber(L, t->getStiffness()); + lua_pushnumber(L, t->getFrequency()); return 1; } @@ -85,11 +85,41 @@ int w_MouseJoint_setDampingRatio(lua_State *L) { MouseJoint *t = luax_checkmousejoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); - t->setDamping(arg1); + 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; +} + +int w_MouseJoint_setStiffness(lua_State *L) +{ + MouseJoint *t = luax_checkmousejoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + luax_catchexcept(L, [&]() { t->setStiffness(arg1); }); + return 0; +} + +int w_MouseJoint_getStiffness(lua_State *L) +{ + MouseJoint *t = luax_checkmousejoint(L, 1); + lua_pushnumber(L, t->getStiffness()); + return 1; +} + +int w_MouseJoint_setDamping(lua_State *L) +{ + MouseJoint *t = luax_checkmousejoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + t->setDamping(arg1); + return 0; +} + +int w_MouseJoint_getDamping(lua_State *L) { MouseJoint *t = luax_checkmousejoint(L, 1); lua_pushnumber(L, t->getDamping()); @@ -106,6 +136,10 @@ static const luaL_Reg w_MouseJoint_functions[] = { "getFrequency", w_MouseJoint_getFrequency }, { "setDampingRatio", w_MouseJoint_setDampingRatio }, { "getDampingRatio", w_MouseJoint_getDampingRatio }, + { "setStiffness", w_MouseJoint_setStiffness }, + { "getStiffness", w_MouseJoint_getStiffness }, + { "setDamping", w_MouseJoint_setDamping }, + { "getDamping", w_MouseJoint_getDamping }, { 0, 0 } }; diff --git a/src/modules/physics/box2d/wrap_WeldJoint.cpp b/src/modules/physics/box2d/wrap_WeldJoint.cpp index e1e960159..7d1efc020 100644 --- a/src/modules/physics/box2d/wrap_WeldJoint.cpp +++ b/src/modules/physics/box2d/wrap_WeldJoint.cpp @@ -39,14 +39,14 @@ int w_WeldJoint_setFrequency(lua_State *L) { WeldJoint *t = luax_checkweldjoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); - t->setStiffness(arg1); + t->setFrequency(arg1); return 0; } int w_WeldJoint_getFrequency(lua_State *L) { WeldJoint *t = luax_checkweldjoint(L, 1); - lua_pushnumber(L, t->getStiffness()); + lua_pushnumber(L, t->getFrequency()); return 1; } @@ -54,11 +54,41 @@ int w_WeldJoint_setDampingRatio(lua_State *L) { WeldJoint *t = luax_checkweldjoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); - t->setDamping(arg1); + 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; +} + +int w_WeldJoint_setStiffness(lua_State *L) +{ + WeldJoint *t = luax_checkweldjoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + t->setStiffness(arg1); + return 0; +} + +int w_WeldJoint_getStiffness(lua_State *L) +{ + WeldJoint *t = luax_checkweldjoint(L, 1); + lua_pushnumber(L, t->getStiffness()); + return 1; +} + +int w_WeldJoint_setDamping(lua_State *L) +{ + WeldJoint *t = luax_checkweldjoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + t->setDamping(arg1); + return 0; +} + +int w_WeldJoint_getDamping(lua_State *L) { WeldJoint *t = luax_checkweldjoint(L, 1); lua_pushnumber(L, t->getDamping()); @@ -78,6 +108,10 @@ static const luaL_Reg w_WeldJoint_functions[] = { "getFrequency", w_WeldJoint_getFrequency }, { "setDampingRatio", w_WeldJoint_setDampingRatio }, { "getDampingRatio", w_WeldJoint_getDampingRatio }, + { "setStiffness", w_WeldJoint_setStiffness }, + { "getStiffness", w_WeldJoint_getStiffness }, + { "setDamping", w_WeldJoint_setDamping }, + { "getDamping", w_WeldJoint_getDamping }, { "getReferenceAngle", w_WeldJoint_getReferenceAngle }, { 0, 0 } }; diff --git a/src/modules/physics/box2d/wrap_WheelJoint.cpp b/src/modules/physics/box2d/wrap_WheelJoint.cpp index 021fb675a..3f2a8e5b6 100644 --- a/src/modules/physics/box2d/wrap_WheelJoint.cpp +++ b/src/modules/physics/box2d/wrap_WheelJoint.cpp @@ -102,7 +102,37 @@ int w_WheelJoint_getMotorTorque(lua_State *L) return 1; } -int w_WheelJoint_setSpringFrequency(lua_State *L) +int w_WheelJoint_setFrequency(lua_State *L) +{ + WheelJoint *t = luax_checkwheeljoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + t->setFrequency(arg1); + return 0; +} + +int w_WheelJoint_getFrequency(lua_State *L) +{ + WheelJoint *t = luax_checkwheeljoint(L, 1); + lua_pushnumber(L, t->getFrequency()); + return 1; +} + +int w_WheelJoint_setDampingRatio(lua_State *L) +{ + WheelJoint *t = luax_checkwheeljoint(L, 1); + float arg1 = (float)luaL_checknumber(L, 2); + t->setDampingRatio(arg1); + return 0; +} + +int w_WheelJoint_getDampingRatio(lua_State *L) +{ + WheelJoint *t = luax_checkwheeljoint(L, 1); + lua_pushnumber(L, t->getDampingRatio()); + return 1; +} + +int w_WheelJoint_setStiffness(lua_State *L) { WheelJoint *t = luax_checkwheeljoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); @@ -110,14 +140,14 @@ int w_WheelJoint_setSpringFrequency(lua_State *L) return 0; } -int w_WheelJoint_getSpringFrequency(lua_State *L) +int w_WheelJoint_getStiffness(lua_State *L) { WheelJoint *t = luax_checkwheeljoint(L, 1); lua_pushnumber(L, t->getStiffness()); return 1; } -int w_WheelJoint_setSpringDampingRatio(lua_State *L) +int w_WheelJoint_setDamping(lua_State *L) { WheelJoint *t = luax_checkwheeljoint(L, 1); float arg1 = (float)luaL_checknumber(L, 2); @@ -125,7 +155,7 @@ int w_WheelJoint_setSpringDampingRatio(lua_State *L) return 0; } -int w_WheelJoint_getSpringDampingRatio(lua_State *L) +int w_WheelJoint_getDamping(lua_State *L) { WheelJoint *t = luax_checkwheeljoint(L, 1); lua_pushnumber(L, t->getDamping()); @@ -150,10 +180,22 @@ static const luaL_Reg w_WheelJoint_functions[] = { "setMaxMotorTorque", w_WheelJoint_setMaxMotorTorque }, { "getMaxMotorTorque", w_WheelJoint_getMaxMotorTorque }, { "getMotorTorque", w_WheelJoint_getMotorTorque }, - { "setSpringFrequency", w_WheelJoint_setSpringFrequency }, - { "getSpringFrequency", w_WheelJoint_getSpringFrequency }, - { "setSpringDampingRatio", w_WheelJoint_setSpringDampingRatio }, - { "getSpringDampingRatio", w_WheelJoint_getSpringDampingRatio }, + { "setSpringFrequency", w_WheelJoint_setFrequency }, + { "getSpringFrequency", w_WheelJoint_getFrequency }, + { "setSpringDampingRatio", w_WheelJoint_setDampingRatio }, + { "getSpringDampingRatio", w_WheelJoint_getDampingRatio }, + { "setSpringStiffness", w_WheelJoint_setStiffness }, + { "getSpringStiffness", w_WheelJoint_getStiffness }, + { "setSpringDamping", w_WheelJoint_setDamping }, + { "getSpringDamping", w_WheelJoint_getDamping }, + { "setFrequency", w_WheelJoint_setFrequency }, + { "getFrequency", w_WheelJoint_getFrequency }, + { "setDampingRatio", w_WheelJoint_setDampingRatio }, + { "getDampingRatio", w_WheelJoint_getDampingRatio }, + { "setStiffness", w_WheelJoint_setStiffness }, + { "getStiffness", w_WheelJoint_getStiffness }, + { "setDamping", w_WheelJoint_setDamping }, + { "getDamping", w_WheelJoint_getDamping }, { "getAxis", w_WheelJoint_getAxis }, { 0, 0 } };