[Bf-blender-cvs] [54f96ed] temp_merge_gooseberry_hair: Added separate damping for bending springs.

Lukas Tönne noreply at git.blender.org
Mon Jan 19 20:49:47 CET 2015


Commit: 54f96ede9fdcb3d5224a189b6f80ad68530477d8
Author: Lukas Tönne
Date:   Fri Sep 26 17:25:21 2014 +0200
Branches: temp_merge_gooseberry_hair
https://developer.blender.org/rB54f96ede9fdcb3d5224a189b6f80ad68530477d8

Added separate damping for bending springs.

The bend damping factor was hardcoded to the same value as the stiffness.
Now it has its own factor in the settings and button in hair dynamics.

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

M	release/scripts/startup/bl_ui/properties_particle.py
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/makesdna/DNA_cloth_types.h
M	source/blender/makesrna/intern/rna_cloth.c
M	source/blender/physics/intern/BPH_mass_spring.cpp

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

diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 00c19c9..de0921d 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -306,6 +306,7 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
         sub = col.column(align=True)
         sub.prop(cloth, "spring_damping", text="Spring")
         sub.prop(cloth, "air_damping", text="Air")
+        sub.prop(cloth, "bending_damping", text="Bending")
 
         col.label(text="Quality:")
         col.prop(cloth, "quality", text="Steps", slider=True)
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 297a0e4..a77357f 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -120,6 +120,7 @@ void cloth_init(ClothModifierData *clmd )
 	clmd->sim_parms->structural = 15.0;
 	clmd->sim_parms->shear = 15.0;
 	clmd->sim_parms->bending = 0.5;
+	clmd->sim_parms->bending_damping = 0.5;
 	clmd->sim_parms->Cdis = 5.0; 
 	clmd->sim_parms->Cvi = 1.0;
 	clmd->sim_parms->mass = 0.3f;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index de39d26..43de4a2 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -456,4 +456,23 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 	}
+	
+	if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
+		Object *ob;
+		ModifierData *md;
+		for (ob = main->object.first; ob; ob = ob->id.next) {
+			for (md = ob->modifiers.first; md; md = md->next) {
+				if (md->type == eModifierType_Cloth) {
+					ClothModifierData *clmd = (ClothModifierData*) md;
+					clmd->sim_parms->bending_damping = 0.5f;
+				}
+				else if (md->type == eModifierType_ParticleSystem) {
+					ParticleSystemModifierData *pmd = (ParticleSystemModifierData*) md;
+					if (pmd->psys->clmd) {
+						pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
+					}
+				}
+			}
+		}
+	}
 }
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 39a1abc..85c91a5 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -76,6 +76,10 @@ typedef struct ClothSimSettings {
 	float	shrink_min;  /* min amount to shrink cloth by 0.0f (no shrink) - 1.0f (shrink to nothing) */
 	float	shrink_max;  /* max amount to shrink cloth by 0.0f (no shrink) - 1.0f (shrink to nothing) */
 	
+	/* XXX various hair stuff
+	 * should really be separate, this struct is a horrible mess already
+	 */
+	float	bending_damping;	/* damping of bending springs */
 	int		voxel_res;          /* resolution of voxel grid for interaction */
 	int		voxel_filter_size;  /* filter size for voxel grid */
 
@@ -91,7 +95,6 @@ typedef struct ClothSimSettings {
 	short	shapekey_rest;  /* vertex group for scaling structural stiffness */
 	short	presets; /* used for presets on GUI */
 	short 	reset;
-	int		pad;
 
 	struct EffectorWeights *effector_weights;
 } ClothSimSettings;
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 57dc3ea..4e1c912 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -544,6 +544,13 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Bending Stiffness Maximum", "Maximum bending stiffness value");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+	prop = RNA_def_property(srna, "bending_damping", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "bending_damping");
+	RNA_def_property_range(prop, 0.0f, 1000.0f);
+	RNA_def_property_ui_text(prop, "Bending Spring Damping",
+	                         "Damping of bending motion");
+	RNA_def_property_update(prop, 0, "rna_cloth_update");
+
 	prop = RNA_def_property(srna, "use_sewing_springs", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_SEW);
 	RNA_def_property_ui_text(prop, "Sew Cloth", "Pulls loose edges together");
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 0138178..6a768f1 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -410,7 +410,10 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
 		s->flags |= CLOTH_SPRING_FLAG_NEEDED;
 		
 		scaling = parms->bending + s->stiffness * fabsf(parms->max_bend - parms->bending);
-		cb = kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
+		kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
+		
+		scaling = parms->bending_damping;
+		cb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
 		
 		BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->matrix_ij_kl, s->restlen, kb, cb, s->f, s->dfdx, s->dfdv);
 #endif
@@ -422,7 +425,10 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
 		s->flags |= CLOTH_SPRING_FLAG_NEEDED;
 		
 		scaling = parms->bending + s->stiffness * fabsf(parms->max_bend - parms->bending);
-		cb = kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
+		kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
+		
+		scaling = parms->bending_damping;
+		cb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
 		
 		/* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */
 		BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->mn, s->matrix_ij_kl, s->matrix_kl_mn, s->matrix_ij_mn, s->target, kb, cb);




More information about the Bf-blender-cvs mailing list