From e5fa4c87c63ed575e215e0681c382831b6946c7c Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Thu, 15 Sep 2011 14:28:48 -0400 Subject: [PATCH] exposed collideConnected flag --HG-- branch : box2d-update --- src/modules/physics/box2d/DistanceJoint.cpp | 3 +- src/modules/physics/box2d/DistanceJoint.h | 2 +- src/modules/physics/box2d/FrictionJoint.cpp | 3 +- src/modules/physics/box2d/FrictionJoint.h | 2 +- src/modules/physics/box2d/GearJoint.cpp | 3 +- src/modules/physics/box2d/GearJoint.h | 2 +- src/modules/physics/box2d/Physics.cpp | 36 ++++++++++---------- src/modules/physics/box2d/Physics.h | 18 +++++----- src/modules/physics/box2d/PrismaticJoint.cpp | 3 +- src/modules/physics/box2d/PrismaticJoint.h | 2 +- src/modules/physics/box2d/PulleyJoint.cpp | 3 +- src/modules/physics/box2d/PulleyJoint.h | 2 +- src/modules/physics/box2d/RevoluteJoint.cpp | 3 +- src/modules/physics/box2d/RevoluteJoint.h | 2 +- src/modules/physics/box2d/RopeJoint.cpp | 3 +- src/modules/physics/box2d/RopeJoint.h | 2 +- src/modules/physics/box2d/WeldJoint.cpp | 3 +- src/modules/physics/box2d/WeldJoint.h | 2 +- src/modules/physics/box2d/WheelJoint.cpp | 3 +- src/modules/physics/box2d/WheelJoint.h | 2 +- src/modules/physics/box2d/wrap_Physics.cpp | 27 ++++++++++----- 21 files changed, 72 insertions(+), 54 deletions(-) diff --git a/src/modules/physics/box2d/DistanceJoint.cpp b/src/modules/physics/box2d/DistanceJoint.cpp index d05ee3883..8ffa8ca9c 100644 --- a/src/modules/physics/box2d/DistanceJoint.cpp +++ b/src/modules/physics/box2d/DistanceJoint.cpp @@ -30,11 +30,12 @@ namespace physics { namespace box2d { - DistanceJoint::DistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2) + DistanceJoint::DistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2DistanceJointDef def; def.Initialize(body1->body, body2->body, world->scaleDown(b2Vec2(x1,y1)), world->scaleDown(b2Vec2(x2,y2))); + def.collideConnected = collideConnected; joint = (b2DistanceJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/DistanceJoint.h b/src/modules/physics/box2d/DistanceJoint.h index 2363f1643..19ce1cb19 100644 --- a/src/modules/physics/box2d/DistanceJoint.h +++ b/src/modules/physics/box2d/DistanceJoint.h @@ -44,7 +44,7 @@ namespace box2d /** * Creates a DistanceJoint connecting body1 to body2. **/ - DistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2); + DistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, bool collideConnected); virtual ~DistanceJoint(); diff --git a/src/modules/physics/box2d/FrictionJoint.cpp b/src/modules/physics/box2d/FrictionJoint.cpp index f4d818803..f606199dd 100644 --- a/src/modules/physics/box2d/FrictionJoint.cpp +++ b/src/modules/physics/box2d/FrictionJoint.cpp @@ -32,11 +32,12 @@ namespace physics { namespace box2d { - FrictionJoint::FrictionJoint(Body * body1, Body * body2, float x, float y) + FrictionJoint::FrictionJoint(Body * body1, Body * body2, float x, float y, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2FrictionJointDef def; def.Initialize(body1->body, body2->body, world->scaleDown(b2Vec2(x,y))); + def.collideConnected = collideConnected; joint = (b2FrictionJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/FrictionJoint.h b/src/modules/physics/box2d/FrictionJoint.h index ed4599f68..d334c4799 100644 --- a/src/modules/physics/box2d/FrictionJoint.h +++ b/src/modules/physics/box2d/FrictionJoint.h @@ -45,7 +45,7 @@ namespace box2d /** * Creates a new FrictionJoint connecting body1 and body2. **/ - FrictionJoint(Body * body1, Body * body2, float x, float y); + FrictionJoint(Body * body1, Body * body2, float x, float y, bool collideConnected); virtual ~FrictionJoint(); diff --git a/src/modules/physics/box2d/GearJoint.cpp b/src/modules/physics/box2d/GearJoint.cpp index aad347f45..5fc0f7dc1 100644 --- a/src/modules/physics/box2d/GearJoint.cpp +++ b/src/modules/physics/box2d/GearJoint.cpp @@ -30,7 +30,7 @@ namespace physics { namespace box2d { - GearJoint::GearJoint(Joint * joint1, Joint * joint2, float ratio) + GearJoint::GearJoint(Joint * joint1, Joint * joint2, float ratio, bool collideConnected) : Joint(joint1->body2, joint2->body2), joint(NULL) { b2GearJointDef def; @@ -39,6 +39,7 @@ namespace box2d def.bodyA = joint1->body2->body; def.bodyB = joint2->body2->body; def.ratio = ratio; + def.collideConnected = collideConnected; joint = (b2GearJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/GearJoint.h b/src/modules/physics/box2d/GearJoint.h index 3be2be3af..58eb648be 100644 --- a/src/modules/physics/box2d/GearJoint.h +++ b/src/modules/physics/box2d/GearJoint.h @@ -52,7 +52,7 @@ namespace box2d /** * Creates a GearJoint connecting joint1 to joint2. **/ - GearJoint(Joint * joint1, Joint * joint2, float ratio); + GearJoint(Joint * joint1, Joint * joint2, float ratio, bool collideConnected); virtual ~GearJoint(); diff --git a/src/modules/physics/box2d/Physics.cpp b/src/modules/physics/box2d/Physics.cpp index bf43ddb22..b8d781eed 100644 --- a/src/modules/physics/box2d/Physics.cpp +++ b/src/modules/physics/box2d/Physics.cpp @@ -144,9 +144,9 @@ namespace box2d return 1; } - DistanceJoint * Physics::newDistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2) + DistanceJoint * Physics::newDistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, bool collideConnected) { - return new DistanceJoint(body1, body2, x1, y1, x2, y2); + return new DistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected); } MouseJoint * Physics::newMouseJoint(Body * body, float x, float y) @@ -154,44 +154,44 @@ namespace box2d return new MouseJoint(body, x, y); } - RevoluteJoint * Physics::newRevoluteJoint(Body * body1, Body * body2, float x, float y) + RevoluteJoint * Physics::newRevoluteJoint(Body * body1, Body * body2, float x, float y, bool collideConnected) { - return new RevoluteJoint(body1, body2, x, y); + return new RevoluteJoint(body1, body2, x, y, collideConnected); } - PrismaticJoint * Physics::newPrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay) + PrismaticJoint * Physics::newPrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected) { - return new PrismaticJoint(body1, body2, x, y, ax, ay); + return new PrismaticJoint(body1, body2, x, y, ax, ay, collideConnected); } - PulleyJoint * Physics::newPulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio) + PulleyJoint * Physics::newPulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio, bool collideConnected) { - return new PulleyJoint(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, ratio); + return new PulleyJoint(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, ratio, collideConnected); } - GearJoint * Physics::newGearJoint(Joint * joint1, Joint * joint2, float ratio) + GearJoint * Physics::newGearJoint(Joint * joint1, Joint * joint2, float ratio, bool collideConnected) { - return new GearJoint(joint1, joint2, ratio); + return new GearJoint(joint1, joint2, ratio, collideConnected); } - FrictionJoint * Physics::newFrictionJoint(Body * body1, Body * body2, float x, float y) + FrictionJoint * Physics::newFrictionJoint(Body * body1, Body * body2, float x, float y, bool collideConnected) { - return new FrictionJoint(body1, body2, x, y); + return new FrictionJoint(body1, body2, x, y, collideConnected); } - WeldJoint * Physics::newWeldJoint(Body * body1, Body * body2, float x, float y) + WeldJoint * Physics::newWeldJoint(Body * body1, Body * body2, float x, float y, bool collideConnected) { - return new WeldJoint(body1, body2, x, y); + return new WeldJoint(body1, body2, x, y, collideConnected); } - WheelJoint * Physics::newWheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay) + WheelJoint * Physics::newWheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected) { - return new WheelJoint(body1, body2, x, y, ax, ay); + return new WheelJoint(body1, body2, x, y, ax, ay, collideConnected); } - RopeJoint * Physics::newRopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength) + RopeJoint * Physics::newRopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength, bool collideConnected) { - return new RopeJoint(body1, body2, x1, y1, x2, y2, maxLength); + return new RopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected); } } // box2d diff --git a/src/modules/physics/box2d/Physics.h b/src/modules/physics/box2d/Physics.h index 94839e865..267a159de 100644 --- a/src/modules/physics/box2d/Physics.h +++ b/src/modules/physics/box2d/Physics.h @@ -158,7 +158,7 @@ namespace box2d * @param x2 Anchor2 along the x-axis. (World coordinates) * @param y2 Anchor2 along the y-axis. (World coordinates) **/ - DistanceJoint * newDistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2); + DistanceJoint * newDistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, bool collideConnected); /** * Creates a new MouseJoint connecting the body with an arbitrary point. @@ -172,7 +172,7 @@ namespace box2d * @param x Anchor along the x-axis. (World coordinates) * @param y Anchor along the y-axis. (World coordinates) **/ - RevoluteJoint * newRevoluteJoint(Body * body1, Body * body2, float x, float y); + RevoluteJoint * newRevoluteJoint(Body * body1, Body * body2, float x, float y, bool collideConnected); /** * Creates a new PrismaticJoint connecting body1 with body2. @@ -181,7 +181,7 @@ namespace box2d * @param ax The x-component of the world-axis. * @param ay The y-component of the world-axis. **/ - PrismaticJoint * newPrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay); + PrismaticJoint * newPrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected); /** * Creates a new PulleyJoint connecting body1 with body2. @@ -191,7 +191,7 @@ namespace box2d * @param anchor2 World anchor on body2. * @param ratio The pulley ratio. **/ - PulleyJoint * newPulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio); + PulleyJoint * newPulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio, bool collideConnected); /** * Creates a new GearJoint connecting joint1 with joint2. @@ -199,21 +199,21 @@ namespace box2d * @param joint2 The second joint. * @param ratio The gear ratio. **/ - GearJoint * newGearJoint(Joint * joint1, Joint * joint2, float ratio); + GearJoint * newGearJoint(Joint * joint1, Joint * joint2, float ratio, bool collideConnected); /** * Creates a new FrictionJoint connecting body1 with body2. * @param x Anchor along the x-axis. (World coordinates) * @param y Anchor along the y-axis. (World coordinates) **/ - FrictionJoint * newFrictionJoint(Body * body1, Body * body2, float x, float y); + FrictionJoint * newFrictionJoint(Body * body1, Body * body2, float x, float y, bool collideConnected); /** * Creates a new WeldJoint connecting body1 with body2. * @param x Anchor along the x-axis. (World coordinates) * @param y Anchor along the y-axis. (World coordinates) **/ - WeldJoint * newWeldJoint(Body * body1, Body * body2, float x, float y); + WeldJoint * newWeldJoint(Body * body1, Body * body2, float x, float y, bool collideConnected); /** * Creates a new WheelJoint connecting body1 with body2. @@ -222,7 +222,7 @@ namespace box2d * @param ax The x-component of the world-axis. * @param ay The y-component of the world-axis. **/ - WheelJoint * newWheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay); + WheelJoint * newWheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected); /** * Creates a new RopeJoint connecting body1 with body2. @@ -232,7 +232,7 @@ namespace box2d * @param y2 Anchor2 along the y-axis. (Local coordinates) * @param maxLength The maximum distance for the bodies. **/ - RopeJoint * newRopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength); + RopeJoint * newRopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength, bool collideConnected); }; // Physics diff --git a/src/modules/physics/box2d/PrismaticJoint.cpp b/src/modules/physics/box2d/PrismaticJoint.cpp index 4556073a7..57ae56b4b 100644 --- a/src/modules/physics/box2d/PrismaticJoint.cpp +++ b/src/modules/physics/box2d/PrismaticJoint.cpp @@ -30,7 +30,7 @@ namespace physics { namespace box2d { - PrismaticJoint::PrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay) + PrismaticJoint::PrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2PrismaticJointDef def; @@ -39,6 +39,7 @@ namespace box2d def.lowerTranslation = 0.0f; def.upperTranslation = 100.0f; def.enableLimit = true; + def.collideConnected = collideConnected; joint = (b2PrismaticJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/PrismaticJoint.h b/src/modules/physics/box2d/PrismaticJoint.h index 38b7787e9..5e0c39222 100644 --- a/src/modules/physics/box2d/PrismaticJoint.h +++ b/src/modules/physics/box2d/PrismaticJoint.h @@ -46,7 +46,7 @@ namespace box2d /** * Creates a new PrismaticJoint connecting body1 and body2. **/ - PrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay); + PrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected); virtual ~PrismaticJoint(); diff --git a/src/modules/physics/box2d/PulleyJoint.cpp b/src/modules/physics/box2d/PulleyJoint.cpp index d45c850da..387a75d41 100644 --- a/src/modules/physics/box2d/PulleyJoint.cpp +++ b/src/modules/physics/box2d/PulleyJoint.cpp @@ -30,12 +30,13 @@ namespace physics { namespace box2d { - PulleyJoint::PulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio) + PulleyJoint::PulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2PulleyJointDef def; def.Initialize(body1->body, body2->body, world->scaleDown(groundAnchor1), world->scaleDown(groundAnchor2), \ world->scaleDown(anchor1), world->scaleDown(anchor2), ratio); + def.collideConnected = collideConnected; joint = (b2PulleyJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/PulleyJoint.h b/src/modules/physics/box2d/PulleyJoint.h index a352c738a..ba1eb201f 100644 --- a/src/modules/physics/box2d/PulleyJoint.h +++ b/src/modules/physics/box2d/PulleyJoint.h @@ -46,7 +46,7 @@ namespace box2d /** * Creates a PulleyJoint connecting body1 to body2. **/ - PulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio); + PulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio, bool collideConnected); virtual ~PulleyJoint(); diff --git a/src/modules/physics/box2d/RevoluteJoint.cpp b/src/modules/physics/box2d/RevoluteJoint.cpp index d725efa6e..cf22a195a 100644 --- a/src/modules/physics/box2d/RevoluteJoint.cpp +++ b/src/modules/physics/box2d/RevoluteJoint.cpp @@ -32,11 +32,12 @@ namespace physics { namespace box2d { - RevoluteJoint::RevoluteJoint(Body * body1, Body * body2, float x, float y) + RevoluteJoint::RevoluteJoint(Body * body1, Body * body2, float x, float y, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2RevoluteJointDef def; def.Initialize(body1->body, body2->body, world->scaleDown(b2Vec2(x,y))); + def.collideConnected = collideConnected; joint = (b2RevoluteJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/RevoluteJoint.h b/src/modules/physics/box2d/RevoluteJoint.h index 51acf26fe..4f5a57064 100644 --- a/src/modules/physics/box2d/RevoluteJoint.h +++ b/src/modules/physics/box2d/RevoluteJoint.h @@ -46,7 +46,7 @@ namespace box2d /** * Creates a new RevoluteJoint connecting body1 and body2. **/ - RevoluteJoint(Body * body1, Body * body2, float x, float y); + RevoluteJoint(Body * body1, Body * body2, float x, float y, bool collideConnected); virtual ~RevoluteJoint(); diff --git a/src/modules/physics/box2d/RopeJoint.cpp b/src/modules/physics/box2d/RopeJoint.cpp index 5cbd26698..6becef476 100644 --- a/src/modules/physics/box2d/RopeJoint.cpp +++ b/src/modules/physics/box2d/RopeJoint.cpp @@ -30,7 +30,7 @@ namespace physics { namespace box2d { - RopeJoint::RopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength) + RopeJoint::RopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2RopeJointDef def; @@ -39,6 +39,7 @@ namespace box2d def.localAnchorA = world->scaleDown(b2Vec2(x1,y1)); def.localAnchorB = world->scaleDown(b2Vec2(x2,y2)); def.maxLength = world->scaleDown(maxLength); + def.collideConnected = collideConnected; joint = (b2RopeJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/RopeJoint.h b/src/modules/physics/box2d/RopeJoint.h index 886f459cd..0d3244b1c 100644 --- a/src/modules/physics/box2d/RopeJoint.h +++ b/src/modules/physics/box2d/RopeJoint.h @@ -44,7 +44,7 @@ namespace box2d /** * Creates a RopeJoint connecting body1 to body2. **/ - RopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength); + RopeJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2, float maxLength, bool collideConnected); virtual ~RopeJoint(); diff --git a/src/modules/physics/box2d/WeldJoint.cpp b/src/modules/physics/box2d/WeldJoint.cpp index 05cb7647f..1b07e04b9 100644 --- a/src/modules/physics/box2d/WeldJoint.cpp +++ b/src/modules/physics/box2d/WeldJoint.cpp @@ -32,11 +32,12 @@ namespace physics { namespace box2d { - WeldJoint::WeldJoint(Body * body1, Body * body2, float x, float y) + WeldJoint::WeldJoint(Body * body1, Body * body2, float x, float y, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2WeldJointDef def; def.Initialize(body1->body, body2->body, world->scaleDown(b2Vec2(x,y))); + def.collideConnected = collideConnected; joint = (b2WeldJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/WeldJoint.h b/src/modules/physics/box2d/WeldJoint.h index ce38a3759..c8bb6856c 100644 --- a/src/modules/physics/box2d/WeldJoint.h +++ b/src/modules/physics/box2d/WeldJoint.h @@ -45,7 +45,7 @@ namespace box2d /** * Creates a new WeldJoint connecting body1 and body2. **/ - WeldJoint(Body * body1, Body * body2, float x, float y); + WeldJoint(Body * body1, Body * body2, float x, float y, bool collideConnected); virtual ~WeldJoint(); diff --git a/src/modules/physics/box2d/WheelJoint.cpp b/src/modules/physics/box2d/WheelJoint.cpp index 01f836338..5ccd7099a 100644 --- a/src/modules/physics/box2d/WheelJoint.cpp +++ b/src/modules/physics/box2d/WheelJoint.cpp @@ -30,12 +30,13 @@ namespace physics { namespace box2d { - WheelJoint::WheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay) + WheelJoint::WheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected) : Joint(body1, body2), joint(NULL) { b2WheelJointDef def; def.Initialize(body1->body, body2->body, world->scaleDown(b2Vec2(x,y)), b2Vec2(ax,ay)); + def.collideConnected = collideConnected; joint = (b2WheelJoint*)createJoint(&def); } diff --git a/src/modules/physics/box2d/WheelJoint.h b/src/modules/physics/box2d/WheelJoint.h index 431ca6fa7..eb4053636 100644 --- a/src/modules/physics/box2d/WheelJoint.h +++ b/src/modules/physics/box2d/WheelJoint.h @@ -47,7 +47,7 @@ namespace box2d /** * Creates a new WheelJoint connecting body1 and body2. **/ - WheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay); + WheelJoint(Body * body1, Body * body2, float x, float y, float ax, float ay, bool collideConnected); virtual ~WheelJoint(); diff --git a/src/modules/physics/box2d/wrap_Physics.cpp b/src/modules/physics/box2d/wrap_Physics.cpp index f72f6f6bd..90c75150e 100644 --- a/src/modules/physics/box2d/wrap_Physics.cpp +++ b/src/modules/physics/box2d/wrap_Physics.cpp @@ -136,7 +136,8 @@ namespace box2d float y1 = (float)luaL_checknumber(L, 4); float x2 = (float)luaL_checknumber(L, 5); float y2 = (float)luaL_checknumber(L, 6); - DistanceJoint * j = instance->newDistanceJoint(body1, body2, x1, y1, x2, y2); + bool collideConnected = luax_optboolean(L, 7, false); + DistanceJoint * j = instance->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected); luax_newtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, (void*)j); return 1; } @@ -157,7 +158,8 @@ namespace box2d Body * body2 = luax_checktype(L, 2, "Body", PHYSICS_BODY_T); float x = (float)luaL_checknumber(L, 3); float y = (float)luaL_checknumber(L, 4); - RevoluteJoint * j = instance->newRevoluteJoint(body1, body2, x, y); + bool collideConnected = luax_optboolean(L, 5, false); + RevoluteJoint * j = instance->newRevoluteJoint(body1, body2, x, y, collideConnected); luax_newtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, (void*)j); return 1; } @@ -170,7 +172,8 @@ namespace box2d float y = (float)luaL_checknumber(L, 4); float ax = (float)luaL_checknumber(L, 5); float ay = (float)luaL_checknumber(L, 6); - PrismaticJoint * j = instance->newPrismaticJoint(body1, body2, x, y, ax, ay); + bool collideConnected = luax_optboolean(L, 7, false); + PrismaticJoint * j = instance->newPrismaticJoint(body1, body2, x, y, ax, ay, collideConnected); luax_newtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, (void*)j); return 1; } @@ -188,8 +191,9 @@ namespace box2d float x2 = (float)luaL_checknumber(L, 9); float y2 = (float)luaL_checknumber(L, 10); float ratio = (float)luaL_optnumber(L, 11, 1.0); + bool collideConnected = luax_optboolean(L, 12, true); // PulleyJoints default to colliding connected bodies, see b2PulleyJoint.h - PulleyJoint * j = instance->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio); + PulleyJoint * j = instance->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio, collideConnected); luax_newtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, (void*)j); return 1; } @@ -199,8 +203,9 @@ namespace box2d Joint * joint1 = luax_checktype(L, 1, "Joint", PHYSICS_JOINT_T); Joint * joint2 = luax_checktype(L, 2, "Joint", PHYSICS_JOINT_T); float ratio = (float)luaL_optnumber(L, 3, 1.0); + bool collideConnected = luax_optboolean(L, 4, false); - GearJoint * j = instance->newGearJoint(joint1, joint2, ratio); + GearJoint * j = instance->newGearJoint(joint1, joint2, ratio, collideConnected); luax_newtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, (void*)j); return 1; } @@ -211,7 +216,8 @@ namespace box2d Body * body2 = luax_checktype(L, 2, "Body", PHYSICS_BODY_T); float x = (float)luaL_checknumber(L, 3); float y = (float)luaL_checknumber(L, 4); - FrictionJoint * j = instance->newFrictionJoint(body1, body2, x, y); + bool collideConnected = luax_optboolean(L, 5, false); + FrictionJoint * j = instance->newFrictionJoint(body1, body2, x, y, collideConnected); luax_newtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, (void*)j); return 1; } @@ -222,7 +228,8 @@ namespace box2d Body * body2 = luax_checktype(L, 2, "Body", PHYSICS_BODY_T); float x = (float)luaL_checknumber(L, 3); float y = (float)luaL_checknumber(L, 4); - WeldJoint * j = instance->newWeldJoint(body1, body2, x, y); + bool collideConnected = luax_optboolean(L, 5, false); + WeldJoint * j = instance->newWeldJoint(body1, body2, x, y, collideConnected); luax_newtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, (void*)j); return 1; } @@ -235,7 +242,8 @@ namespace box2d float y = (float)luaL_checknumber(L, 4); float ax = (float)luaL_checknumber(L, 5); float ay = (float)luaL_checknumber(L, 6); - WheelJoint * j = instance->newWheelJoint(body1, body2, x, y, ax, ay); + bool collideConnected = luax_optboolean(L, 7, false); + WheelJoint * j = instance->newWheelJoint(body1, body2, x, y, ax, ay, collideConnected); luax_newtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, (void*)j); return 1; } @@ -249,7 +257,8 @@ namespace box2d float x2 = (float)luaL_checknumber(L, 5); float y2 = (float)luaL_checknumber(L, 6); float maxLength = (float)luaL_checknumber(L, 7); - RopeJoint * j = instance->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength); + bool collideConnected = luax_optboolean(L, 8, false); + RopeJoint * j = instance->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected); luax_newtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, (void*)j); return 1; }