Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
EstimateCollisionResponse.cpp File Reference

Functions

JPH_NAMESPACE_BEGIN void EstimateCollisionResponse (const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, CollisionEstimationResult &outResult, const ContactSettings &inContactSettings, float inMinVelocityForRestitution, uint inNumIterations)
 

Function Documentation

◆ EstimateCollisionResponse()

JPH_NAMESPACE_BEGIN void EstimateCollisionResponse ( const Body & inBody1,
const Body & inBody2,
const ContactManifold & inManifold,
CollisionEstimationResult & outResult,
const ContactSettings & inContactSettings,
float inMinVelocityForRestitution = 1.0f,
uint inNumIterations = 10 )

This function estimates the contact impulses and body velocity changes as a result of a collision. It can be used in the ContactListener::OnContactAdded to determine the strength of the collision to e.g. play a sound or trigger a particle system. This function is accurate when two bodies collide but will not be accurate when more than 2 bodies collide at the same time as it does not know about these other collisions.

Parameters
inBody1Colliding body 1
inBody2Colliding body 2
inManifoldThe collision manifold
outResultA structure that contains the estimated contact and friction impulses and the resulting body velocities
inContactSettingsThe contact settings for this contact
inMinVelocityForRestitutionMinimal velocity required for restitution to be applied (see PhysicsSettings::mMinVelocityForRestitution)
inNumIterationsNumber of iterations to use for the impulse estimation (see PhysicsSettings::mNumVelocitySteps, note you can probably use a lower number for a decent estimate). If you set the number of iterations to 1 then no friction will be calculated.