I tried capsule88.patch at the new box2d upgrade (thanks for a great upgrade!) - however the capsule does not resolve the collisions correctly. The example below shows a capsule which I would expect to fall down. I guess b2PolygonShape::m_radius was not written to support capsules?
Code:
class CapsuleCollision : public Test
{
public:
CapsuleCollision()
{
b2CapsuleShape capsuleShape;
capsuleShape.SetByExtentsY(5.0f, 1.0f);
b2FixtureDef fd;
fd.shape = &capsuleShape;
fd.density = 20.0f;
fd.friction = 0.2f;
fd.restitution = 1.0f;
b2BodyDef bd;
bd.type = b2_dynamicBody;
bd.position = b2Vec2(0.0f, 10.5f);
mBody = m_world->CreateBody(&bd);
mBody->CreateFixture(&fd);
// floor
b2PolygonShape floorShape;
floorShape.SetAsBox(10.0f, 2.0f, b2Vec2(0.0f, 0.0f), 0.0f);
b2BodyDef floorDef;
floorDef.position = b2Vec2(14.0f, 2.0f);
b2Body* ground = m_world->CreateBody(&floorDef);
ground->CreateFixture(&floorShape, 0.0f);
}
static Test* Create()
{
return new CapsuleCollision();
}
b2Body* mBody;
};
{
public:
CapsuleCollision()
{
b2CapsuleShape capsuleShape;
capsuleShape.SetByExtentsY(5.0f, 1.0f);
b2FixtureDef fd;
fd.shape = &capsuleShape;
fd.density = 20.0f;
fd.friction = 0.2f;
fd.restitution = 1.0f;
b2BodyDef bd;
bd.type = b2_dynamicBody;
bd.position = b2Vec2(0.0f, 10.5f);
mBody = m_world->CreateBody(&bd);
mBody->CreateFixture(&fd);
// floor
b2PolygonShape floorShape;
floorShape.SetAsBox(10.0f, 2.0f, b2Vec2(0.0f, 0.0f), 0.0f);
b2BodyDef floorDef;
floorDef.position = b2Vec2(14.0f, 2.0f);
b2Body* ground = m_world->CreateBody(&floorDef);
ground->CreateFixture(&floorShape, 0.0f);
}
static Test* Create()
{
return new CapsuleCollision();
}
b2Body* mBody;
};