[Bf-blender-cvs] [fe5735c] cloth-improvements: Fix spring force scaling based on length

Luca Rood noreply at git.blender.org
Mon Dec 5 18:51:05 CET 2016


Commit: fe5735c6cf9459364a5aadc9b24e5455ccc77b00
Author: Luca Rood
Date:   Wed Nov 30 15:36:38 2016 -0200
Branches: cloth-improvements
https://developer.blender.org/rBfe5735c6cf9459364a5aadc9b24e5455ccc77b00

Fix spring force scaling based on length

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

M	source/blender/physics/intern/BPH_mass_spring.cpp

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

diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 86072fc..cbfed19 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -355,8 +355,10 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
 		
 		s->flags |= CLOTH_SPRING_FLAG_NEEDED;
 		
+		// TODO: Scaling should be relative to half the area of the adjacent faces instead of length (except for sewing)
+		// Note that this scaling is only valid when coupled with proper mass distribution
 		scaling = parms->structural + s->stiffness * fabsf(parms->max_struct - parms->structural);
-		k = scaling / (parms->avg_spring_len + FLT_EPSILON);
+		k = scaling / (s->restlen + FLT_EPSILON);
 		
 		if (s->type & CLOTH_SPRING_TYPE_SEWING) {
 			// TODO: verify, half verified (couldn't see error)
@@ -375,7 +377,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
 		s->flags |= CLOTH_SPRING_FLAG_NEEDED;
 
 		scaling = parms->shear + s->stiffness * fabsf(parms->max_shear - parms->shear);
-		k = scaling / (parms->avg_spring_len + FLT_EPSILON);
+		k = scaling / (s->restlen + FLT_EPSILON);
 
 		BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, 0.0f, s->f, s->dfdx, s->dfdv);
 #endif




More information about the Bf-blender-cvs mailing list