title: Why does using weld joints make my Box2D program slow?
body: <p>I'm trying to implement weld joints for my box2d bodies:
  </p>
  
  <pre><code>for(pos = _contactListener-&gt;_contacts.begin(); 
      pos != _contactListener-&gt;_contacts.end(); ++pos) {
      MyContact contact = *pos;
  
  
      b2Body *bodyA = contact.fixtureA-&gt;GetBody();
      b2Body *bodyB = contact.fixtureB-&gt;GetBody();
  
      b2Vec2 worldCoordsAnchorPoint = bodyA-&gt;GetWorldPoint (b2Vec2(0,0)); 
      b2WeldJointDef weldJointDef;
      weldJointDef.bodyA = bodyA;
      weldJointDef.bodyB = bodyB;
  
      weldJointDef.localAnchorA = weldJointDef.bodyA-&gt;GetLocalPoint(worldCoordsAnchorPoint);
      weldJointDef.localAnchorB = weldJointDef.bodyB-&gt;GetLocalPoint(worldCoordsAnchorPoint);
      weldJointDef.referenceAngle = weldJointDef.bodyB-&gt;GetAngle() - weldJointDef.bodyA-&gt;GetAngle();
      weldJointDef.collideConnected = true;
      weldJointDef.userData = @"tile";
  
      weldJointDef.Initialize(bodyA, bodyB, worldCoordsAnchorPoint);
      world-&gt;CreateJoint(&amp;weldJointDef);
      //}
  }
  </code></pre>
  
  <p>but my fps are very low. I think it because I don't check that bodies are the ones to weld.
  How can I check that body are weld?
  Thanks.</p>