Boolean Modifier is evaluated if an object linked to the cutter object is link-duplicated #84156

Open
opened 2020-12-26 19:38:47 +01:00 by Matthew Wiebe · 4 comments

System Information
Operating system: Linux-5.4.0-58-generic-x86_64-with-debian-bullseye-sid 64 Bits
Graphics card: GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 455.38

Blender Version
Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: 0f45cab862

Short description of error
Suppose ObjectA has a boolean modifier, the target object of which is CutterA. CutterA shares the same mesh datablock as CutterB. If CutterB is link-duplicated (Alt-D), ObjectA 's boolean modifier is re-evaluated. In large technical scenes with many linked cutters this means Blender frequently stalls, re-evaluating every boolean in the scene every time you duplicate a cutter.

Expected behaviour: boolean modifier should only be evaluated if the cutter object datablocks change, and adding a user to a datablock should not count as a change.

**System Information** Operating system: Linux-5.4.0-58-generic-x86_64-with-debian-bullseye-sid 64 Bits Graphics card: GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 455.38 **Blender Version** Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: `0f45cab862` **Short description of error** Suppose ObjectA has a boolean modifier, the target object of which is CutterA. CutterA shares the same mesh datablock as CutterB. If CutterB is link-duplicated (Alt-D), ObjectA 's boolean modifier is re-evaluated. In large technical scenes with many linked cutters this means Blender frequently stalls, re-evaluating *every boolean in the scene every time you duplicate a cutter.* Expected behaviour: boolean modifier should only be evaluated if the cutter object datablocks *change*, and adding a user to a datablock should not count as a change.
Author

Added subscriber: @cerebral

Added subscriber: @cerebral

Added subscribers: @Sergey, @mont29

Added subscribers: @Sergey, @mont29

There are several sources for that update:

  • Some very, very old code in object duplicate operator (duplicate_exec in object_add.c file) would also deg-tag obdata. This was probably needed with old depsgraph, but definitively not with the new one? either mesh remains the same, and there is nothing to tag, or a new one is added, and depsgraph will know by itself it needs to process it.
  • deg_graph_on_visible_update will 'tag' mesh ID with 0, i.e. LEGACY_0, which it should most likely not use here.

deg_graph_id_tag_legacy_compat (which is currently called basically when tagging any ID for update) will currently systematically also tag with LEGACY_0 the object data, when called for an object.

tagging the mesh for update will then trigger geometry updates of all its object users...

Points 1. and 2. are fairly trivial to address, but point 3. is a bit of a rabbit hole, so would consider this more like a known issue.

Here is a dummy patch fixing all three aspects of the problem - but the 'fix' for 3. breaks even basic things like switching to Edit mode...

P1865: (An Untitled Masterwork)

diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 95ee8234ef3..97ef7a563c9 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -313,7 +313,7 @@ void deg_graph_id_tag_legacy_compat(
         Object *object = (Object *)id;
         ID *data_id = (ID *)object->data;
         if (data_id != nullptr) {
-          graph_id_tag_update(bmain, depsgraph, data_id, 0, update_source);
+          //          graph_id_tag_update(bmain, depsgraph, data_id, 0, update_source);
         }
         break;
       }
@@ -539,7 +539,10 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph, const bool do_ti
     if (id_type == ID_OB) {
       flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
     }
-    graph_id_tag_update(bmain, graph, id_node->id_orig, flag, DEG_UPDATE_SOURCE_VISIBILITY);
+    /* Do not update with LEGACY_0 flag here. */
+    if (flag != 0) {
+      graph_id_tag_update(bmain, graph, id_node->id_orig, flag, DEG_UPDATE_SOURCE_VISIBILITY);
+    }
     if (id_type == ID_SCE) {
       /* Make sure collection properties are up to date. */
       id_node->tag_update(graph, DEG_UPDATE_SOURCE_VISIBILITY);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 03ff8808423..ce65dab5f1a 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -3168,10 +3168,6 @@ static int duplicate_exec(bContext *C, wmOperator *op)
     if (BASACT(view_layer) == base) {
       ED_object_base_activate(C, basen);
     }
-
-    if (basen->object->data) {
-      DEG_id_tag_update(basen->object->data, 0);
-    }
   }
   CTX_DATA_END;
 

CC @Sergey for completeness.

There are several sources for that update: - Some very, very old code in object duplicate operator (`duplicate_exec` in `object_add.c` file) would also deg-tag obdata. This was probably needed with old depsgraph, but definitively not with the new one? either mesh remains the same, and there is nothing to tag, or a new one is added, and depsgraph will know by itself it needs to process it. - `deg_graph_on_visible_update` will 'tag' mesh ID with `0`, i.e. `LEGACY_0`, which it should most likely not use here. # `deg_graph_id_tag_legacy_compat` (which is currently called basically when tagging any ID for update) will currently systematically also tag with `LEGACY_0` the object data, when called for an object. tagging the mesh for update will then trigger geometry updates of all its object users... Points `1.` and `2.` are fairly trivial to address, but point `3.` is a bit of a rabbit hole, so would consider this more like a known issue. Here is a dummy patch fixing all three aspects of the problem - but the 'fix' for `3.` breaks even basic things like switching to Edit mode... [P1865: (An Untitled Masterwork)](https://archive.blender.org/developer/P1865.txt) ``` diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 95ee8234ef3..97ef7a563c9 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -313,7 +313,7 @@ void deg_graph_id_tag_legacy_compat( Object *object = (Object *)id; ID *data_id = (ID *)object->data; if (data_id != nullptr) { - graph_id_tag_update(bmain, depsgraph, data_id, 0, update_source); + // graph_id_tag_update(bmain, depsgraph, data_id, 0, update_source); } break; } @@ -539,7 +539,10 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph, const bool do_ti if (id_type == ID_OB) { flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY; } - graph_id_tag_update(bmain, graph, id_node->id_orig, flag, DEG_UPDATE_SOURCE_VISIBILITY); + /* Do not update with LEGACY_0 flag here. */ + if (flag != 0) { + graph_id_tag_update(bmain, graph, id_node->id_orig, flag, DEG_UPDATE_SOURCE_VISIBILITY); + } if (id_type == ID_SCE) { /* Make sure collection properties are up to date. */ id_node->tag_update(graph, DEG_UPDATE_SOURCE_VISIBILITY); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 03ff8808423..ce65dab5f1a 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -3168,10 +3168,6 @@ static int duplicate_exec(bContext *C, wmOperator *op) if (BASACT(view_layer) == base) { ED_object_base_activate(C, basen); } - - if (basen->object->data) { - DEG_id_tag_update(basen->object->data, 0); - } } CTX_DATA_END; ``` CC @Sergey for completeness.

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser removed the
Interest
Modeling
label 2023-02-09 15:28:44 +01:00
Philipp Oeser added the
Interest
Core
label 2023-02-10 11:09:27 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#84156
No description provided.