NewtonMaterialSetCompoundCollisionCallback

From Newton Wiki
Jump to: navigation, search

NewtonMaterialSetCompoundCollisionCallback

void NewtonMaterialSetCompoundCollisionCallback(const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnCompoundSubCollisionAABBOverlap compoundAabbOverlap)

Usage

Set userData and the functions event handlers for the material interaction between two physics materials .

Parameters

  • const NewtonWorld* const newtonWorld
  • int id0
  • int id1
  • NewtonOnCompoundSubCollisionAABBOverlap compoundAabbOverlap

Return

  • (Procedure)

Description

  • When the AABB extend of the collision geometry of two bodies overlap, Newton collision system retrieves the material
  • interaction that defines the behavior between the pair of bodies. The material interaction is collected from a database of materials,
  • indexed by the material gruopID assigned to the bodies. If the material is tagged as non collidable,
  • then no action is taken and the simulation continues.
  • If the material is tagged as collidable, and a *aabbOverlap* was set for this material, then the *aabbOverlap* function is called.
  • If the function *aabbOverlap* returns 0, no further action is taken for this material (this can be use to ignore the interaction under
  • certain conditions). If the function *aabbOverlap* returns 1, Newton proceeds to calculate the array of contacts for the pair of
  • colliding bodies. If the function *processCallback* was set, the application receives a callback for every contact found between the
  • two colliding bodies. Here the application can perform fine grain control over the behavior of the collision system. For example,
  • rejecting the contact, making the contact frictionless, applying special effects to the surface etc.
  • After all contacts are processed and if the function *endCallback* was set, Newton calls *endCallback*.
  • Here the application can collect information gathered during the contact-processing phase and provide some feedback to the player.
  • A typical use for the material callback is to play sound effects. The application passes the address of structure in the *userData* along with
  • three event function callbacks. When the function *aabbOverlap* is called by Newton, the application resets a variable say *maximumImpactSpeed*.
  • Then for every call to the function *processCallback*, the application compares the impact speed for this contact with the value of
  • *maximumImpactSpeed*, if the value is larger, then the application stores the new value along with the position, and any other quantity desired.
  • When the application receives the call to *endCallback* the application plays a 3d sound based in the position and strength of the contact.

See also