MovingBlocks / box2d-editor

Automatically exported from code.google.com/p/box2d-editor - migrated here to maybe maintain together with Destination Sol. Original website:
https://code.google.com/archive/p/box2d-editor/
Apache License 2.0
84 stars 21 forks source link

Crash when shape gets connected #43

Open sinsinewave opened 6 years ago

sinsinewave commented 6 years ago

Whenever I try to finish a shape manually, the application crashes with java: /var/lib/jenkins/workspace/libgdx/extensions/gdx-box2d/gdx-box2d/jni/Box2D/Collision/Shapes/b2PolygonShape.cpp:158: void b2PolygonShape::Set(const b2Vec2*, int32): Assertion 'false' failed.

Using auto trace to generate shapes works fine, but if you try to move any of the nodes, the same crash occurs.

I'm running Linux x64, Java 1.8.0.

dlon commented 6 years ago

This error was fixed for me by upgrading libGDX. The crash occurred whenever two adjacent vertices in a polygon were placed near each other (due to an assertion in Box2D related to floating point precision, it seems).

diff --git a/build.gradle b/build.gradle
index 8d2b408..923f09c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,8 +11,8 @@ allprojects {
     version = '1.3.1'
     ext {
         appName = 'Physics Body Editor'
-        gdxVersion = '1.6.4'
-        roboVMVersion = '1.5.0'
+        gdxVersion = '1.9.8'
+        roboVMVersion = '2.3.1'
     }

     repositories {
diff --git a/editor/src/main/java/aurelienribon/bodyeditor/maths/Tracer.java b/editor/src/main/java/aurelienribon/bodyeditor/maths/Tracer.java
index 636bb24..9f66d4e 100644
--- a/editor/src/main/java/aurelienribon/bodyeditor/maths/Tracer.java
+++ b/editor/src/main/java/aurelienribon/bodyeditor/maths/Tracer.java
@@ -13,9 +13,8 @@ import com.badlogic.gdx.utils.Array;
  */
 public class Tracer {
     public static Vector2[][] trace(String path, float hullTolerance, int alphaTolerance, boolean multiPartDetection, boolean holeDetection) {
-        Blending blending = Pixmap.getBlending();
-        Pixmap.setBlending(Blending.None);
         Pixmap pixmap = TextureUtils.getPOTPixmap(path);
+        pixmap.setBlending(Blending.None);

         int w = pixmap.getWidth();
         int h = pixmap.getHeight();
@@ -31,7 +30,6 @@ public class Tracer {
         }

         pixmap.dispose();
-        Pixmap.setBlending(blending);

         Array<Array<Vector2>> outlines;
         try {