Just an update on this: it looks like the following files (at least) have non threadsafe operations going on:
Distance.java
TOI.java
CircleContact.java
EdgeAndCircleContact.java
CollideCircle.java
CollidePoly.java
PointAndCircleContact.java
PointAndPolyContact.java
PolyAndCircleContact.java
PolyAndEdgeContact.java
PolyContact.java
So at the moment, JBox2d is not safe to use with multiple worlds simulated in multiple threads, at least without either editing or locking so that the world steps happen sequentially (which would remove any multi-processor benefit that you might otherwise exploit).
The fix here is not entirely straightforward; I'm going back and forth between performing per-world pooling or per-thread pooling. Per-world might work fine for now, but if we ever get around to adding true multi-threading to the engine (i.e. one world, multiple threads), that will mean going back and fixing up all that stuff then, so it might be better just to deal with it now.
I'll post an update when I decide how to best approach this and get some code in.
Distance.java
TOI.java
CircleContact.java
EdgeAndCircleContact.java
CollideCircle.java
CollidePoly.java
PointAndCircleContact.java
PointAndPolyContact.java
PolyAndCircleContact.java
PolyAndEdgeContact.java
PolyContact.java
So at the moment, JBox2d is not safe to use with multiple worlds simulated in multiple threads, at least without either editing or locking so that the world steps happen sequentially (which would remove any multi-processor benefit that you might otherwise exploit).
The fix here is not entirely straightforward; I'm going back and forth between performing per-world pooling or per-thread pooling. Per-world might work fine for now, but if we ever get around to adding true multi-threading to the engine (i.e. one world, multiple threads), that will mean going back and fixing up all that stuff then, so it might be better just to deal with it now.
I'll post an update when I decide how to best approach this and get some code in.