I need to make a body with more than 8 vertices, and i get the error.
AL lib: (EE) alc_cleanup: 1 device not closed
Assertion failed!
Program: C:\Program Files\Java\jre7\bin\javaw.exe
File: /var/lib/jenkins/workspace/libgdx/gdx/jni/Box2D/Collision/Shapes/b2PolygonShape.cpp, Line 122
Expression: 3 <= count && count <= 8
How can I change that constant?
I found this file https://github.com/libgdx/libgdx/blob/master/gdx/jni/Box2D/Common/b2Settings.h
Here i saw
#define b2_maxPolygonVertices 8
How can I change it from libGDX?
Actually you should not change that, since it would decrease the performance.
What you would do instead is create a Body
with several Fixtures
. Those fixtures will have max 8 vertices and will share some of the vertices, so you will simulate a bigger piece using smaller parts, which are stuck together.
This is called polygon decomposition. Some editors for Box2D do that automatically for you, when you export your scene. Probable the best editor for Box2D out there is R.U.B.E.. There is also a libgdx loader for rube scenes here.
If you create them programmatically you would probably have to do this yourself. Maybe some LibGDX tools like the EarClippingTriangulator could help you here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With