[Bf-blender-cvs] [97b232e] cloth-improvements: Separate cloth shear from structural stiffness

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


Commit: 97b232ec709ab18eac43a0858bb4a1fcbf60b469
Author: Luca Rood
Date:   Wed Nov 30 00:26:13 2016 -0200
Branches: cloth-improvements
https://developer.blender.org/rB97b232ec709ab18eac43a0858bb4a1fcbf60b469

Separate cloth shear from structural stiffness

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
M	source/blender/blenkernel/intern/cloth.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
M	source/blender/physics/intern/implicit.h

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 3ebf269..32bfdda 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -87,6 +87,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
         col.label(text="Material:")
         col.prop(cloth, "mass")
         col.prop(cloth, "structural_stiffness", text="Structural")
+        col.prop(cloth, "shear_stiffness", text="Shear")
         col.prop(cloth, "bending_stiffness", text="Bending")
 
         col = split.column()
@@ -200,17 +201,20 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
 
         layout.active = (cloth.use_stiffness_scale and cloth_panel_enabled(md))
 
-        split = layout.split()
+        row = layout.row()
+        row.label(text="Structural Stiffness:")
+        row.prop_search(cloth, "vertex_group_structural_stiffness", ob, "vertex_groups", text="")
+        row.prop(cloth, "structural_stiffness_max", text="Max")
 
-        col = split.column()
-        col.label(text="Structural Stiffness:")
-        col.prop_search(cloth, "vertex_group_structural_stiffness", ob, "vertex_groups", text="")
-        col.prop(cloth, "structural_stiffness_max", text="Max")
+        row = layout.row()
+        row.label(text="Shear Stiffness:")
+        row.prop_search(cloth, "vertex_group_shear_stiffness", ob, "vertex_groups", text="")
+        row.prop(cloth, "shear_stiffness_max", text="Max")
 
-        col = split.column()
-        col.label(text="Bending Stiffness:")
-        col.prop_search(cloth, "vertex_group_bending", ob, "vertex_groups", text="")
-        col.prop(cloth, "bending_stiffness_max", text="Max")
+        row = layout.row()
+        row.label(text="Bending Stiffness:")
+        row.prop_search(cloth, "vertex_group_bending", ob, "vertex_groups", text="")
+        row.prop(cloth, "bending_stiffness_max", text="Max")
 
 
 class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 28ef3f6..ca80d29 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -82,7 +82,8 @@ void cloth_init(ClothModifierData *clmd )
 	clmd->sim_parms->gravity[2] = -9.81;
 	clmd->sim_parms->structural = 15.0;
 	clmd->sim_parms->max_struct = 15.0;
-	clmd->sim_parms->shear = 15.0;
+	clmd->sim_parms->shear = 5.0;
+	clmd->sim_parms->max_shear = 5.0;
 	clmd->sim_parms->bending = 0.5;
 	clmd->sim_parms->max_bend = 0.5;
 	clmd->sim_parms->bending_damping = 0.5;
@@ -726,6 +727,9 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
 					if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) {
 						if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) {
 							verts->struct_stiff = dvert->dw [j].weight;
+						}
+
+						if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shear-1)) {
 							verts->shear_stiff = dvert->dw [j].weight;
 						}
 						
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index ee147da..cd8ae30 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -59,7 +59,7 @@ typedef struct ClothSimSettings {
 	float	bending;	/* Flexion spring stiffness.			*/
 	float	max_bend; 	/* max bending scaling value, min is "bending" */
 	float	max_struct; 	/* max structural scaling value, min is "structural" */
-	float	max_shear; 	/* max shear scaling value, UNUSED */
+	float	max_shear; 	/* max shear scaling value */
 	float	max_sewing; 	/* max sewing force */
 	float 	avg_spring_len; /* used for normalized springs */
 	float 	timescale; /* parameter how fast cloth runs */
@@ -94,12 +94,13 @@ typedef struct ClothSimSettings {
 	short	vgroup_bend;	/* vertex group for scaling bending stiffness */
 	short	vgroup_mass;	/* optional vertexgroup name for assigning weight.*/
 	short	vgroup_struct;  /* vertex group for scaling structural stiffness */
+	short	vgroup_shear;  /* vertex group for scaling structural stiffness */
 	short	vgroup_shrink;  /* vertex group for shrinking cloth */
 	short	shapekey_rest;  /* vertex group for scaling structural stiffness */
 	short	presets; /* used for presets on GUI */
 	short 	reset;
 
-	char pad0[4];
+	char pad0[2];
 	struct EffectorWeights *effector_weights;
 } ClothSimSettings;
 
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index d8bcbc2..6a12654 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -118,6 +118,28 @@ static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value
 	settings->max_struct = value;
 }
 
+static void rna_ClothSettings_shear_set(struct PointerRNA *ptr, float value)
+{
+	ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+	settings->shear = value;
+
+	/* check for max clipping */
+	if (value > settings->max_shear)
+		settings->max_shear = value;
+}
+
+static void rna_ClothSettings_max_shear_set(struct PointerRNA *ptr, float value)
+{
+	ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+	/* check for clipping */
+	if (value < settings->shear)
+		value = settings->shear;
+
+	settings->max_shear = value;
+}
+
 static void rna_ClothSettings_max_sewing_set(struct PointerRNA *ptr, float value)
 {
 	ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
@@ -183,6 +205,24 @@ static void rna_ClothSettings_struct_vgroup_set(PointerRNA *ptr, const char *val
 	rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_struct);
 }
 
+static void rna_ClothSettings_shear_vgroup_get(PointerRNA *ptr, char *value)
+{
+	ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
+	rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_shear);
+}
+
+static int rna_ClothSettings_shear_vgroup_length(PointerRNA *ptr)
+{
+	ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
+	return rna_object_vgroup_name_index_length(ptr, sim->vgroup_shear);
+}
+
+static void rna_ClothSettings_shear_vgroup_set(PointerRNA *ptr, const char *value)
+{
+	ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
+	rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_shear);
+}
+
 static void rna_ClothSettings_bend_vgroup_get(PointerRNA *ptr, char *value)
 {
 	ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
@@ -531,6 +571,20 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Structural Stiffness Maximum", "Maximum structural stiffness value");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+	prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "shear");
+	RNA_def_property_range(prop, 0.0f, 10000.0f);
+	RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shear_set", NULL);
+	RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness");
+	RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+	prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "max_shear");
+	RNA_def_property_range(prop, 0.0f, 10000.0f);
+	RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_shear_set", NULL);
+	RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value");
+	RNA_def_property_update(prop, 0, "rna_cloth_update");
+
 	prop = RNA_def_property(srna, "sewing_force_max", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "max_sewing");
 	RNA_def_property_range(prop, 0.0f, 10000.0f);
@@ -546,6 +600,14 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
 	                         "Vertex group for fine control over structural stiffness");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+	prop = RNA_def_property(srna, "vertex_group_shear_stiffness", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_funcs(prop, "rna_ClothSettings_shear_vgroup_get",
+	                              "rna_ClothSettings_shear_vgroup_length",
+	                              "rna_ClothSettings_shear_vgroup_set");
+	RNA_def_property_ui_text(prop, "Shear Stiffness Vertex Group",
+	                         "Vertex group for fine control over shear stiffness");
+	RNA_def_property_update(prop, 0, "rna_cloth_update");
+
 	prop = RNA_def_property(srna, "bending_stiffness", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "bending");
 	RNA_def_property_range(prop, 0.0f, 10000.0f);
@@ -604,20 +666,6 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
 
 	/* unused still */
 #if 0
-	prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE);
-	RNA_def_property_float_sdna(prop, NULL, "shear");
-	RNA_def_property_range(prop, 0.0f, 1000.0f);
-	RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness");
-#endif
-	/* unused still */
-#if 0
-	prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE);
-	RNA_def_property_float_sdna(prop, NULL, "max_shear");
-	RNA_def_property_range(prop, 0.0f, upperLimitf);
-	RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value");
-#endif
-	/* unused still */
-#if 0
 	prop = RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "eff_force_scale");
 	RNA_def_property_range(prop, 0.0f, 100.0f);
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 359395b..86072fc 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -349,7 +349,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
 	s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;
 	
 	// calculate force of structural + shear springs
-	if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR) || (s->type & CLOTH_SPRING_TYPE_SEWING) ) {
+	if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SEWING) )

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list