Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Rood <LucaRood>2016-08-13 19:40:22 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2016-08-13 19:48:33 +0300
commitda77d9873f1632f2ec4b624e949c0270753fa465 (patch)
treee9574927276b3039807083ea0f029f43386c9f48 /source/blender/makesrna/intern/rna_cloth.c
parent35a6e540b172cf351da34715b8ad2e0bebc92d44 (diff)
Prevent max stiffness values from going under normal stiffness values in cloth stiffness scaling.
When updating the max values under stiffness scaling, they clip at the normal stiffness values as expected, however when updating stiffness values, you could set them higher than the max values, and the max values weren't updated accordingly. As the stiffness scaling computes using the absolute difference between the max values and the stiffness values, you got higher stiffnesses in scaled areas even though your max is actually lower than the normal stiffness. This diff fixes that behaviour, by updating the max values to be equal to the stiffness whenever you set a higher stiffness than the max value. Also, I have initialized the max values to the same as the stiffnesses, as they were previously just set to zero, and caused the same problem described above. Reviewers: lukastoenne Reviewed By: lukastoenne Tags: #physics Differential Revision: https://developer.blender.org/D2147
Diffstat (limited to 'source/blender/makesrna/intern/rna_cloth.c')
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 781e44c9ed6..91cae32d054 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -68,6 +68,16 @@ static void rna_cloth_pinning_changed(Main *UNUSED(bmain), Scene *UNUSED(scene),
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
+static void rna_ClothSettings_bending_set(struct PointerRNA *ptr, float value)
+{
+ ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+ settings->bending = value;
+
+ /* check for max clipping */
+ if (value > settings->max_bend)
+ settings->max_bend = value;
+}
static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value)
{
@@ -80,6 +90,17 @@ 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)
+{
+ ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
+
+ settings->structural = value;
+
+ /* check for max clipping */
+ if (value > settings->max_struct)
+ settings->max_struct = value;
+}
+
static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value)
{
ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
@@ -493,6 +514,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "structural_stiffness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "structural");
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_update(prop, 0, "rna_cloth_update");
@@ -521,6 +543,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
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);
+ RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_bending_set", NULL);
RNA_def_property_ui_text(prop, "Bending Stiffness",
"Wrinkle coefficient (higher = less smaller but more big wrinkles)");
RNA_def_property_update(prop, 0, "rna_cloth_update");