diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2012-06-01 20:50:12 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2012-06-01 20:50:12 +0400 |
commit | 9efc294d457c974cc8626ec50c90f755ed25c9e5 (patch) | |
tree | a2904fbe6d28df19653c88431b280402a5e1ab0e /source | |
parent | 3ea554e0a26857bb8bc37792b665f63cef3689d5 (diff) |
Followup fix Bugfix [#31629]: Cloth simulation collisions used still too high repulsions.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index e680d9889cd..b90cc9d5958 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -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 ); |