[Bf-blender-cvs] [e0b46b1] master: Arbitrary scaling factor for the structural spring forces (stretching).

Lukas Tönne noreply at git.blender.org
Tue Jan 20 09:49:54 CET 2015


Commit: e0b46b136e2e12e7bf7676abfeaa2964905d5f35
Author: Lukas Tönne
Date:   Tue Sep 9 12:01:10 2014 +0200
Branches: master
https://developer.blender.org/rBe0b46b136e2e12e7bf7676abfeaa2964905d5f35

Arbitrary scaling factor for the structural spring forces (stretching).

This is not nice at all, but for some reason (possibly time scale) the
old force values are much too high and cause the solver to become
unstable. These will be revisited later anyway, so for now such scaling
should be fine.

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

M	source/blender/blenkernel/intern/implicit_eigen.cpp

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

diff --git a/source/blender/blenkernel/intern/implicit_eigen.cpp b/source/blender/blenkernel/intern/implicit_eigen.cpp
index 26bfa49..139f4c7 100644
--- a/source/blender/blenkernel/intern/implicit_eigen.cpp
+++ b/source/blender/blenkernel/intern/implicit_eigen.cpp
@@ -341,6 +341,8 @@ DO_INLINE void dfdv_damp(float to[3][3], const float dir[3], float damping)
 
 static void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, const lVector &X, const lVector &V, float time)
 {
+	const float structural_scale = 0.001f;
+	
 	Cloth *cloth = clmd->clothObject;
 	ClothVertex *verts = cloth->verts;
 	ClothVertex *v1 = &verts[s->ij], *v2 = &verts[s->kl];
@@ -397,7 +399,7 @@ static void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, con
 		if (length > L || no_compress) {
 			s->flags |= CLOTH_SPRING_FLAG_NEEDED;
 			
-			k = clmd->sim_parms->structural;
+			k = clmd->sim_parms->structural * structural_scale;
 			scaling = k + s->stiffness * fabsf(clmd->sim_parms->max_struct - k);
 
 			k = scaling / (clmd->sim_parms->avg_spring_len + FLT_EPSILON);
@@ -418,14 +420,13 @@ static void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, con
 			
 			// Ascher & Boxman, p.21: Damping only during elonglation
 			// something wrong with it...
-			madd_v3_v3fl(s->f, dir, clmd->sim_parms->Cdis * dot_v3v3(vel, dir));
+			madd_v3_v3fl(s->f, dir, clmd->sim_parms->Cdis * dot_v3v3(vel, dir) * structural_scale);
 			
 			/* VERIFIED */
 			dfdx_spring(s->dfdx, dir, length, L, k);
 			
 			/* VERIFIED */
-			dfdv_damp(s->dfdv, dir, clmd->sim_parms->Cdis);
-			
+			dfdv_damp(s->dfdv, dir, clmd->sim_parms->Cdis * structural_scale);
 		}
 	}
 	else if (s->type & CLOTH_SPRING_TYPE_GOAL) {




More information about the Bf-blender-cvs mailing list