From 541d0fdba61a9c99612f7532207d5ce704f10b43 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Wed, 4 Dec 2019 11:24:46 +0100 Subject: Add cloth pressure vertex group and unlock cloth shrink values range Introduced a way to specify cloth pressure force influence with a vertex group. This will allow users to only have pressure affect certain parts of the mesh. In addition to this, the "shrink factor" is now also unlocked to allow negative values and thus allowing the cloth mesh to grow as well. Reviewed By: Jaques Lucke Differential Revision: http://developer.blender.org/D6347 --- source/blender/makesrna/intern/rna_cloth.c | 43 +++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'source/blender/makesrna/intern/rna_cloth.c') diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index cf48ed549e6..9f6f15b8379 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -291,6 +291,24 @@ static void rna_ClothSettings_bend_vgroup_set(PointerRNA *ptr, const char *value rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_bend); } +static void rna_ClothSettings_pressure_vgroup_get(PointerRNA *ptr, char *value) +{ + ClothSimSettings *sim = (ClothSimSettings *)ptr->data; + rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_pressure); +} + +static int rna_ClothSettings_pressure_vgroup_length(PointerRNA *ptr) +{ + ClothSimSettings *sim = (ClothSimSettings *)ptr->data; + return rna_object_vgroup_name_index_length(ptr, sim->vgroup_pressure); +} + +static void rna_ClothSettings_pressure_vgroup_set(PointerRNA *ptr, const char *value) +{ + ClothSimSettings *sim = (ClothSimSettings *)ptr->data; + rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_pressure); +} + static void rna_CollSettings_selfcol_vgroup_get(PointerRNA *ptr, char *value) { ClothCollSettings *coll = (ClothCollSettings *)ptr->data; @@ -595,14 +613,16 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "shrink_min", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "shrink_min"); - RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_range(prop, -FLT_MAX, 1.0f); + RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.05f, 3); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shrink_min_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, "shrink_max", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "shrink_max"); - RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_range(prop, -FLT_MAX, 1.0f); + RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.05f, 3); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shrink_max_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"); @@ -803,8 +823,10 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "target_volume"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_float_default(prop, 0.0f); - RNA_def_property_ui_text( - prop, "Target Volume", "The mesh volume where the inner/outer pressure will be the same"); + RNA_def_property_ui_text(prop, + "Target Volume", + "The mesh volume where the inner/outer pressure will be the same. If " + "set to zero the volume will not contribute to the total pressure"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "pressure_factor", PROP_FLOAT, PROP_NONE); @@ -814,6 +836,19 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pressure Scale", "Air pressure scaling factor"); RNA_def_property_update(prop, 0, "rna_cloth_update"); + prop = RNA_def_property(srna, "vertex_group_pressure", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, + "rna_ClothSettings_pressure_vgroup_get", + "rna_ClothSettings_pressure_vgroup_length", + "rna_ClothSettings_pressure_vgroup_set"); + RNA_def_property_ui_text( + prop, + "Pressure Vertex Group", + "Vertex Group for where to apply pressure. Zero weight means no " + "pressure while a weight of one means full pressure. Faces with a vertex " + "that has zero weight will be excluded from the volume calculation"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + /* unused */ /* unused still */ -- cgit v1.2.3