Jolt Physics
A multi core friendly Game Physics Engine
|
#include <Jolt/Jolt.h>
#include <Jolt/Physics/Collision/EstimateCollisionResponse.h>
#include <Jolt/Physics/Body/Body.h>
JPH_NAMESPACE_BEGIN 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.
inBody1 | Colliding body 1 |
inBody2 | Colliding body 2 |
inManifold | The collision manifold |
outResult | A structure that contains the estimated contact and friction impulses and the resulting body velocities |
inCombinedFriction | The combined friction of body 1 and body 2 (see ContactSettings::mCombinedFriction) |
inCombinedRestitution | The combined restitution of body 1 and body 2 (see ContactSettings::mCombinedRestitution) |
inMinVelocityForRestitution | Minimal velocity required for restitution to be applied (see PhysicsSettings::mMinVelocityForRestitution) |
inNumIterations | Number 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. |