[Bf-blender-cvs] [5aacca55fa] cloth-improvements: UI Cleanup: Add new property scaling panel

Luca Rood noreply at git.blender.org
Sat Jan 7 05:10:06 CET 2017


Commit: 5aacca55fa710ebc495f84e8a1c617464814fdb9
Author: Luca Rood
Date:   Sat Jan 7 02:04:57 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rB5aacca55fa710ebc495f84e8a1c617464814fdb9

UI Cleanup: Add new property scaling panel

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
M	source/blender/makesrna/intern/rna_cloth.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index e5ee33cdc4..d7396d7889 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -267,8 +267,8 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
         sub.prop_search(cloth, "vertex_group_self_collisions", ob, "vertex_groups", text="Vertex Group")
 
 
-class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
-    bl_label = "Cloth Stiffness Scaling"
+class PHYSICS_PT_cloth_scaling(PhysicButtonsPanel, Panel):
+    bl_label = "Cloth Property Scaling"
     bl_options = {'DEFAULT_CLOSED'}
     COMPAT_ENGINES = {'BLENDER_RENDER'}
 
@@ -282,22 +282,43 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
         layout.active = cloth_panel_enabled(md)
 
         row = layout.row()
-        row.label(text="Structural Stiffness:")
-        row.prop_search(cloth, "vertex_group_structural_stiffness", ob, "vertex_groups", text="")
-        row.prop(cloth, "tension_stiffness_max", text="Tension")
 
-        row = layout.row()
-        row.prop(cloth, "compression_stiffness_max", text="Compression")
-        
-        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 = row.column(align=True)
+        col.label(text="Structural Stiffness:")
+        col.label(text="Tension:")
+        col.label(text="Compression:")
 
-        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")
+        col = row.column(align=True)
+        col.prop_search(cloth, "vertex_group_structural_stiffness", ob, "vertex_groups", text="")
+
+        sub = col.column(align=True)
+        sub.active = cloth.vertex_group_structural_stiffness != ""
+        sub.prop(cloth, "tension_stiffness_max", text="Max")
+        sub.prop(cloth, "compression_stiffness_max", text="Max")
+
+        split = layout.split(percentage=0.25, align=True)
+        split.label(text="Shear:")
+        split.prop_search(cloth, "vertex_group_shear_stiffness", ob, "vertex_groups", text="")
+
+        sub = split.row(align=True)
+        sub.active = cloth.vertex_group_shear_stiffness != ""
+        sub.prop(cloth, "shear_stiffness_max", text="Max")
+
+        split = layout.split(percentage=0.25, align=True)
+        split.label("Bending:")
+        split.prop_search(cloth, "vertex_group_bending", ob, "vertex_groups", text="")
+
+        sub = split.row(align=True)
+        sub.active = cloth.vertex_group_bending != ""
+        sub.prop(cloth, "bending_stiffness_max", text="Max")
+
+        split = layout.split(percentage=0.25, align=True)
+        split.label("Shrinking:")
+        split.prop_search(cloth, "vertex_group_shrink", ob, "vertex_groups", text="")
+
+        sub = split.row(align=True)
+        sub.active = cloth.vertex_group_shrink != ""
+        sub.prop(cloth, "shrinking_max", text="Max")
 
 
 class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index e39a94a76c..13de955d52 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -175,6 +175,28 @@ static void rna_ClothSettings_max_sewing_set(struct PointerRNA *ptr, float value
 	settings->max_sewing = value;
 }
 
+static void rna_ClothSettings_shrink_set(struct PointerRNA *ptr, float value)
+{
+	ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+	settings->shrink = value;
+
+	/* check for max clipping */
+	if (value > settings->max_shrink)
+		settings->max_shrink = value;
+}
+
+static void rna_ClothSettings_max_shrink_set(struct PointerRNA *ptr, float value)
+{
+	ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+	/* check for clipping */
+	if (value < settings->shrink)
+		value = settings->shrink;
+
+	settings->max_shrink = value;
+}
+
 static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value)
 {
 	ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
@@ -543,12 +565,14 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "shrinking", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "shrink");
 	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shrink_set", NULL);
 	RNA_def_property_ui_text(prop, "Shrink Factor", "Factor by which to shrink cloth");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");
 
 	prop = RNA_def_property(srna, "shrinking_max", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "max_shrink");
 	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_shrink_set", NULL);
 	RNA_def_property_ui_text(prop, "Shrink Factor Max", "Max amount to shrink cloth by");
 	RNA_def_property_update(prop, 0, "rna_cloth_update");




More information about the Bf-blender-cvs mailing list