NewtonContactProcess

From Newton Wiki
Jump to: navigation, search

typedef int (_cdecl *NewtonContactProcess) (const NewtonMaterial* material, const NewtonContact* contact);

This callback can bet set by NewtonMaterialSetCollisionCallback. To understand it better see NewtonContactBegin first.

It's called for each contact point between two bodies colliding. Note that it need not to be called even though NewtonContactBegin was called, because overlaping of AABB boxed doesn't mean that there are contact points! So don;t be surprised when directly after NewtonContactBegin you will get NewtonContactEnd called(if you set it, of course).

There's a lot of function that can be used in process callback:

NewtonMaterialDisableContact NewtonMaterialGetMaterialPairUserData NewtonMaterialGetContactFaceAttribute NewtonMaterialGetBodyCollisionID NewtonMaterialGetContactNormalSpeed NewtonMaterialGetContactForce NewtonMaterialGetContactPositionAndNormal NewtonMaterialGetContactTangentDirections NewtonMaterialGetContactTangentSpeed NewtonMaterialSetContactSoftness NewtonMaterialSetContactElasticity NewtonMaterialSetContactFrictionState NewtonMaterialSetContactStaticFrictionCoef NewtonMaterialSetContactKineticFrictionCoef NewtonMaterialSetContactTangentAcceleration NewtonMaterialContactRotateTangentDirections

because of this diversity there are plenty of possibilities what this callback could be used for. For example: contact rejection based on some parameters, triggers, determining hit force, playing sounds, applying damping on too strong hit etc