i work with libGDX. When i am trying in Box2D to create a fixture having a polygon-shape i get following error.:
java: ./Box2D/Collision/b2Distance.h:103: const b2Vec2& b2DistanceProxy::GetVertex(int32) const: Assertion `0 <= index && index < m_count' failed.
When i don't do Box2D's world.step()
, i don't get this error any more.
So i commented out everything in my WorldContactListener and i added world.step() again.
I am still getting the same Error.
When i replace the polygon-shape with a circle-shape everything works fine. So here is how i am creating my polygon-shape:
PolygonShape shape = new PolygonShape();
float ppm = Game.PixelsPerMeter;
Vector2[] vertices = new Vector2[3];
vertices[0] = new Vector2(0f/ppm , 0f );
vertices[1] = new Vector2(1/ppm , 1f/ppm );
vertices[2] = new Vector2(0f/ppm ,1f/ppm);
shape.set(vertices);
And here is how i am adding everything it the Box2D world:
float ppm = Game.PixelsPerMeter
BodyDef bdef = new BodyDef();
bdef.position.set(100/ ppm, 200/ ppm);
bdef.type = BodyDef.BodyType.DynamicBody;
b2dbody = world.createBody(bdef);
FixtureDef mainFdef = new FixtureDef();
mainFdef.shape = Shape; //this is the shape from above of course
b2dbody.createFixture(mainFdef).setUserData(this);
I would be really happy if you could tell me whats wrong!
Thank You
Error:(382, 17) Gradle: error: no suitable method found for set(Vector2[],int) method PolygonShape.set(Vector2[]) is not applicable (actual and formal argument lists differ in length) method PolygonShape.set(float[]) is not applicable (actual and formal argument lists differ in length) method PolygonShape.set(float[],int,int) is not applicable (actual and formal argument lists differ in length)
. There is no method that takes these two parameters. – strammermax