I guess 500 dynamic bodies: very bad. Here are some performance tips
Dyn4j is single-threaded. So I guess the best way for integration would be to do exactly like the Bullet and have one separate thread for physics - at least that’s how I’d do it.
Exactly! I’m using Bullet integration as a guide, so you have the two options: you can run the Dyn4jAppState on a different threat (by default) with fix timestep (1/60 sec) or on the same threat using variable timeStep. Running it on a different threat is the best way in my opinion (better performance and you will avoid weird results).
From Dyn4j wiki (https://code.google.com/p/dyn4j/wiki/GettingStarted):
"To allow simulation of the scene the World object has two methods that must be called from the game loop: World.update(double) or World.updatev(double). These methods must be passed the elapsed time from the last iteration in seconds.
The World.updatev(double) method can be used if you prefer a variable time step or would like to control when the World updates yourself. The World.update(double) method will only update given the step frequency set in the Settings object.
Note: Variable time steps can reduce accuracy and stability."