Box2D ChainShape is broken
See original GitHub issueIssue 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:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Tom-Ski Is a hotfix release planned or should we wait a few months for 1.9.8?
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.