Browse Source

Merged in miscbill/love/fb_add_ropejoint_setmaxlength (pull request #73)

Expose box2d’s RopeJoint::SetMaxLength().
Alex Szpakowski 8 years ago
parent
commit
93d43c58a8

+ 4 - 0
src/modules/physics/box2d/RopeJoint.cpp

@@ -59,6 +59,10 @@ float RopeJoint::getMaxLength() const
 	return Physics::scaleUp(joint->GetMaxLength());
 	return Physics::scaleUp(joint->GetMaxLength());
 }
 }
 
 
+void RopeJoint::setMaxLength(float maxLength)
+{
+	joint->SetMaxLength(Physics::scaleDown(maxLength));
+}
 
 
 } // box2d
 } // box2d
 } // physics
 } // physics

+ 1 - 0
src/modules/physics/box2d/RopeJoint.h

@@ -50,6 +50,7 @@ public:
 	 * Gets the maximum length of the rope.
 	 * Gets the maximum length of the rope.
 	 **/
 	 **/
 	float getMaxLength() const;
 	float getMaxLength() const;
+	void setMaxLength(float length);
 
 
 private:
 private:
 	// The Box2D RopeJoint object.
 	// The Box2D RopeJoint object.

+ 9 - 0
src/modules/physics/box2d/wrap_RopeJoint.cpp

@@ -42,9 +42,18 @@ int w_RopeJoint_getMaxLength(lua_State *L)
 	return 1;
 	return 1;
 }
 }
 
 
+int w_RopeJoint_setMaxLength(lua_State *L)
+{
+	RopeJoint *t = luax_checkropejoint(L, 1);
+	float arg1 = (float)luaL_checknumber(L, 2);
+	t->setMaxLength(arg1);
+	return 0;
+}
+	
 static const luaL_Reg w_RopeJoint_functions[] =
 static const luaL_Reg w_RopeJoint_functions[] =
 {
 {
 	{ "getMaxLength", w_RopeJoint_getMaxLength },
 	{ "getMaxLength", w_RopeJoint_getMaxLength },
+	{ "setMaxLength", w_RopeJoint_setMaxLength },
 	{ 0, 0 }
 	{ 0, 0 }
 };
 };