Explorar el Código

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 hace 9 años
padre
commit
57e4ec78e3
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  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(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();