diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 0462c91e227..f1bf5478403 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -8,6 +8,8 @@ #define DNA_DEPRECATED_ALLOW +#include + #include "CLG_log.h" #include "DNA_brush_types.h" @@ -134,6 +136,24 @@ static void version_geometry_nodes_add_realize_instance_nodes(bNodeTree *ntree) } } +/* Version VertexWeightEdit modifier to make existing weights exclusive of the threshold. */ +static void version_vertex_weight_edit_preserve_threshold_exclusivity(Main *bmain) +{ + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + if (ob->type != OB_MESH) { + continue; + } + + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { + if (md->type == eModifierType_WeightVGEdit) { + WeightVGEditModifierData *wmd = reinterpret_cast(md); + wmd->add_threshold = nexttoward(wmd->add_threshold, 2.0); + wmd->rem_threshold = nexttoward(wmd->rem_threshold, -1.0); + } + } + } +} + static void version_mesh_crease_generic(Main &bmain) { LISTBASE_FOREACH (Mesh *, mesh, &bmain.meshes) { @@ -337,6 +357,10 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 400, 11)) { + version_vertex_weight_edit_preserve_threshold_exclusivity(bmain); + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/makesrna/intern/rna_modifier.cc b/source/blender/makesrna/intern/rna_modifier.cc index 9be3a0b1666..97faa97f509 100644 --- a/source/blender/makesrna/intern/rna_modifier.cc +++ b/source/blender/makesrna/intern/rna_modifier.cc @@ -5218,21 +5218,21 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop = RNA_def_property(srna, "add_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, nullptr, "add_threshold"); - RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_range(prop, -1000.0, 1000.0); RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1); RNA_def_property_ui_text(prop, "Add Threshold", - "Lower bound for a vertex's weight " + "Lower (inclusive) bound for a vertex's weight " "to be added to the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "remove_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, nullptr, "rem_threshold"); - RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_range(prop, -1000.0, 1000.0); RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1); RNA_def_property_ui_text(prop, "Remove Threshold", - "Upper bound for a vertex's weight " + "Upper (inclusive) bound for a vertex's weight " "to be removed from the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.cc b/source/blender/modifiers/intern/MOD_weightvg_util.cc index da0db8db2f3..f9794b71d55 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.cc +++ b/source/blender/modifiers/intern/MOD_weightvg_util.cc @@ -296,7 +296,7 @@ void weightvg_update_vg(MDeformVert *dvert, /* If the vertex is in this vgroup, remove it if needed, or just update it. */ if (dw != nullptr) { - if (do_rem && w < rem_thresh) { + if (do_rem && w <= rem_thresh) { BKE_defvert_remove_group(dv, dw); } else { @@ -304,7 +304,7 @@ void weightvg_update_vg(MDeformVert *dvert, } } /* Else, add it if needed! */ - else if (do_add && w > add_thresh) { + else if (do_add && w >= add_thresh) { BKE_defvert_add_index_notest(dv, defgrp_idx, w); } }