Maniphest T101804

vertex group re-appears, after it was previously removed via the API
Confirmed, NormalBUG

Assigned To
None
Authored By
MACHIN3 (MACHIN3)
Oct 13 2022, 5:56 PM
Tags
  • BF Blender
  • Modeling
  • Modifiers
Subscribers
Germano Cavalcante (mano-wii)
Hans Goudey (HooglyBoogly)
MACHIN3 (MACHIN3)

Description

System Information
Operating system: Linux-4.15.0-175-generic-x86_64-with-glibc2.27 64 Bits
Graphics card: NVIDIA GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.103.01

Blender Version
Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: rBb292cfe5a936
Worked: (newest version of Blender that worked as expected)

Short description of error
I have an object with 2 bevel modifiers. Each one uses it's own vertex group to control the beveling.
I have a script that applies the first mod in the stack, and then removes its vertex group as well.
If you run this script 2 times, both mods, and both vertex groups should be removed.
Curiously, while the modifiers are both removed successfully, the first vgroup will reappear after the second run of the script, so after the 2nd mod and vgroup have been removed.

To workaround this, you can toggle into edit mode and back into object mode at the beginning of the script.

Possibly related to the commits mentioned here: https://developer.blender.org/T93896 ?

video demo

Exact steps for others to reproduce the error

  • open the attached blend file
  • verify how each bevel mod is related to a vertex group sharing its name
  • run the script two times, and notice how the first vgroup reappears at the end

Event Timeline

MACHIN3 (MACHIN3) created this task.Oct 13 2022, 5:56 PM
MACHIN3 (MACHIN3) updated the task description.Oct 13 2022, 6:04 PM
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Oct 13 2022, 11:19 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".
Germano Cavalcante (mano-wii) added projects: Modeling, Modifiers.
Germano Cavalcante (mano-wii) added a subscriber: Germano Cavalcante (mano-wii).

I was able to confirm the problem and further simplify the file and script to just these lines:

import bpy

obj = bpy.context.active_object
obj.vertex_groups.remove(obj.vertex_groups.get("A"))
bpy.ops.object.modifier_apply(modifier="EdgeBevel")

Analyzing the code I could see that the Vertex Group is removed from ob->data but the Vertex Groups from ob_eval->runtime->data_orig are kept and copied when applying modifiers.

I'm not sure why ob->data is different from ob_eval->runtime->data_orig, but it doesn't feel right to keep the vertex group and restore when it's not even used anymore.

So I'm confirming it as a bug.

Hans Goudey (HooglyBoogly) added a subscriber: Hans Goudey (HooglyBoogly).EditedOct 14 2022, 2:38 PM

Not sure, but I'm guessing that removing a vertex group doesn't properly tag the object for reevaluation. Then the vertex group would still be on the evaluated mesh when it is applied.
Edit: Looked at this a bit more, my guess was wrong unfortunately.

MACHIN3 (MACHIN3) added a comment.Dec 19 2022, 10:41 PM

Any update on this?

MACHIN3 (MACHIN3) added a comment.Dec 19 2022, 10:45 PM
In T101804#1432176, @Germano Cavalcante (mano-wii) wrote:

I was able to confirm the problem and further simplify the file and script to just these lines:

import bpy

obj = bpy.context.active_object
obj.vertex_groups.remove(obj.vertex_groups.get("A"))
bpy.ops.object.modifier_apply(modifier="EdgeBevel")

Analyzing the code I could see that the Vertex Group is removed from ob->data but the Vertex Groups from ob_eval->runtime->data_orig are kept and copied when applying modifiers.

I'm not sure why ob->data is different from ob_eval->runtime->data_orig, but it doesn't feel right to keep the vertex group and restore when it's not even used anymore.

So I'm confirming it as a bug.

Note that in a real world example, you would definitely want to apply the mod first, and then remove the vertex group afterwards, as otherwise you would get a very different result.
I'm not sure how that affects the bug you exposed, but I wanted to mention it, in case it becomes a different issue then.