[Bf-blender-cvs] [fa56691] cloth-improvements: Implement separate tension and compression components
Luca Rood
noreply at git.blender.org
Mon Dec 5 18:51:09 CET 2016
Commit: fa5669164bf236699ce26d5960d4eeffb5fc1648
Author: Luca Rood
Date: Thu Dec 1 10:15:36 2016 -0200
Branches: cloth-improvements
https://developer.blender.org/rBfa5669164bf236699ce26d5960d4eeffb5fc1648
Implement separate tension and compression components
===================================================================
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
M source/blender/physics/intern/implicit_blender.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index b5acbcb..43096d5 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -86,14 +86,16 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
col.label(text="Material:")
col.prop(cloth, "mass")
- col.prop(cloth, "structural_stiffness", text="Structural")
+ col.prop(cloth, "tension_stiffness", text="Tension")
+ col.prop(cloth, "compression_stiffness", text="Compression")
col.prop(cloth, "shear_stiffness", text="Shear")
col.prop(cloth, "bending_stiffness", text="Bending")
col = split.column()
col.label(text="Damping:")
- col.prop(cloth, "structural_damping", text="Structural")
+ col.prop(cloth, "tension_damping", text="Tension")
+ col.prop(cloth, "compression_damping", text="Compression")
col.prop(cloth, "shear_damping", text="Shear")
col.prop(cloth, "air_damping", text="Air")
col.prop(cloth, "vel_damping", text="Velocity")
@@ -205,9 +207,12 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
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")
+ 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")
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index bc07f35..79e1d1b 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -80,14 +80,17 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->gravity[0] = 0.0;
clmd->sim_parms->gravity[1] = 0.0;
clmd->sim_parms->gravity[2] = -9.81;
- clmd->sim_parms->structural = 15.0;
- clmd->sim_parms->max_struct = 15.0;
+ clmd->sim_parms->tension = 15.0;
+ clmd->sim_parms->compression = 15.0;
+ clmd->sim_parms->max_tension = 15.0;
+ clmd->sim_parms->max_compression = 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;
- clmd->sim_parms->struct_damp = 5.0;
+ clmd->sim_parms->tension_damp = 5.0;
+ clmd->sim_parms->compression_damp = 5.0;
clmd->sim_parms->shear_damp = 5.0;
clmd->sim_parms->Cvi = 1.0;
clmd->sim_parms->mass = 0.3f;
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 3266fed..6583a00 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -49,17 +49,20 @@
typedef struct ClothSimSettings {
struct LinkNode *cache; /* UNUSED atm */
float mingoal; /* see SB */
- float struct_damp; /* Mechanical damping of structural springs. */
+ float tension_damp; /* Mechanical damping of structural springs. */
+ float compression_damp; /* Mechanical damping of structural springs. */
float shear_damp; /* Mechanical damping of structural springs. */
float Cvi; /* Viscous/fluid damping. */
float gravity[3]; /* Gravity/external force vector. */
float dt; /* This is the duration of our time step, computed. */
float mass; /* The mass of the entire cloth. */
- float structural; /* Structural spring stiffness. */
+ float tension; /* Tension spring stiffness. */
+ float compression; /* Compression spring stiffness. */
float shear; /* Shear spring stiffness. */
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_tension; /* max structural scaling value, min is "structural" */
+ float max_compression; /* max structural scaling value, min is "structural" */
float max_shear; /* max shear scaling value */
float max_sewing; /* max sewing force */
float avg_spring_len; /* used for normalized springs */
@@ -101,7 +104,7 @@ typedef struct ClothSimSettings {
short presets; /* used for presets on GUI */
short reset;
- char pad0[6];
+ 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 eab538c..6b4c93b 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -96,26 +96,48 @@ static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value)
settings->max_bend = value;
}
-static void rna_ClothSettings_structural_set(struct PointerRNA *ptr, float value)
+static void rna_ClothSettings_tension_set(struct PointerRNA *ptr, float value)
{
ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
- settings->structural = value;
+ settings->tension = value;
/* check for max clipping */
- if (value > settings->max_struct)
- settings->max_struct = value;
+ if (value > settings->max_tension)
+ settings->max_tension = value;
}
-static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value)
+static void rna_ClothSettings_max_tension_set(struct PointerRNA *ptr, float value)
{
ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
/* check for clipping */
- if (value < settings->structural)
- value = settings->structural;
+ if (value < settings->tension)
+ value = settings->tension;
- settings->max_struct = value;
+ settings->max_tension = value;
+}
+
+static void rna_ClothSettings_compression_set(struct PointerRNA *ptr, float value)
+{
+ ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+ settings->compression = value;
+
+ /* check for max clipping */
+ if (value > settings->max_compression)
+ settings->max_compression = value;
+}
+
+static void rna_ClothSettings_max_compression_set(struct PointerRNA *ptr, float value)
+{
+ ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+ /* check for clipping */
+ if (value < settings->compression)
+ value = settings->compression;
+
+ settings->max_compression = value;
}
static void rna_ClothSettings_shear_set(struct PointerRNA *ptr, float value)
@@ -550,10 +572,17 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_cloth_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- prop = RNA_def_property(srna, "structural_damping", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "struct_damp");
+ prop = RNA_def_property(srna, "tension_damping", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "tension_damp");
+ RNA_def_property_range(prop, 0.0f, 50.0f);
+ RNA_def_property_ui_text(prop, "Tension Spring Damping",
+ "Damping of cloth velocity (higher = more smooth, less jiggling)");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "compression_damping", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "compression_damp");
RNA_def_property_range(prop, 0.0f, 50.0f);
- RNA_def_property_ui_text(prop, "Structural Spring Damping",
+ RNA_def_property_ui_text(prop, "Compression Spring Damping",
"Damping of cloth velocity (higher = more smooth, less jiggling)");
RNA_def_property_update(prop, 0, "rna_cloth_update");
@@ -564,18 +593,32 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
"Damping of cloth velocity (higher = more smooth, less jiggling)");
RNA_def_property_update(prop, 0, "rna_cloth_update");
- prop = RNA_def_property(srna, "structural_stiffness", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "structural");
+ prop = RNA_def_property(srna, "tension_stiffness", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "tension");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_tension_set", NULL);
+ RNA_def_property_ui_text(prop, "Tension Stiffness", "Tension stiffness of structure");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "tension_stiffness_max", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "max_tension");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_tension_set", NULL);
+ RNA_def_property_ui_text(prop, "Tension Stiffness Maximum", "Maximum tension stiffness value");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "compression_stiffness", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "compression");
RNA_def_property_range(prop, 0.0f, 10000.0f);
- RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_structural_set", NULL);
- RNA_def_property_ui_text(prop, "Structural Stiffness", "Overall stiffness of structure");
+ RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_compression_set", NULL);
+ RNA_def_property_ui_text(prop, "Compression Stiffness", "Compression stiffness of structure");
RNA_def_property_update(prop, 0, "rna_cloth_update");
- prop = RNA_def_property(srna, "structural_stiffness_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "max_struct");
+ prop = RNA_def_property(srna, "compression_stiffness_max", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "max_compression");
RNA_def_property_range(prop, 0.0f, 10000.0f);
- RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_struct_set", NULL);
- RNA_def_property_ui_text(prop, "Structural Stiffness Maximum", "Maximum structural stiffness value
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list