Boolean modifier with Freestyle edges #40315

Closed
opened 2014-05-22 17:26:18 +02:00 by Fazekas Laszlo · 22 comments
Member

System Information
Ubuntu 14.04 64bit NVidia 440

Blender Version
Broken: 2.70 c56bbcc
Worked: (optional)

Short description of error
Boolean modifier keeps only the Freestyle edges of the original mesh (not like the Sharp/Seam edges, they are merged with the masking mesh). If you apply the modifier, all Freestyle edge attributes are lost.

Exact steps for others to reproduce the error
Create two mesh objects. Set boolean modifier for one of them using the other. Set some Freestyle edges for both of them in Edit mode. Disable the masking layer for rendering so you can see only the modifier's output. Render it with Freestyle enabled. You can see only the original mesh's Freestyle edges are there. Apply the modifier. Render again. No Freestyle edges at all.
bool_edge_mark.blend

**System Information** Ubuntu 14.04 64bit NVidia 440 **Blender Version** Broken: 2.70 c56bbcc Worked: (optional) **Short description of error** Boolean modifier keeps only the Freestyle edges of the original mesh (not like the Sharp/Seam edges, they are merged with the masking mesh). If you apply the modifier, all Freestyle edge attributes are lost. **Exact steps for others to reproduce the error** Create two mesh objects. Set boolean modifier for one of them using the other. Set some Freestyle edges for both of them in Edit mode. Disable the masking layer for rendering so you can see only the modifier's output. Render it with Freestyle enabled. You can see only the original mesh's Freestyle edges are there. Apply the modifier. Render again. No Freestyle edges at all. [bool_edge_mark.blend](https://archive.blender.org/developer/F89714/bool_edge_mark.blend)
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @totoro-4

Added subscriber: @totoro-4
Sergey Sharybin self-assigned this 2014-05-22 18:29:57 +02:00

Added subscriber: @kjym3

Added subscriber: @kjym3

Just FYI, Campbell recently addressed a similar problem with the subsurf modifier in the commit 3182c54da6.

Just FYI, Campbell recently addressed a similar problem with the subsurf modifier in the commit 3182c54da6.
Author
Member

The exporter_SetEdge() in MOD_boolean_util.c copies the edge customdata. It seems for me (but not sure, I apologize for the things below if I'm wrong) that CARVE_MESH_LEFT means the original object and CARVE_MESH_RIGHT is the masking object. But I don't know what CustomData_copy_data() copies here. Maybe this supposed to copy the edge customdata from the CARVE_MESH_RIGHT object? Because the CARVE_MESH_LEFT object's data comes from somewhere else. If I comment out this copy instruction the freestyle edges are still there (before applying of course).

I think 'orig_edge_index' has a meaning only together with 'which_orig_mesh' here.

But even this copied data won't be in the final result if the applyModifier() gets the MOD_APPLY_USECACHE flag in MOD_boolean.c.

The exporter_SetEdge() in MOD_boolean_util.c copies the edge customdata. It seems for me (but not sure, I apologize for the things below if I'm wrong) that CARVE_MESH_LEFT means the original object and CARVE_MESH_RIGHT is the masking object. But I don't know what CustomData_copy_data() copies here. Maybe this supposed to copy the edge customdata from the CARVE_MESH_RIGHT object? Because the CARVE_MESH_LEFT object's data comes from somewhere else. If I comment out this copy instruction the freestyle edges are still there (before applying of course). I think 'orig_edge_index' has a meaning only together with 'which_orig_mesh' here. But even this copied data won't be in the final result if the applyModifier() gets the MOD_APPLY_USECACHE flag in MOD_boolean.c.

This issue was referenced by 3b4f792ce1

This issue was referenced by 3b4f792ce102f5c892e4108c19512dd3b9968335

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 3b4f792ce1.

Closed by commit 3b4f792ce1.
Author
Member

Added subscriber: @Sergey

Added subscriber: @Sergey
Author
Member

@Sergey thank you! But something still missing. Now the edges are there from both objects AFTER applying the modifier, but through the modifier the edges from the masking object are still missing. Render my original example scene before and after apply to see the difference.

@Sergey thank you! But something still missing. Now the edges are there from both objects AFTER applying the modifier, but through the modifier the edges from the masking object are still missing. Render my original example scene before and after apply to see the difference.
Author
Member

I don't know if it helps, but I've made some debugging with this MOD_boolean_util.c. The output DerivedMesh always contains the good freestyle edge customdata layer, but later (I don't know where) something overwrites this information. This happening after the modifier, and it rebuilds the freestyle edge layer (and perhaps others too) using the contents of the CD_ORIGINDEX layer as an index to the original mesh's edges. The exporter_SetEdge() function fills the contents of this index layer but it refers only to the original mesh (left) and not to the masking mesh (right).

I don't know if it helps, but I've made some debugging with this MOD_boolean_util.c. The output DerivedMesh always contains the good freestyle edge customdata layer, but later (I don't know where) something overwrites this information. This happening after the modifier, and it rebuilds the freestyle edge layer (and perhaps others too) using the contents of the CD_ORIGINDEX layer as an index to the original mesh's edges. The exporter_SetEdge() function fills the contents of this index layer but it refers only to the original mesh (left) and not to the masking mesh (right).

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'

Hi @Sergey,
Thank to the commit, now applying the modifier gives a correct boolean result with all Freestyle edge marks kept. Still only edge marks of the modified object (left object) are kept when rendering without applying the modifier, and those edge marks from the modifier parameter object (right object) are lost.

Hi @Sergey, Thank to the commit, now applying the modifier gives a correct boolean result with all Freestyle edge marks kept. Still only edge marks of the modified object (left object) are kept when rendering without applying the modifier, and those edge marks from the modifier parameter object (right object) are lost.
Author
Member

I think this is a design bug in the modifier system. The 3182c54da6 bug was the same thing. Now the modifiers must serve two different workflows at once. For applying it creates the customdata by itself, but without applying it passes a list about the edges mapping (and perhaps faces etc.). I think the modifier knows better what is what, so this postprocessing is not a good idea. It restricts design of future modifiers too. Was this originally a speedup to not copy all the data during the modifier chain but only reference?

I think this is a design bug in the modifier system. The 3182c54da6 bug was the same thing. Now the modifiers must serve two different workflows at once. For applying it creates the customdata by itself, but without applying it passes a list about the edges mapping (and perhaps faces etc.). I think the modifier knows better what is what, so this postprocessing is not a good idea. It restricts design of future modifiers too. Was this originally a speedup to not copy all the data during the modifier chain but only reference?

@kjym3, afraid that's up to you, not me ;)

Seems that the issue is inside make_freestyle_edge_mark_hash() which for some reason uses CD layer from original mesh, not DM. Hence it'll fail to get flags for edges which doesn't ORIGINDEX.

Here's a patch which makes it so flags from DM are used, but not sure maybe it was a reason to use flags from the base mesh (which i don't actually see): http://www.pasteall.org/51902/diff

@kjym3, afraid that's up to you, not me ;) Seems that the issue is inside `make_freestyle_edge_mark_hash()` which for some reason uses CD layer from original mesh, not DM. Hence it'll fail to get flags for edges which doesn't ORIGINDEX. Here's a patch which makes it so flags from DM are used, but not sure maybe it was a reason to use flags from the base mesh (which i don't actually see): http://www.pasteall.org/51902/diff
Author
Member

I'm happy to hear it is not a general problem in Blender. Actually I didn't check the freestyle part... Thank you @Sergey!

I'm happy to hear it is not a general problem in Blender. Actually I didn't check the freestyle part... Thank you @Sergey!
Sergey Sharybin removed their assignment 2014-05-28 15:46:03 +02:00
Tamito Kajiyama was assigned by Sergey Sharybin 2014-05-28 15:46:03 +02:00

Thank you Sergey for the fix for make_freestyle_edge_mark_hash(). I found a related issue that edge marks from the parameter object of the boolean modifier were still missing when the object has modifiers in its own modifier stack. Please, consider a code review of D558 which includes fixes of the two issues.

Thank you Sergey for the fix for make_freestyle_edge_mark_hash(). I found a related issue that edge marks from the parameter object of the boolean modifier were still missing when the object has modifiers in its own modifier stack. Please, consider a code review of [D558](https://archive.blender.org/developer/D558) which includes fixes of the two issues.
Author
Member

Hello @kjym3, thank you! I hope this finishes this bug. I cannot try it yet, the code review is not in the git. As a notice, I see a very similar part in convertblender.c at lines 3327 and 3366 for the CD_FREESTYLE_FACE marks, using the CD_ORIGINDEX again. Maybe it also needs a correction?

Hello @kjym3, thank you! I hope this finishes this bug. I cannot try it yet, the code review is not in the git. As a notice, I see a very similar part in convertblender.c at lines 3327 and 3366 for the CD_FREESTYLE_FACE marks, using the CD_ORIGINDEX again. Maybe it also needs a correction?

Yes, the CD_FREESTYLE_FACE stuff also requires a code revision. Patch D558 focuses on edge marks. I will address the face marks issue separately.

Yes, the CD_FREESTYLE_FACE stuff also requires a code revision. Patch [D558](https://archive.blender.org/developer/D558) focuses on edge marks. I will address the face marks issue separately.

This issue was referenced by edfd989e86

This issue was referenced by edfd989e864f2c87d2bbceef1acf88bbb46db497

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit edfd989e86.

Closed by commit edfd989e86.
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
4 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#40315
No description provided.