ph_setcorrections (var ERP, var CFM);
ph_setcollisions (var ERP, var CFM);
Sets global correction factors for physis constraints (ph_setcorrections)
and physics collision contact points (ph_setcollisions). ERP stands
for Error Reduction Parameter and defines how quickly misaligned constraints
get adjusted. CFM means Contact Force Mixing and determines
how 'soft' a constraint or collision contact reacts.
Parameters:
ERP |
Error Reduction Parameter [0..100000], default: 20000 |
CFM |
Contact Force Mixing [0..100000], default: 0.1 |
Returns:
1 if successful, 0 otherwise.
Speed:
Fast
Remarks:
- Setting ERP to 0 will have constrained objects drift apart after some
time because errors get not corrected. With ERP set to its maximum
value any constrained objects that get forced into an unacceptable position/orientation
will be corrected within a single frame. This however can cause overshooting
and it is thus recommended to use smaller values instead.
- Setting
CFM to 0 results in very stiff joints (this will lead to errors
though- do not do it). Setting CFM to its maximum value makes constrained
objects act as though limited by rubber bands.
- Constraints (joints) chould be allowed to have more "wiggle
room", whereas collisions need to be resolved more quickly. The default ERP
value for ph_setcorrections is 20000 which results in ca. 20% of a
penetration to be resolved per physics frame. For ph_setcollisions often
a larger value like 80% (80000) is desired, so that colliding objects
are pushed apart immediately. The optimal values depends on your entity's
sizes and speeds.
Example:
ph_setcorrections(0,0); // switch off error correction for joints
ph_setcollisions(20000, 100); // make collision contacts soft/spongy
ph_setcollisions(100000, 0); // make collision contacts really hard
See also:
phent_setelasticity
► latest
version online