From f6b74e9ce75ff8c193f42224fad28b900a1561e8 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Fri, 13 Jan 2023 18:10:45 -0400 Subject: [PATCH] WheelJoint:getMotorTorque takes a dt param instead of inverse dt. Matches the change made to RevoluteJoint:getMotorTorque. --- src/modules/physics/box2d/WheelJoint.cpp | 5 +++-- src/modules/physics/box2d/WheelJoint.h | 4 ++-- src/modules/physics/box2d/wrap_WheelJoint.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/physics/box2d/WheelJoint.cpp b/src/modules/physics/box2d/WheelJoint.cpp index 833c600de..cc42e4224 100644 --- a/src/modules/physics/box2d/WheelJoint.cpp +++ b/src/modules/physics/box2d/WheelJoint.cpp @@ -90,9 +90,10 @@ float WheelJoint::getMaxMotorTorque() const return Physics::scaleUp(Physics::scaleUp(joint->GetMaxMotorTorque())); } -float WheelJoint::getMotorTorque(float inv_dt) const +float WheelJoint::getMotorTorque(float dt) const { - return Physics::scaleUp(Physics::scaleUp(joint->GetMotorTorque(inv_dt))); + float invdt = 1.0f / dt; + return Physics::scaleUp(Physics::scaleUp(joint->GetMotorTorque(invdt))); } void WheelJoint::setStiffness(float k) diff --git a/src/modules/physics/box2d/WheelJoint.h b/src/modules/physics/box2d/WheelJoint.h index dc1696e75..83182a1bf 100644 --- a/src/modules/physics/box2d/WheelJoint.h +++ b/src/modules/physics/box2d/WheelJoint.h @@ -91,9 +91,9 @@ public: /** * Get the current motor torque, usually in N. - * @param inv_dt The inverse time step. + * @param dt The time step. **/ - float getMotorTorque(float inv_dt) const; + float getMotorTorque(float dt) const; /** * Sets the response speed. Dependent of mass diff --git a/src/modules/physics/box2d/wrap_WheelJoint.cpp b/src/modules/physics/box2d/wrap_WheelJoint.cpp index f796b5f12..fa116833e 100644 --- a/src/modules/physics/box2d/wrap_WheelJoint.cpp +++ b/src/modules/physics/box2d/wrap_WheelJoint.cpp @@ -97,8 +97,8 @@ int w_WheelJoint_getMaxMotorTorque(lua_State *L) int w_WheelJoint_getMotorTorque(lua_State *L) { WheelJoint *t = luax_checkwheeljoint(L, 1); - float inv_dt = (float)luaL_checknumber(L, 2); - lua_pushnumber(L, t->getMotorTorque(inv_dt)); + float dt = (float)luaL_checknumber(L, 2); + lua_pushnumber(L, t->getMotorTorque(dt)); return 1; }