[Bf-blender-cvs] [2d48769a8b] cloth-improvements: Fix stability issue and further make collisions inelastic

Luca Rood noreply at git.blender.org
Fri Jan 20 05:38:36 CET 2017


Commit: 2d48769a8b8953d1307fad62b1519295acdab01d
Author: Luca Rood
Date:   Wed Jan 18 23:06:33 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rB2d48769a8b8953d1307fad62b1519295acdab01d

Fix stability issue and further make collisions inelastic

The repulse when colliding points are approaching was being scaled
incorrectly by the impulse, causing some undesired elasticity in the
collision. I imagine this was a workaround to avoid penetrations
because the collision responce was being calculated with respect to
the incorrect state, but this is no longer necessary now that that has
been fixed. (had missed this case in my previous elasticity commit)

Other than that, I have bary interpolated the static repulses to avoid a
nasty instability issue in some corner cases.

===================================================================

M	source/blender/blenkernel/intern/collision.c

===================================================================

diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 5fe238a8cb..3d612a0c74 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -382,7 +382,6 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
 				/* stay on the safe side and clamp repulse */
 				if ( impulse > ALMOST_ZERO )
 					repulse = min_ff( repulse, 5.0*impulse );
-				repulse = max_ff(impulse, repulse);
 
 				/*impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); original 2.0 / 0.25 */
 
@@ -421,9 +420,16 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
 				/* Impulse shoud be uniform throughout polygon, the scaling used above was wrong */
 				float impulse = repulse / 4.5f;
 
-				VECADDMUL ( i1, collider_norm,  impulse );
-				VECADDMUL ( i2, collider_norm,  impulse );
-				VECADDMUL ( i3, collider_norm,  impulse );
+				if (backside) {
+					VECADDMUL ( i1, collider_norm,  impulse );
+					VECADDMUL ( i2, collider_norm,  impulse );
+					VECADDMUL ( i3, collider_norm,  impulse );
+				}
+				else {
+					VECADDMUL ( i1, collider_norm, w1 * impulse );
+					VECADDMUL ( i2, collider_norm, w2 * impulse );
+					VECADDMUL ( i3, collider_norm, w3 * impulse );
+				}
 
 				cloth1->verts[collpair->ap1].impulse_count++;
 				cloth1->verts[collpair->ap2].impulse_count++;




More information about the Bf-blender-cvs mailing list