I'm try to get things work with Box2D. I can compile my program but when I try to run I got an error. Here is code:
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(x, y);
body = world.CreateBody(&bodyDef);
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(w, h);
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.3f;
body->CreateFixture(&fixtureDef);
Error:
mezo: ~/cpp/Box2D_v2.2.1/Box2D/Collision/Shapes/b2PolygonShape.cpp:352: virtual void b2PolygonShape::ComputeMass(b2MassData*, float32) const: Assertion `area > 1.19209289550781250000e-7F' failed.
I figured out if comment out fixtureDef.density = 1.0f; I can compile, run and everything works, except body is moving 2 fast ( because of density maybe ?), It also works if I set density to 0.
Looks like the area of your shape is extremely small. Check w, h
values. The speed of the body does nothing with it's density.