I’m using ragdolls for the cool effect, but otherwise don’t use physics much, and due to the performance hit, i don’t add the ragdolls to Physics Space until they’re used (ie when a soldier dies).
The only(?) problem i have with this is that the first time a ragdoll is enabled (added to physics space), i notice a severe slowdown, that lasts for 5-7s. The next time there is no problem.
This is of course very annoying, and i’m looking for ways to remedy it, although i don’t have a great deal of experience with bullet.
So, why is there a slow down the first time a ragdoll is added to physics space?
I suspect the first time the code is not JIT-compiled
What you could do is preuse one in some kind of a precaching to force the jit to optimize it before.
During the loading part of the game you can put a ragdoll in the physics space so the code can get “jitted”.