Time step

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Time step

Postby blackbird_dream » Tue Dec 08, 2020 3:47 pm

Hi.
I'd like to perform physik at 1000 Hz (constant time step).
Then display the scene with 2 options
1) when it can. at the risk of non smooth motions
2) slow motion (every 10 timesteps)

what are the best settings for that ?
Sorry if it's evergreen content.
I've read posts about the topic but it's not crystal clear in my mind.

Many thks
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: Time step

Postby Julio Jerez » Tue Dec 08, 2020 5:40 pm

you can call the function to set the number of sub steps.
the time step you pass to the engine will be divided by that number.
when running async, the update does not interfere with graphics
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Time step

Postby blackbird_dream » Fri Dec 11, 2020 7:12 am

ok thks
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: Time step

Postby Julio Jerez » Fri Dec 11, 2020 11:29 am

a 1000 fps is probably an over kill, but you can try any combination, I find that for most accurate simulation some from 250 to 300 has always gives expected result using newton for most people who has contacted my. Newton integrators are are RK4 internally so you get an implicit subdivision but a factor of four of the time step, in fact an RK4 step is much, much better than 4 eulers sub steps.
what you have to take int account is that the constraint dynamics there are make highly non linear forces and torque. for example newton is probably one the only physics solver that correctly model gyroscopy toques so that alone make the integration hard and we pay a price in performance for that.
but you can experiment with different time steps.

the function is this
NewtonSetNumberOfSubsteps (m_world, m_solverSubSteps);

you set that before you enter the loop and the you can newton update with the the time step. for example is the then step is 0.016 (that 60 fps) and you want to run the physics at 0.002 ms per step

them you do this
n = 0.016 / 0.002 = 8

then you call
Code: Select all
NewtonSetNumberOfSubsteps (m_world, 8);


and the update loop is
Code: Select all
      while (!exit)
      {
         NewtonUpdateAsync(m_world, 0.016);
      }


or
Code: Select all
      while (!exit)
      {
         NewtonUpdate(m_world, 0.016);
      }


the NewtonUpdateAsync return immidialtlly, so the physics run concurrent with your app.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 28 guests