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:
authorCampbell Barton <ideasman42@gmail.com>2018-10-29 05:01:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-10-29 05:03:28 +0300
commit6c892efdbc4d5882da9a2655b21e4f4c2559106b (patch)
treea75392f4a93b347385d3d1a93a6dd029722010fb
parente3d2df038001af8c67707c20a27e21571b1fdff6 (diff)
Modifier: mask threshold option
D3834 by @Allosteric
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py3
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c7
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c4
4 files changed, 15 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 1a80a160ea5..23ab644cba1 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -523,6 +523,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
sub.active = bool(md.vertex_group)
sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
+ col = layout.column()
+ col.prop(md, "threshold")
+
def MESH_DEFORM(self, layout, ob, md):
split = layout.split()
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index ad5f3768b93..2adf4a02d22 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -192,8 +192,9 @@ typedef struct MaskModifierData {
struct Object *ob_arm; /* armature to use to in place of hardcoded vgroup */
char vgroup[64]; /* name of vertex group to use to mask, MAX_VGROUP_NAME */
- int mode; /* using armature or hardcoded vgroup */
- int flag; /* flags for various things */
+ short mode; /* using armature or hardcoded vgroup */
+ short flag; /* flags for various things */
+ float threshold;
} MaskModifierData;
/* Mask Modifier -> mode */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 1a05b6e5e00..f9b848744d6 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -3267,6 +3267,13 @@ static void rna_def_modifier_mask(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MASK_INV);
RNA_def_property_ui_text(prop, "Invert", "Use vertices that are not part of region defined");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "threshold");
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
+ RNA_def_property_ui_text(prop, "Threshold", "Weights over this threshold remain");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
static void rna_def_modifier_simpledeform(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 93332fb0455..5246f8cd35a 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -196,7 +196,7 @@ static DerivedMesh *applyModifier(
for (j = 0; j < dv->totweight; j++, dw++) {
if (dw->def_nr < defbase_tot) {
if (bone_select_array[dw->def_nr]) {
- if (dw->weight != 0.0f) {
+ if (dw->weight > mmd->threshold) {
found = true;
break;
}
@@ -228,7 +228,7 @@ static DerivedMesh *applyModifier(
/* add vertices which exist in vertexgroup into ghash for filtering */
for (i = 0, dv = dvert; i < maxVerts; i++, dv++) {
- const bool found = defvert_find_weight(dv, defgrp_index) != 0.0f;
+ const bool found = defvert_find_weight(dv, defgrp_index) > mmd->threshold;
if (found_test != found) {
continue;
}