我正在尝试为我的 box2d 主体实现焊接接头:
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);
//}
}
但我的fps非常低。我认为是因为我不检查身体是否是要焊接的。如何检查车身是否焊接?谢谢。