NewtonUpdateAsync

From Newton Wiki
Jump to: navigation, search

NewtonUpdateAsync

void NewtonUpdateAsync (const NewtonWorld* const newtonWorld, dFloat timestep)

Usage

Advances the simulation by an amount of time (Multi-threaded).

Parameters

  • const NewtonWorld *newtonWorld - pointer to the Newton world
  • dFloat timestep - timestep in seconds

Description

This is the heart of the engine. This command updates the entire Newton world, by the amount of time passed (in seconds). This will collect (by calling ForceAndTorqueCallback) and apply any forces to NewtonBodies in the NewtonWorld, detect collisions, and eventually come up with the new positions and orientations for all bodies in the system (and again call the appropriate callbacks).

Remarks

  • Newton only accepts values for elapsed in the following range: 20fps < elapsed < 600fps. if you pass a value outside this range, it will be clamped. For more details see What value should I pass to "NewtonUpdate?

  • Unlike NewtonUpdate, NewtonUpdateAsync will not wait for the update to complete, running the callbacks and performing simulation in a completely independant thread.
  • Using NewtonUpdateAsync with subframe interplation for you graphics loop you can get maximum performance possible, in order of several hundreds of fps, while the physics runs at a fix frame rate in the background.
  • This function will advance the simulation by the amount of time specified by timestep. The Newton Engine does not perform sub-steps, and does not need tuning parameters. It is the responsibility of the application to ensure that timestep is small enough to guarantee physics stability.

Examples

//get elapsed time (depends on your system)
float elapsed = System->get_elapsed();
NewtonUpdateAsync( mWorld, elapsed );

See also

NewtonInvalidateCache, NewtonUpdate, NewtonWaitForUpdateToFinish