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
This commit is contained in:
parent
35a6e540b1
commit
da77d9873f
Notes:
blender-bot
2023-02-14 07:40:59 +01:00
Referenced by issue #49087, Alembic Realflow problem Referenced by issue #49088, Specific .blend crashes in blender from git master, works in 2.77a
|
@ -81,8 +81,10 @@ void cloth_init(ClothModifierData *clmd )
|
|||
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->shear = 15.0;
|
||||
clmd->sim_parms->bending = 0.5;
|
||||
clmd->sim_parms->max_bend = 0.5;
|
||||
clmd->sim_parms->bending_damping = 0.5;
|
||||
clmd->sim_parms->Cdis = 5.0;
|
||||
clmd->sim_parms->Cvi = 1.0;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue