question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Box2D ChainShape is broken

See original GitHub issue

Issue details

The latest Box2D version (1.9.7) fails to create correct chain shapes that used to work with previous versions.

Reproduction steps/code

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.ChainShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.World;

public class Test extends ApplicationAdapter {
	@Override
	public void create () {
		World world = new World(new Vector2(), true);
		BodyDef bodyDef = new BodyDef();
		FixtureDef fixtureDef = new FixtureDef();
		ChainShape shape = new ChainShape();
		float[] vertices = {0f, 0f, 1f, 1f, 0f, 1f};
		shape.createChain(vertices);
		fixtureDef.shape = shape;
		world.createBody(bodyDef).createFixture(fixtureDef);
	}
}

This code snippet works correctly on LibGDX 1.9.6, but fails on LibGDX 1.9.7 with a native error.

Version of LibGDX and/or relevant dependencies

1.9.7 (LibGDX + Box2D).

Stacktrace

java: /var/lib/jenkins/workspace/libgdx/extensions/gdx-box2d/gdx-box2d/jni/Box2D/Collision/Shapes/b2ChainShape.cpp:62: void b2ChainShape::CreateChain(const b2Vec2*, int32): Assertion `count >= 2' failed.

Affected platforms

Note that I checked only on Linux Mint, but other platforms are expected to be affected as well.

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
czyzbycommented, Nov 2, 2017

@Tom-Ski Is a hotfix release planned or should we wait a few months for 1.9.8?

0reactions
Tom-Skicommented, Feb 20, 2018

This issue is a duplicate. See issue referred too for the tracking of this issue. Fixed and released in 1.9.8 as the tag on the commit shows.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ChainShape in Box2D - java - Stack Overflow
1 Answer 1 ... ChainShape chain = new ChainShape(); createChain().Vec2[] vertices = new Vec2[2]; vertices[0] = box2d.coordPixelsToWorld(0,150); vertices[1] = ...
Read more >
Dynamics Module - Box2D
When the body breaks, you can destroy a fixture and recreate it on a new body. ... If the fixture has children, such...
Read more >
Movement of body after applying weld joint
I am using Box2D with LibGDX. I've tried this: polygon1.applyLinearImpulse(new Vector2(-5, 0), polygon1.getWorldCenter() ...
Read more >
Chain (rope) with box2d - Impact Forums
The biggest potential issue you may encounter is that the ImpactJS Box2D ... It was not working because function Apply gravity only applied...
Read more >
"Vertices of chain shape are too close together" HELP!
enableScene() returns false // // then the Kinect is not working correctly // // make ... createPolygon(); // create the box2d body from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found