diff --git a/3rd/box2d/src/box2d_World.cpp b/3rd/box2d/src/box2d_World.cpp index 7063ecb4..e28293f2 100644 --- a/3rd/box2d/src/box2d_World.cpp +++ b/3rd/box2d/src/box2d_World.cpp @@ -156,5 +156,15 @@ void PyWorld::_register(VM* vm, PyObject* mod, PyObject* type){ self._debug_draw.draw_like = args[1]; return vm->None; }); -} + + // joints + vm->bind(type, "create_weld_joint(self, a, b)", [](VM* vm, ArgsView args){ + PyWorld& self = _CAST(PyWorld&, args[0]); + PyBody& bodyA = CAST(PyBody&, args[1]); + PyBody& bodyB = CAST(PyBody&, args[2]); + b2WeldJointDef def; + def.Initialize(bodyA.body, bodyB.body, bodyA.body->GetWorldCenter()); + b2Joint* p = self.world.CreateJoint(&def); + return VAR(p); // void_p + }); } // namespace pkpy \ No newline at end of file diff --git a/docs/modules/box2d.md b/docs/modules/box2d.md index 44009936..784dd136 100644 --- a/docs/modules/box2d.md +++ b/docs/modules/box2d.md @@ -88,6 +88,9 @@ class World: def set_debug_draw(self, draw: _DrawLike): """set the debug draw object.""" + def create_weld_joint(self, body_a: 'Body', body_b: 'Body'): + """create a weld joint between two bodies.""" + class Body: type: int # 0-static, 1-kinematic, 2-dynamic, by default 2 gravity_scale: float