Page MenuHome

Smooth Vertex Weights operator affects ALL objects that are in weight paint mode(even deselected ones)
Closed, ResolvedPublic


Blender Version
Broken: 2.80, 02581a7ef819, 2019-02-08

Short description of error
If you leave object A in weight paint mode by making object B the active object, then you enter weight paint mode on object B and use Smooth Vertex Groups operator, the operator will also affect object A.

Exact steps for others to reproduce the error
In attached blend:

  • execute the Smooth Vertex Weights operator
  • increase number of iterations to better see the issue
  • notice how the deselected objects' weights are getting smoothed. (Those objects are in weight paint mode)

Other weight operators may be affected. I tried the Clean Vertex Groups operator, it didn't seem to be affected.

Event Timeline

Demeter Dzadik (Mets) updated the task description. (Show Details)
Sebastian Parborg (zeddb) triaged this task as Confirmed, Medium priority.
Demeter Dzadik (Mets) reopened this task as Open.Jul 1 2019, 8:30 PM

I agree, I can still reproduce this in today's build.

Strange, all meshes are in the weight paint mode, but with the exception of the active object, there is no visual indication of in what mode the other meshes are.

Indicating that other objects are in weight paint can be implemented.
But an easier solution would be to change the operator to run only on the active object in that case:

diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 678f6f50096..883fe5e4668 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -3278,9 +3278,18 @@ static int vertex_group_smooth_exec(bContext *C, wmOperator *op)
   ViewLayer *view_layer = CTX_data_view_layer(C);
   Object *ob_ctx = ED_object_context(C);
-  uint objects_len = 0;
-  Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(
-      view_layer, CTX_wm_view3d(C), &objects_len, ob_ctx->mode);
+  bool free_object_array = false;
+  uint objects_len = 1;
+  Object **objects;
+  if (ob_ctx->mode == OB_MODE_EDIT) {
+    free_object_array = true;
+    objects = BKE_view_layer_array_from_objects_in_mode_unique_data(
+        view_layer, CTX_wm_view3d(C), &objects_len, ob_ctx->mode);
+  }
+  else {
+    objects = &ob_ctx;
+  }
   for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
     Object *ob = objects[ob_index];
@@ -3296,7 +3305,9 @@ static int vertex_group_smooth_exec(bContext *C, wmOperator *op)
     WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
     WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-  MEM_freeN(objects);
+  if (free_object_array) {
+    MEM_freeN(objects);
+  }

I think the fact that non-active objects in weight paint mode don't show the weight paint overlay is normal. Remember, the other objects in this scenario are not selected, so I wouldn't expect them to have the weight paint overlay. Even if they were selected, multi-object weight paint mode isn't a thing right now afaik(although it would be a welcome feature!), so I would still only expect the active object to have the weight paint overlay. This aspect is working as intended in my opinion.

I'm glad the easier solution is the one you describe, since that would make sense to me. After all, what other operator works on objects that are not even selected? So I think that's the main problem here, that it looks as though the Smooth Vertex Weights operator just checks the scene for any object that happens to be in weight paint mode, and operates on it, which probably goes against all kinds of Blender design philosophies.