Change maxPolygonVertices in Box2D?

I’m working on a project that uses Daniel Shiffman’s Box2D library to arrange a bunch of objects and have run into an issue. It seems that a polygon with more than 8 vertices throws an error, but I’d really like to change that to at least 12 or 14 (see note below).

Digging through the docs, it looks like this can be changed by a variable called maxPolygonVertices in the Java port (see the Settings.java file). But I can’t figure out if there’s a way to change that through the Processing library, or how I might mod the library to allow that, or if I need to change the Java port, then recompile both libraries?

Note: I totally get that more vertices will slow things down, but in my case this isn’t an interactive system where performance is an issue. Basically, I want to use the robust and out-of-the-box collision that Box2D offers to lay out what will eventually be a print. No need for fast frame rate :slight_smile:

1 Like
import shiffman.box2d.*;

void setup() {
  println(org.jbox2d.common.Settings.maxPolygonVertices); // 8
  org.jbox2d.common.Settings.maxPolygonVertices <<= 1;
  println(org.jbox2d.common.Settings.maxPolygonVertices); // 16
  exit();
}
2 Likes

Nice! Any reason not to just do this?

org.jbox2d.common.Settings.maxPolygonVertices = 12;