Browse Source

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.
Bart van Strien 9 years ago
parent
commit
57e4ec78e3
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/modules/physics/box2d/MouseJoint.cpp

+ 3 - 0
src/modules/physics/box2d/MouseJoint.cpp

@@ -36,6 +36,9 @@ MouseJoint::MouseJoint(Body *body1, float x, float y)
 	: Joint(body1)
 	: Joint(body1)
 	, joint(NULL)
 	, joint(NULL)
 {
 {
+	if (body1->getType() == Body::BODY_KINEMATIC)
+		throw love::Exception("Cannot attach a MouseJoint to a kinematic body");
+
 	b2MouseJointDef def;
 	b2MouseJointDef def;
 
 
 	def.bodyA = body1->world->getGroundBody();
 	def.bodyA = body1->world->getGroundBody();