Animation: Make Vertex Weight Edit modifier inclusive #108286
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#108286
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "nrupsis/blender:vertext-weights-inclusive"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
The Vertex Weight Edit modifier isn't inclusive.
Exp: Empty Vertex group with default weight equal to the add threshold.
This PR changes VertexWeightEdit modifier to be inclusive. An empty vertex group with the default weight equal to the "add" threshold (0.5) now adds weight as expected.
Removing Weight:
Old behavior: Cube with Vertex group of weight 0.5 isn't removed when threshold is also 0.5
Patch: With the inclusiveness, the 0.5 weighted group is now removed:
Breaking Changes
Now that the calculations are inclusive, older files with the VertexWeighEdit modifier will be impacted (I.e, if threshold and Default weight are
0.0
or1.0
). to fix this, we there is some versioning code to modify the Group Add / Remove threshold to the nearest floating point (using C++ nexttoward) to ensure the previous behavior is kept in tact.Additionally, increasing the
add_threshold
andremove_threshold
property range to [-1000.0, 1000.0] to allow us to add in 3.6 backwards compatibility.Testing:
The two 3.5 blend files attached exhibit the same behavior in 3.5 as they do in 4.0.
Ref: Issue #82831
Note: From module meeting, on the versioning we should bump +- to the most significant floating point number in the versioning code.
Ah, thx putting that PR up, this is exactly what I came up with in #82831, right?
Hi @lichtwerk, yep! At the moment this is exactly what you have. However, in the Animation / Rigging module meeting, we discussed adding some versioning code to 4.0 to preserve backwards comparability (slightly modify the float value to make it act exclusive). Currently working on that bit. Thanks for the initial code!
WIP: making weights inclusiveto Animation: Make Vertex Weight Edit modifier inclusive@blender-bot package
Package build started. Download here when ready.
@ -29,0 +36,4 @@
{
/* Object */
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
The blank lines before the object type check and after the modifier type check don't add much IMO.
Same with the
/* Object */
and/* Object modifiers */
comments IMO, that is obvious anyway.Best to remove those I think.
@ -29,2 +57,4 @@
}
}
void do_versions_after_linking_400(FileData * /*fd*/, Main *bmain)
Does this still need to be in
do_versions_after_linking_400
, now that the mesh isn't being modified?Looks like the full modifier data gets pulled in. moved it to the main
blo_do_versions_400
@ -18,2 +20,4 @@
#include "BKE_deform.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
Seems this include is unneeded now.
@ -116,2 +120,4 @@
}
/* Version VertexWeightEdit modifier to make existing weights exclusive of the threshold. */
static void version_vertex_weight_edit(Main *bmain)
I think a more detailed name would be better, especially since this file will get many more versioning functions.
version_vertex_weight_slightly_nudge_thresholds
or something along those lines?@ -118,0 +130,4 @@
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_WeightVGEdit) {
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
if (wmd->default_weight == wmd->add_threshold) {
What is the comparison to
default_weight
for? Wouldn't it be prudent to always adjust the thresholds? (honest question, not trying to suggest any change)To preserve previous behavior (i.e, exclusivity) I think we should only consider cases where the default weight is equal to the add/subtract threshold. That way we're only modifying peoples files to preserver backwards compatibly, and nothing more.
Now, I think this is a small enough corner case where it probably wouldn't matter if we just automatically adjusted all thresholds, but I don't see an obvious advantage to it.
From what I understand of the documentation is that it applies
default_weight
to those vertices withweight >= add_threshold
. So in theory you could add vertices withdefault_weight = 60%
withadd_threshold = 50%
. If I understand things well, the in/exclusivity of that threshold is what matters here, regardless of the weight that these vertices will get.I think you're right. However, I don't know how you assign weights to vertices that are not already in a vgroup?
The tool tip for the Group add is "Lower bounds for a vertex's weight to be added to the vgroup".
From my testing, the default weight (for the Group add) only applies to vertices not in the targeted vgroup. Which, unless editable outside the vgroup, will always be 0.
This is hitting the bound of my knowledge on the subject, so perhaps I'm just misunderstanding.
Talked about this in last weeks Animation & Rigging module. Removing the
default_weight == threshold
checks.@ -206,6 +232,10 @@ void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_ATLEAST(bmain, 400, 7)) {
I would recommend only adding versioning code to the generic 'move me when the subversion is bumped' section. At least for reviewing that makes things easier, as subsequent development on
main
can otherwise cause conflicts.The actual bump & move into a version-specific section can then be done when landing. Or as a 2nd stage of the review, if you want more eyes on that as well.
@ -118,0 +129,4 @@
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_WeightVGEdit) {
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
(WeightVGEditModifierData *)md
->reinterpret_cast<WeightVGEditModifierData *>(md)
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast
@ -31,6 +33,8 @@
#include "BLO_readfile.h"
#include "DNA_modifier_types.h"
Keep the
DNA_...
includes grouped together.@ -124,0 +137,4 @@
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);
Maybe add a comment that explains what these numbers are. They are just the min/max values ±1, but that might not be obvious to everybody.
@ -134,2 +156,3 @@
"GeometryNodeStoreNamedAttribute",
"GeometryNodeInputNamedAttribute")) {
"GeometryNodeInputNamedAttribute"))
{
Formatting
@ -5219,3 +5219,2 @@
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_float_sdna(prop, NULL, "add_threshold");
My bet is that this PR started before the code was converted to C++. Be sure to use
nullptr
instead ofNULL
in C++ code.My bet is that this PR started before the code was converted to C++. Be sure to use
nullptr
instead ofNULL
in C++ code.@ -5220,2 +5220,2 @@
RNA_def_property_float_sdna(prop, nullptr, "add_threshold");
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_float_sdna(prop, NULL, "add_threshold");
RNA_def_property_range(prop, -1000.0, 1000.0);
The PR description says nothing about expanding the allowed ranges for these thresholds. Is this a necessity for the change from exclusive to inclusive? If not, it'll be better to put into a separate commit.
This change doesn't impact the exclusive to inclusive, however it is required for the versioning code to work.
Should the whole versioning bit be moved into a new PR/commit?
No it's better to have the change + the versioning in one commit. I just didn't realise that this was necessary for the versioning.
@ -146,3 +166,2 @@
"GeometryNodeStoreNamedAttribute",
"GeometryNodeInputNamedAttribute"))
{
"GeometryNodeInputNamedAttribute")) {
Keep unrelated changes out of the commit (even when it's fixing someone else's formatting mistakes).
git gui
is your friend when you want to (un)stage specific hunks/lines.LGTM, thanks!
Seems like this has versioning code checking
MAIN_VERSION_ATLEAST(bmain, 400, 11)
butBLENDER_FILE_SUBVERSION
hasnt actually been bumped? (we are still at 10?)