Search Unity

Heavy physics in VR - Independent loop

Discussion in 'Physics' started by Eyap, Nov 8, 2019.

  1. Eyap

    Eyap

    Joined:
    Nov 17, 2017
    Posts:
    40
    Hello,
    I need to do heavy physics simulations in both Desktop and VR, for an industrial project.
    I did a first draft using PhysX, but the main problem is the interdependence between the physic and the display : When I have huge calculations, the VR display is stopped (which is a big problem).

    Changing the time settings, i.e "Maximum allowed timestep" seems to help, but doesn't remove completely the problem on huge calculations.

    One solution may be to have a completely independent physics. Is it possible to achieve that with PhysX ? If not, is it possible to achieve that using DOTS and Havok or unity physics ? If not again, do i have another choice than using bullet (with this package) ?


    Unity version, as of now : 2018.3.0f2.

    Thanks !
     
  2. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Are the heavy calculations something you're mainly doing in your own code (calculating forces and so on) or is it just because you have zillions of rigid bodies and PhysX can't go quite fast enough?

    You can't do much about the latter (PhysX bottlenecks), unfortunately, but if more of the computational work is on your side there's probably a lot you can do to speed things up. I wrote a boat simulator that had thousands of forces computed every cycle at a fairly high frequency. Frame rate wasn't good enough until I optimized the heck out of things and got the physics part running something like 10-20 times faster. If all else fails, you can port over the heavy things to a C++ file and get a speed increase upwards of 500%, more if you use intrinsics.
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,445
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    To answer the OP you can have multiple physics scenes in Unity. So you might want one for the players and another for the objects, which are simulated at different rates.

    This however still is vulnerable to a single physics step taking too long, so might want to go a bit custom here... or use DOTS.
     
  5. Eyap

    Eyap

    Joined:
    Nov 17, 2017
    Posts:
    40
    Infortunately, it's the latter.

    @mgear -> i'll take a look, thanks.

    @hippocoder -> I only have one physic-scene (only a few complicated objects). What are you thinking by "a bit custom" ? I'll do some tests with it anyway, it seems interesting.