mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Added an optional 'collideconnected' boolean argument to love.physics.newMotorJoint (resolves issue #1130).
This commit is contained in:
@@ -42,7 +42,7 @@ MotorJoint::MotorJoint(Body *body1, Body *body2)
|
||||
joint = (b2MotorJoint *) createJoint(&def);
|
||||
}
|
||||
|
||||
MotorJoint::MotorJoint(Body *body1, Body *body2, float correctionFactor)
|
||||
MotorJoint::MotorJoint(Body *body1, Body *body2, float correctionFactor, bool collideConnected)
|
||||
: Joint(body1, body2)
|
||||
, joint(NULL)
|
||||
{
|
||||
@@ -50,6 +50,7 @@ MotorJoint::MotorJoint(Body *body1, Body *body2, float correctionFactor)
|
||||
|
||||
def.Initialize(body1->body, body2->body);
|
||||
def.correctionFactor = correctionFactor;
|
||||
def.collideConnected = collideConnected;
|
||||
|
||||
joint = (b2MotorJoint *) createJoint(&def);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class MotorJoint : public Joint
|
||||
public:
|
||||
|
||||
MotorJoint(Body *body1, Body* body2);
|
||||
MotorJoint(Body *body1, Body* body2, float correctionFactor);
|
||||
MotorJoint(Body *body1, Body* body2, float correctionFactor, bool collideConnected);
|
||||
virtual ~MotorJoint();
|
||||
|
||||
/// Set/get the target linear offset, in frame A, in meters.
|
||||
|
||||
@@ -268,9 +268,9 @@ MotorJoint *Physics::newMotorJoint(Body *body1, Body *body2)
|
||||
return new MotorJoint(body1, body2);
|
||||
}
|
||||
|
||||
MotorJoint *Physics::newMotorJoint(Body *body1, Body *body2, float correctionFactor)
|
||||
MotorJoint *Physics::newMotorJoint(Body *body1, Body *body2, float correctionFactor, bool collideConnected)
|
||||
{
|
||||
return new MotorJoint(body1, body2, correctionFactor);
|
||||
return new MotorJoint(body1, body2, correctionFactor, collideConnected);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ public:
|
||||
* and body2.
|
||||
**/
|
||||
MotorJoint *newMotorJoint(Body *body1, Body *body2);
|
||||
MotorJoint *newMotorJoint(Body *body1, Body *body2, float correctionFactor);
|
||||
MotorJoint *newMotorJoint(Body *body1, Body *body2, float correctionFactor, bool collideConnected);
|
||||
|
||||
/**
|
||||
* Creates a new Fixture attaching shape to body.
|
||||
|
||||
@@ -419,8 +419,9 @@ int w_newMotorJoint(lua_State *L)
|
||||
if (!lua_isnoneornil(L, 3))
|
||||
{
|
||||
float correctionFactor = (float)luaL_checknumber(L, 3);
|
||||
bool collideConnected = luax_optboolean(L, 4, false);
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newMotorJoint(body1, body2, correctionFactor);
|
||||
j = instance()->newMotorJoint(body1, body2, correctionFactor, collideConnected);
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user