Error creating fixture

So I'm pretty new to Box2D, just started playing around with it tonight. I've been looking at a few example and forums posts on the web and have started trying to get my first object created. Heres the main constructor and variables of my PhysicsObject class, (a base class that will be extended for all of my objects in game).

I'm using the most recent build from GitHub

Code: Select all

BodyType bodyType;
    BodyDef bodyDef;
    FixtureDef fixtureDef;
    Body body;
    Shape shape;

    public PhysicsObject(){}

    public PhysicsObject(float posX, float posY, BodyType bodyType, Shape shape){
        this.bodyType = bodyType;
        this.shape = shape;

        this.bodyDef = new BodyDef();
        this.bodyDef.setType(bodyType);
        this.bodyDef.setPosition(new Vec2(posX, posY));

        this.fixtureDef = new FixtureDef();
        this.fixtureDef.setShape(shape);
        this.fixtureDef.density = PhysicsDefault.defaultDensity;
        this.fixtureDef.friction = PhysicsDefault.defaultFriction;
        this.fixtureDef.restitution = PhysicsDefault.defaultRestitution;

        this.body = PhysicsManager.world.createBody(bodyDef);
        this.body.createFixture(fixtureDef);
    }


I am getting a java crash at this.body.createFixture(fixtureDef);

The parameters being passed are 10f, 10f, BodyType.DYNAMIC, and a simple PolygonShape.

stack trace is as follows:

Code: Select all

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
   at org.jbox2d.pooling.normal.OrderedStack.pop(OrderedStack.java:52)
   at org.jbox2d.pooling.normal.DefaultWorldPool.popVec2(DefaultWorldPool.java:177)
   at org.jbox2d.dynamics.Body.resetMassData(Body.java:683)
   at org.jbox2d.dynamics.Body.createFixture(Body.java:207)
   at couk.infinitebox.sid.Physics.PhysicsObject.<init>(PhysicsObject.java:38)
   at couk.infinitebox.sid.object.GameObject.<init>(GameObject.java:30)
   at couk.infinitebox.sid.object.Box.<init>(Box.java:15)
   at couk.infinitebox.sid.GameWindow.<init>(GameWindow.java:26)
   at couk.infinitebox.sid.Game.main(Game.java:32)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)


Am i initializing my object wrong?

Original thread: https://box2d.org/forum/viewtopic.php?t=9742