Animation: Make Vertex Weight Edit modifier inclusive
Update VertexWeighEdit modifier Group Add / Remove threshold to be inclusive. Additionally, add 3.6 backwards compatibility (4.0 versioning) to slightly offset Group Add / Remove threshold property value to make exclusive. Pull Request: https://projects.blender.org/blender/blender/pulls/108286
This commit is contained in:
parent
769d18877b
commit
1837bda030
@ -8,6 +8,8 @@
|
||||
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#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<WeightVGEditModifierData *>(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.
|
||||
*
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user