Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to set mass and inertia when using b2FixtureDef #2

Open
eweitnauer opened this issue Mar 5, 2012 · 0 comments
Open

Fails to set mass and inertia when using b2FixtureDef #2

eweitnauer opened this issue Mar 5, 2012 · 0 comments

Comments

@eweitnauer
Copy link

There seems to be a problem when using b2FixtureDef to create a fixture. With the following code

function createBody(x, y, rot, dynamic) {
    var bodyDef = new Box2D.b2BodyDef();
    bodyDef.set_position(new Box2D.b2Vec2(x, y));
    bodyDef.set_angle(rot);
    bodyDef.set_type(dynamic ? Box2D.b2_dynamicBody : Box2D.b2_staticBody);
    var body = world.CreateBody(bodyDef);
    var shape = new Box2D.b2PolygonShape();
    shape.SetAsBox(1, 0.1);
    var fixtureDef = new Box2D.b2FixtureDef();
    fixtureDef.set_density(1);
    fixtureDef.set_shape(shape);
    body.CreateFixture(fixtureDef);
    return body;
  }

I get the error "Uncaught Assertion failed: m_I > 0.0f, at Box2D_v2.2.1/Box2D/Dynamics/b2Body.cpp, 319, void b2Body::ResetMassData()".
What I was also wondering about is why the b2MassData is not available as javascript class in the Box2D namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant