我無法弄清楚如何使接點斷裂。基本上,一個旋轉關節被添加到b2PolygonShape的兩個b2Body中。但是當一輛汽車在它上面移動時,接頭不會中斷。而是汽車穿過多邊形的形狀。box2d b2RevoluteJoint not breaking
試過下面沒有運氣到目前爲止
b2BodyDef bodyDef;
bodyDef.position.Set(xPos/PTM_RATIO, yPos/PTM_RATIO);
bodyDef.angle = atan(dy/dx);
bodyDef.userData = sp;
bodyDef.type = b2_dynamicBody;
b2Body* body = world->CreateBody(&bodyDef);
b2PolygonShape shape;
b2Vec2 rectangle1_vertices[4];
rectangle1_vertices[0].Set(-len/2, -width/2);
rectangle1_vertices[1].Set(len/2, -width/2);
rectangle1_vertices[2].Set(len/2, width/2);
rectangle1_vertices[3].Set(-len/2, width/2);
shape.Set(rectangle1_vertices, 4);
b2FixtureDef fd;
fd.shape = &shape;
fd.density = 10.0f;
body->CreateFixture(&fd);
edge.body = body;
// The code below is not breaking the joint even though enableLimit = true.
b2RevoluteJointDef jointDef;
b2Vec2 anchor = vertex.body->GetPosition();
jointDef.lowerAngle = -10.0 * b2_pi/180.0f;
jointDef.upperAngle = 10.0 * b2_pi/180.0f;
jointDef.enableLimit = true;
jointDef.maxMotorTorque = 1000.0f;
jointDef.enableMotor = true;
//prevEdge and edge are b2Body with b2PolygonShape.
jointDef.Initialize(prevEdge.body, edge.body, anchor);
world->CreateJoint(&jointDef);
感謝您對Box2D的幫助