NewtonSetIslandUpdateEvent

From Newton Wiki
Jump to: navigation, search

NewtonSetIslandUpdateEvent

void NewtonSetIslandUpdateEvent (const NewtonWorld* const newtonWorld, NewtonIslandUpdate islandUpdate)

Usage

Assign an event function for collision island updates.

Parameters

  • const NewtonWorld* newtonWorld - pointer to the Newton world.
  • NewtonIslandUpdate islandUpdate - pointer to a callback function used to respond to changes in collision islands.

Return

  • Nothing.

Description

Assign an event function for collision island updates.

The event handler callback function will be called in case a collision island is changed by Newton. The event handler receives as parameter a pointer to the collision island object and the number of bodies in the collision island.

Remarks

  • The application can set a function callback to be called just after the array of all bodies making an island of connected bodies are collected. This function will be called just before the array is accepted for contact resolution and integration.
  • The callback function must return an integer 0 or 1 to either skip or process the bodies in that particular island.
  • Applications can leverage this function to implement an game physics LOD.
  • For example the application can determine the AABB of the island and check it against the view frustum. If the entire island AABB is invisible, then the application can suspend its simulation, even if it is not in equilibrium.
  • Other possible applications are to implement of a visual debugger, or freeze entire islands for application specific reasons.
  • The application must not create, modify, or destroy bodies inside the callback or risk putting the engine into an undefined state (ie it will crash, if you are lucky).

See also

NewtonIslandGetBody NewtonIslandGetBodyAABB