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

Go to the source code of this file.

Classes

struct  CollisionEstimationResult
 A structure that contains the estimated contact and friction impulses and the resulting body velocities. More...
 
struct  CollisionEstimationResult::Impulse
 

Functions

JPH_EXPORT void EstimateCollisionResponse (const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, CollisionEstimationResult &outResult, float inCombinedFriction, float inCombinedRestitution, float inMinVelocityForRestitution=1.0f, uint inNumIterations=10)
 

Function Documentation

◆ EstimateCollisionResponse()

JPH_EXPORT void EstimateCollisionResponse ( const Body inBody1,
const Body inBody2,
const ContactManifold inManifold,
CollisionEstimationResult outResult,
float  inCombinedFriction,
float  inCombinedRestitution,
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
inCombinedFrictionThe combined friction of body 1 and body 2 (see ContactSettings::mCombinedFriction)
inCombinedRestitutionThe combined restitution of body 1 and body 2 (see ContactSettings::mCombinedRestitution)
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.