NewtonInvalidateCache

From Newton Wiki
Revision as of 08:02, 10 June 2019 by WikiSysop (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

NewtonInvalidateCache

void NewtonInvalidateCache (const NewtonWorld* const newtonWorld)

Usage

Reset all internal engine states by clearing all of the internal contact joints and sorting the body and joint lists.

Parameters

void NewtonInvalidateCache (const NewtonWorld* const newtonWorld)

Return

  • (Procedure)

Remarks

This function is useful when deterministic results are needed, for example precise physical simulations or in multiplayer games that work in fixed frame rate and synchronize using "lock step" (also called the "tick sync") method.

  • This function should only be called after initializing the game world, or after adding or removing a body or joint to the scene before calling the next NewtonUpdate call, do not call it during callbacks or every single frame, doing so may severely degrade performance.
  • From the moment you call this function, Newton will run deterministic as long as you run the physics in single thread, see NewtonSetThreadsCount.
  • Changing the floating point rounding modes using FLDCW asm opcode, or any non-deterministic input from the application to newton will break determinism.
  • Although using different update times per frame will still keep the simulation deterministic, it will be only deterministic as long as the order and timing of updates stays always identical.
  • Determinism may not work the same on all platforms and architectures (a deterministic simulation on x86 under Windows might not be indentical to simulation on a iphone, although they would both run deterministic, the results may be different due to different precision of floating point math on different CPUs, same may be true when using cpu extension sets such as SSE)
  • Call this function whenever you want to create a reproducible simulation from a pre-defined initial condition.
  • It does *not* suffice to merely reset the position and velocity of objects. This is because Newton takes advantage of frame-to-frame coherence for performance reasons.
  • This function must be called outside of any Newton Update callbacks.
  • Note: this kind of synchronization incurs a heavy performance penalty if called during each update.

See also

NewtonUpdate


See also

NewtonUpdate NewtonSetPlatformArchitecture NewtonGetPlatformArchitecture NewtonSetThreadsCount NewtonGetThreadsCount