Browse Source

WheelJoint:getMotorTorque takes a dt param instead of inverse dt.

Matches the change made to RevoluteJoint:getMotorTorque.
Sasha Szpakowski 2 years ago
parent
commit
f6b74e9ce7

+ 3 - 2
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)

+ 2 - 2
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

+ 2 - 2
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;
 }