[Bf-blender-cvs] [d086f6a] master: Shrink Wrap modifier: invert vgroup option
Campbell Barton
noreply at git.blender.org
Mon Mar 7 01:37:32 CET 2016
Commit: d086f6aa5c26d445aef1ebd04e6c8501f6189d91
Author: Campbell Barton
Date: Mon Mar 7 11:24:03 2016 +1100
Branches: master
https://developer.blender.org/rBd086f6aa5c26d445aef1ebd04e6c8501f6189d91
Shrink Wrap modifier: invert vgroup option
D1839 from @Orgold
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/blenkernel/BKE_shrinkwrap.h
M source/blender/blenkernel/intern/shrinkwrap.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index e5d70ae..30ca175 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -738,7 +738,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "target", text="")
col = split.column()
col.label(text="Vertex Group:")
- col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+ row = col.row(align=True)
+ row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+ row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
split = layout.split()
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 070f5c7..d2ab4f3 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -67,6 +67,7 @@ typedef struct ShrinkwrapCalcData {
struct MDeformVert *dvert; //Pointer to mdeform array
int vgroup; //Vertex group num
+ bool invert_vgroup; /* invert vertex group influence */
struct DerivedMesh *target; //mesh we are shrinking to
struct SpaceTransform local2target; //transform to move between local and target space
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index bbed4cc..d40d83a 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -96,6 +96,11 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
+
+ if (calc->invert_vgroup) {
+ weight = 1.0f - weight;
+ }
+
if (weight == 0.0f) {
continue;
}
@@ -411,6 +416,11 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
+
+ if (calc->invert_vgroup) {
+ weight = 1.0f - weight;
+ }
+
if (weight == 0.0f) continue;
/* Convert the vertex to tree coordinates */
@@ -480,6 +490,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
calc.ob = ob;
calc.numVerts = numVerts;
calc.vertexCos = vertexCos;
+ calc.invert_vgroup = (smd->shrinkOpts & MOD_SHRINKWRAP_INVERT_VGROUP) != 0;
/* DeformVertex */
calc.vgroup = defgroup_name_index(calc.ob, calc.smd->vgroup_name);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index d00e5d5..c215951 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -825,6 +825,8 @@ enum {
MOD_SHRINKWRAP_CULL_TARGET_BACKFACE = (1 << 4),
MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE = (1 << 5), /* distance is measure to the front face of the target */
+
+ MOD_SHRINKWRAP_INVERT_VGROUP = (1 << 6),
};
/* Shrinkwrap->projAxis */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 961bbfe..571d7fb 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3043,6 +3043,11 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE);
RNA_def_property_ui_text(prop, "Keep Above Surface", "");
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, "shrinkOpts", MOD_SHRINKWRAP_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
static void rna_def_modifier_fluidsim(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list