Heavy computation, CPU and multi core
Hi,
I am currently struggling with the performance of my application for a real time simulation with sophisticated physics. I am not actually Unity PhysX engine, but my own one, and only using Unity to display the result. I use time sync with a FixedUpdate though. The physic part is in C#/C++ and imported in the project through the Plugins folder.
My core physics engine can run separately from Unity and when I call it from a batch process independently from Unity, I am roughly able to run it 4 to 5 times faster than real time. The computations are then performed evenly on all cores available without any problem.
When I am including my code into Unity, I call the core engine once per FixedUpdate call. However here the performance is terrible and the performance is more 5 to 10 times slower than real time. The FPS is more or less in the 0-2 range, where obviously I need ideally 60. But when looking at the CPU usage, I can see that only one core is used. How come ?
Is there a way to force Unity to spread the heavy CPU computation on multiple cores even though I need to call my program in one single FixedUpdate call ?
Unity version used is the latest 2018.1.
Any tips here would be extremely useful, as I cannot currently run my simulation on my machine.
Thanks a lot