Browse Source

Merge pull request #1743 from megagrump/12.0-getMotorTorque

use dt instead of inv_dt in RevoluteJoint::getMotorTorque
Alex Szpakowski 3 years ago
parent
commit
9cc98df218

+ 2 - 1
src/modules/physics/box2d/RevoluteJoint.cpp

@@ -101,8 +101,9 @@ float RevoluteJoint::getMotorSpeed() const
 	return joint->GetMotorSpeed();
 	return joint->GetMotorSpeed();
 }
 }
 
 
-float RevoluteJoint::getMotorTorque(float inv_dt) const
+float RevoluteJoint::getMotorTorque(float dt) const
 {
 {
+	float inv_dt = 1.0f / dt;
 	return Physics::scaleUp(Physics::scaleUp(joint->GetMotorTorque(inv_dt)));
 	return Physics::scaleUp(Physics::scaleUp(joint->GetMotorTorque(inv_dt)));
 }
 }
 
 

+ 2 - 2
src/modules/physics/box2d/RevoluteJoint.h

@@ -87,9 +87,9 @@ public:
 
 
 	/**
 	/**
 	 * Get the current motor torque, usually in N-m.
 	 * Get the current motor torque, usually in N-m.
-	 * @param inv_dt The inverse timestep.
+	 * @param dt The timestep.
 	 **/
 	 **/
-	float getMotorTorque(float inv_dt) const;
+	float getMotorTorque(float dt) const;
 
 
 	/**
 	/**
 	 * Get the maximum motor torque, usually in N-m.
 	 * Get the maximum motor torque, usually in N-m.

+ 2 - 2
src/modules/physics/box2d/wrap_RevoluteJoint.cpp

@@ -91,8 +91,8 @@ int w_RevoluteJoint_getMotorSpeed(lua_State *L)
 int w_RevoluteJoint_getMotorTorque(lua_State *L)
 int w_RevoluteJoint_getMotorTorque(lua_State *L)
 {
 {
 	RevoluteJoint *t = luax_checkrevolutejoint(L, 1);
 	RevoluteJoint *t = luax_checkrevolutejoint(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;
 	return 1;
 }
 }