[Bf-blender-cvs] [55b9eebede] cloth-improvements: Implement rest planarity factor option

Luca Rood noreply at git.blender.org
Fri Jan 6 07:49:23 CET 2017


Commit: 55b9eebedef82bc64109a741bea87a98ee1bb25c
Author: Luca Rood
Date:   Fri Jan 6 04:27:29 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rB55b9eebedef82bc64109a741bea87a98ee1bb25c

Implement rest planarity factor option

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
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_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index fc14855fe8..09f13b9a03 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -105,6 +105,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
         layout.prop(cloth, "structural_yield_factor")
         layout.prop(cloth, "bending_plasticity")
         layout.prop(cloth, "bending_yield_factor")
+        layout.prop(cloth, "rest_planarity_factor")
 
         split = layout.split()
 
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 2480caa279..a2213a67f2 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -86,6 +86,7 @@ typedef struct ClothSimSettings {
 	float	struct_yield_fact;	/* Factor of how much length has to change before plastic behavior kicks in (1-inf) */
 	float	bend_plasticity;	/* Factor of how much the rest angle will change after reaching yield point (0-1) */
 	float	bend_yield_fact;	/* How much angle has to change as a factor of a full circle before plastic behavior kicks in (0-1) */
+	float	rest_planar_fact;	/* Factor of how planar rest angles should be, 0 means the original angle, and 1 means totally flat */
 	
 	/* XXX various hair stuff
 	 * should really be separate, this struct is a horrible mess already
@@ -108,7 +109,7 @@ typedef struct ClothSimSettings {
 	short	presets; /* used for presets on GUI */
 	short 	reset;
 
-	char pad0[2];
+	char pad0[6];
 	struct EffectorWeights *effector_weights;
 } ClothSimSettings;
 
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index c107b8e4cc..84bd375e48 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -660,6 +660,12 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Bending Yield Factor", "How much cloth has to bend before plasticity takes effect");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+	prop = RNA_def_property(srna, "rest_planarity_factor", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "rest_planar_fact");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Rest Planarity Factor", "How planar the rest shape should be, 0 is the original shape, and 1 is totally flat");
+	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);
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 6eacf19520..830ade1c37 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -353,8 +353,9 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
 		scaling = parms->bending + s->ang_stiffness * fabsf(parms->max_bend - parms->bending);
 		k = scaling * s->restlen * s->lenfact * 0.1f; /* multiplying by 0.1, just to scale the forces to more reasonable values */
 
-		BPH_mass_spring_force_spring_angular(data, s->ij, s->kl, s->pa, s->pb, s->la, s->lb, s->restang, &s->angoffset,
-		                                     k, parms->bending_damping, bend_plast, parms->bend_yield_fact * M_PI * 2);
+		BPH_mass_spring_force_spring_angular(data, s->ij, s->kl, s->pa, s->pb, s->la, s->lb,
+		                                     s->restang * (1.0f - parms->rest_planar_fact), &s->angoffset, k,
+		                                     parms->bending_damping, bend_plast, parms->bend_yield_fact * M_PI * 2);
 #endif
 	}




More information about the Bf-blender-cvs mailing list