From 57e4ec78e3192aa586f388c50923451b2e6740d7 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Tue, 2 Aug 2016 14:26:51 +0200 Subject: [PATCH] Prevent attaching a MouseJoint to a kinematic body (fixes #1185) It turns out, calling World:update() after attaching a MouseJoint to a kinematic body causes an exception. Normally the wrapper catches the exception, but somehow this exception cannot be caught. Wonderful. --- src/modules/physics/box2d/MouseJoint.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/physics/box2d/MouseJoint.cpp b/src/modules/physics/box2d/MouseJoint.cpp index 08e41d35e..96768e870 100644 --- a/src/modules/physics/box2d/MouseJoint.cpp +++ b/src/modules/physics/box2d/MouseJoint.cpp @@ -36,6 +36,9 @@ MouseJoint::MouseJoint(Body *body1, float x, float y) : Joint(body1) , joint(NULL) { + if (body1->getType() == Body::BODY_KINEMATIC) + throw love::Exception("Cannot attach a MouseJoint to a kinematic body"); + b2MouseJointDef def; def.bodyA = body1->world->getGroundBody();