2
我試圖實現焊縫我Box2D的機構: 爲什麼使用焊接接頭會使我的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很低。我認爲這是因爲我不檢查身體是否是焊接的。 我如何檢查身體是否焊接? 謝謝。
您可以通過比較焊接對象前後的fps來測試是否屬於這種情況。 – 2013-02-16 14:25:55