ByteArena/box2d

Simulation instability caused by some joints

maxfish opened this issue · 5 comments

It looks like some of the joints types don't work properly.

I'm implementing a loader for R.U.B.E scenes here https://github.com/maxfish/gojira2d/blob/master/pkg/physics/b2djson_scene.go and I'm trying a lot of different scenes.
I can see that the only joints which work well are revolute, rope, distance and wheel. Motor, prismatic, weld and friction seem to make the simulation explode after a while.

Here is one example of a weld join that is unstable: https://pastebin.com/dPB2xBfV
As soon as body3, while falling, touches body2, body2 sprints away from the screen at high speed

Another example simulating a R.U.B.E scene containing all types of joints:

Any ideas of what could be the cause?

Found a code error for the Prismatic joints when warmStart is true. I've fixed it in my fork maxfish@a623c1c

xtuc commented

Nice! would you mind doing a PR?

Here it is #10
Unfortunately, the other issues are still there. I'll keep checking

After the fixes I've submitted via PRs (including the changes suggested in #7), it looks like the joints (weld, revolute, prismatic, friction, motor, distance, rope, wheel) work as expected.

Here there is an updated video: https://youtu.be/zo81uKfpTzQ

I'm closing this since the issue seems to be fixed now