19-10-2018, 09:35 PM
(This post was last modified: 19-10-2018, 09:37 PM by josemendez.)
(19-10-2018, 06:39 PM)mmortall Wrote: Hello.
We have a performance issue and we found this lines in profiler.
It seems like this operations leads to a huge performance drop. Can it be optimized in some way? Thanks.
This happens when we drop the soft body and it is simulated.
WaitForAllTasks() is being called 6 times per frame. This means physics is being executed a lot of times each frame, no wonder it takes a lot of time. All contacts in the scene are being copied between C++ and C# multiple times, so you're paying the cost of struct marshaling, x6. (Also, make sure that you absolutely need to use contact callbacks, you might not need to pay even x1).
Make sure you're not running into death spiralling. If you are, reduce Unity's "max physics timestep" parameter. See:
https://www.youtube.com/watch?v=sUVqa-72-Ms
Also remember than deep profiling adds a 60-70% overhead, so things will be much much faster with profiling disabled.