Я пытаюсь установить центр масс для копьевидного объекта. Вот соответствующий код:
// Create spear body and shape
b2BodyDef spearBodyDef;
spearBodyDef.type = b2_dynamicBody;
spearBodyDef.position.Set(100.0/PTM_RATIO, 100.0/PTM_RATIO);
//spearBodyDef.angle = 45.0 * (180.0f/b2_pi);
spearBodyDef.userData = _spear;
_spearBody = _world->CreateBody(&spearBodyDef);
b2PolygonShape spearShape;
spearShape.Set(verts, num);
b2FixtureDef spearShapeDef;
spearShapeDef.shape = &spearShape;
spearShapeDef.density = 100.0f;
spearShapeDef.friction = 0.9f;
spearShapeDef.restitution = 0.1f;
_spearBody->CreateFixture(&spearShapeDef);
b2MassData massD;
_spearBody->GetMassData(&massD);
b2Vec2 centerV;
centerV.x = 25.0;
centerV.y = -1.0f;
massD.center = centerV;
_spearBody->SetMassData(&massD);
Это приводит к сбою приложения из-за ошибки подтверждения:
Jul 5 02:52:23 unknown UIKitApplication:com.youcompany.box[0xb15c][10311] <Notice>: Assertion failed: (m_I > 0.0f),
Jul 5 02:52:23 unknown UIKitApplication:com.youcompany.box[0xb15c][10311] <Notice>: function SetMassData, file /User
Jul 5 02:52:23 unknown UIKitApplication:com.youcompany.box[0xb15c][10311] <Notice>: s/~/Desktop/box/box/libs/Box
Jul 5 02:52:23 unknown UIKitApplication:com.youcompany.box[0xb15c][10311] <Notice>: 2D/Dynamics/b2Body.cpp, line 357
Jul 5 02:52:23 unknown UIKitApplication:com.youcompany.box[0xb15c][10311] <Notice>: .
Что я делаю не так? Спасибо