From 6e505a45a1167537e7628e3feb31893cf8898ec8 Mon Sep 17 00:00:00 2001 From: Cody Winchester Date: Fri, 27 Mar 2020 12:20:31 +0100 Subject: Surface Deform modifier: add vertex group and strength control. This commit aims to add functionality to the surface deform modifier that gives more control and allows it to work better with the modifier stack. * Maintains compatibility with older files. The default settings keep it so that the whole object is bound and vertex coordinates get overwritten as the modifier currently does. * Turns the deformations from an absolute vertex coordinate overwrite into an additive offset from the vertex location before the modifier to the resulting bound deformation. This gives the ability to control the strength of the deformation and mix the deformation of the modifier with the modifier stack that comes before it. * Also adds in a vertex group with the invert option. This is applied after the bind deformation is added. So the whole object is still bound to target, and the vertex group filters afterwards what parts get affected. I experimented with a version to only binds the geometry weighted to the vertex group, but that would break compatibility with old files. I may bring it in later as a separate option/mode for the surface deform. With several fixes from @mont29. Reviewed By: mont29 Differencial Revision: https://developer.blender.org/D6894 --- source/blender/makesrna/intern/rna_modifier.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 91eaae6cfc8..0de745f5892 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -799,6 +799,7 @@ RNA_MOD_VGROUP_NAME_SET(Smooth, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Solidify, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Solidify, shell_defgrp_name); RNA_MOD_VGROUP_NAME_SET(Solidify, rim_defgrp_name); +RNA_MOD_VGROUP_NAME_SET(SurfaceDeform, defgrp_name); RNA_MOD_VGROUP_NAME_SET(UVWarp, vgroup_name); RNA_MOD_VGROUP_NAME_SET(Warp, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Wave, defgrp_name); @@ -4453,13 +4454,17 @@ static void rna_def_modifier_solidify(BlenderRNA *brna) prop = RNA_def_property(srna, "shell_vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "shell_defgrp_name"); - RNA_def_property_ui_text(prop, "Shell Vertex Group", "Vertex group that the generated shell geometry will be weighted to"); + RNA_def_property_ui_text(prop, + "Shell Vertex Group", + "Vertex group that the generated shell geometry will be weighted to"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SolidifyModifier_shell_defgrp_name_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "rim_vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "rim_defgrp_name"); - RNA_def_property_ui_text(prop, "Rim Vertex Group", "Vertex group that the generated rim geometry will be weighted to"); + RNA_def_property_ui_text(prop, + "Rim Vertex Group", + "Vertex group that the generated rim geometry will be weighted to"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SolidifyModifier_rim_defgrp_name_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -6385,6 +6390,24 @@ static void rna_def_modifier_surfacedeform(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_SurfaceDeformModifier_is_bound_get", NULL); RNA_def_property_ui_text(prop, "Bound", "Whether geometry has been bound to target mesh"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text( + prop, "Vertex Group", "Vertex group name for selecting/weighting the affected areas"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SurfaceDeformModifier_defgrp_name_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SDEF_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, -100, 100); + RNA_def_property_ui_range(prop, -100, 100, 10, 2); + RNA_def_property_ui_text(prop, "Strength", "Strength of modifier deformations"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_weightednormal(BlenderRNA *brna) -- cgit v1.2.3