Fix deadlock in physics system (#6414)
- Reorder unlock and notify_all calls to avoid notifying when not all worker threads are waiting.
- Make sure main thread does not attempt to exclusively lock mSimulationMutex while not all workers are done with previous frame.
- Replace mNewFrame flag by counter to avoid modification from multiple threads.
See this comment for more details.
Fixes #6414 (closed).
Edited by elsid