From ead4186734e9a15899ae7e02030d1065cc4e3861 Mon Sep 17 00:00:00 2001 From: Bill Clagett Date: Sun, 20 Nov 2016 23:00:22 -0500 Subject: [PATCH] =?UTF-8?q?Expose=20box2d=E2=80=99s=20RopeJoint::SetMaxLen?= =?UTF-8?q?gth().?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : fb_add_ropejoint_setmaxlength --- src/modules/physics/box2d/RopeJoint.cpp | 4 ++++ src/modules/physics/box2d/RopeJoint.h | 1 + src/modules/physics/box2d/wrap_RopeJoint.cpp | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/src/modules/physics/box2d/RopeJoint.cpp b/src/modules/physics/box2d/RopeJoint.cpp index 8db662a09..53d7677d6 100644 --- a/src/modules/physics/box2d/RopeJoint.cpp +++ b/src/modules/physics/box2d/RopeJoint.cpp @@ -59,6 +59,10 @@ float RopeJoint::getMaxLength() const return Physics::scaleUp(joint->GetMaxLength()); } +void RopeJoint::setMaxLength(float maxLength) +{ + joint->SetMaxLength(Physics::scaleDown(maxLength)); +} } // box2d } // physics diff --git a/src/modules/physics/box2d/RopeJoint.h b/src/modules/physics/box2d/RopeJoint.h index 56d00bb20..926da9ac0 100644 --- a/src/modules/physics/box2d/RopeJoint.h +++ b/src/modules/physics/box2d/RopeJoint.h @@ -50,6 +50,7 @@ public: * Gets the maximum length of the rope. **/ float getMaxLength() const; + void setMaxLength(float length); private: // The Box2D RopeJoint object. diff --git a/src/modules/physics/box2d/wrap_RopeJoint.cpp b/src/modules/physics/box2d/wrap_RopeJoint.cpp index 926354a55..0fe233e1e 100644 --- a/src/modules/physics/box2d/wrap_RopeJoint.cpp +++ b/src/modules/physics/box2d/wrap_RopeJoint.cpp @@ -42,9 +42,18 @@ int w_RopeJoint_getMaxLength(lua_State *L) 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[] = { { "getMaxLength", w_RopeJoint_getMaxLength }, + { "setMaxLength", w_RopeJoint_setMaxLength }, { 0, 0 } };