I'm trying to implement weld joints for my box2d bodies:
for(pos = _contactListener->_contacts.begin();
pos != _contactListener->_contacts.end(); ++pos) {
MyContact contact = *pos;
b2Body *bodyA = contact.fixtureA->GetBody();
b2Body *bodyB = contact.fixtureB->GetBody();
b2Vec2 worldCoordsAnchorPoint = bodyA->GetWorldPoint (b2Vec2(0,0));
b2WeldJointDef weldJointDef;
weldJointDef.bodyA = bodyA;
weldJointDef.bodyB = bodyB;
weldJointDef.localAnchorA = weldJointDef.bodyA->GetLocalPoint(worldCoordsAnchorPoint);
weldJointDef.localAnchorB = weldJointDef.bodyB->GetLocalPoint(worldCoordsAnchorPoint);
weldJointDef.referenceAngle = weldJointDef.bodyB->GetAngle() - weldJointDef.bodyA->GetAngle();
weldJointDef.collideConnected = true;
weldJointDef.userData = @"tile";
weldJointDef.Initialize(bodyA, bodyB, worldCoordsAnchorPoint);
world->CreateJoint(&weldJointDef);
//}
}
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.