Followup fix Bugfix [#31629]: Cloth simulation collisions used still too high repulsions.

This commit is contained in:
Daniel Genrich
2012-06-01 16:50:12 +00:00
parent 3ea554e0a2
commit 9efc294d45

View File

@@ -302,6 +302,10 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
// Apply repulse impulse if distance too short
// I_r = -min(dt*kd, m(0, 1d/dt - v_n))
// DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this:
// v += impulse; x_new = x + v;
// We don't use dt!!
// DG TODO: Fix usage of dt here!
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance;
@@ -324,15 +328,18 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
else
{
// Apply repulse impulse if distance too short
// I_r = -min(dt*kd, m(0, 1d/dt - v_n))
// I_r = -min(dt*kd, max(0, 1d/dt - v_n))
// DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this:
// v += impulse; x_new = x + v;
// We don't use dt!!
float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
float d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance;
if ( d > ALMOST_ZERO) {
// stay on the safe side and clamp repulse
float repulse = d*1.0f/spf;
float repulse = d;
float impulse = repulse / (3.0f * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); // original 2.0 / 0.25
float impulse = repulse / (( 1.0f + w1*w1 + w2*w2 + w3*w3 )); // original 2.0 / 0.25
VECADDMUL ( i1, collpair->normal, impulse );
VECADDMUL ( i2, collpair->normal, impulse );
VECADDMUL ( i3, collpair->normal, impulse );