Regression: Script using bmesh.ops.wireframe and bmesh.ops.bevel does not work the same in 3.1 and in 3.01. #96308

Closed
opened 2022-03-10 19:29:33 +01:00 by Christopher S Nichols · 22 comments

System Information
Operating system: platform: 'Windows-10-10.0.19042-SP0'
Graphics card: Radeon RX 570 Series

Blender Version
Broken: version: 3.1.0, branch: master, commit date: 2022-03-08 18:16, hash: c77597cd0e, type: release
Worked: version: 3.0.1, branch: master, commit date: 2022-01-25 17:19, hash: dc2d180181, type: release

Short description of error
In 3.1 it acts like a simple bevel not properly adding the offset of the wireframe added to the mesh. In 3.01 I get a defined edge that is offset and beveled. In both, I keep the original geometry.

Exact steps for others to reproduce the error

  • Paste the provided script in Text editor
  • Execute
import bpy
import bmesh
from bpy import context as C

obj = C.active_object
me = obj.data
bm = bmesh.new()
bm.from_mesh(me)

bmesh.ops.wireframe(bm, faces=bm.faces, thickness=0.02, offset=.1, 
                    use_replace=False, use_boundary=True, use_even_offset=True, use_relative_offset=True, material_offset=-1)

bmesh.ops.bevel(bm, geom=bm.edges, offset=.05, segments=6, profile=.5, affect='EDGES', clamp_overlap=True, material=-1)

bm.to_mesh(me)
me.update()
bm.free()
**System Information** Operating system: platform: 'Windows-10-10.0.19042-SP0' Graphics card: Radeon RX 570 Series **Blender Version** Broken: version: 3.1.0, branch: master, commit date: 2022-03-08 18:16, hash: c77597cd0e15, type: release Worked: version: 3.0.1, branch: master, commit date: 2022-01-25 17:19, hash: dc2d18018171, type: release **Short description of error** In 3.1 it acts like a simple bevel not properly adding the offset of the wireframe added to the mesh. In 3.01 I get a defined edge that is offset and beveled. In both, I keep the original geometry. **Exact steps for others to reproduce the error** - Paste the provided script in Text editor - Execute ``` import bpy import bmesh from bpy import context as C obj = C.active_object me = obj.data bm = bmesh.new() bm.from_mesh(me) bmesh.ops.wireframe(bm, faces=bm.faces, thickness=0.02, offset=.1, use_replace=False, use_boundary=True, use_even_offset=True, use_relative_offset=True, material_offset=-1) bmesh.ops.bevel(bm, geom=bm.edges, offset=.05, segments=6, profile=.5, affect='EDGES', clamp_overlap=True, material=-1) bm.to_mesh(me) me.update() bm.free() ```

Added subscriber: @Armageddon29

Added subscriber: @Armageddon29

#96693 was marked as duplicate of this issue

#96693 was marked as duplicate of this issue

#96522 was marked as duplicate of this issue

#96522 was marked as duplicate of this issue

#96305 was marked as duplicate of this issue

#96305 was marked as duplicate of this issue
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Hi, thanks for the report. Issue appears to be related to #96305 (Applying Wireframe modifier does not apply correctly)
Can you confirm?

Hi, thanks for the report. Issue appears to be related to #96305 (Applying Wireframe modifier does not apply correctly) Can you confirm?

Actually, I checked adding the wireframe and the bevel modifiers and they work just fine in 3.1. It appears to mess up only in the bmesh script and only in 3.1. I also noticed that if I save the file in 3.1 and then open it up in 3.01 the script doesn't work then either. If I open a new file in 3.01 and copy the script it will work. I know you updated python, but I don't see how that could affect it. I am puzzled because it doesn't make sense to me why a file saved in 3.1 and opened in 3.01 would treat the code differently than when it was written the same in 3.01. I will leave it to someone more capable than I to ferret out the cause. If you need any more info, let me know.

Sincerely

Chris Nichols

Actually, I checked adding the wireframe and the bevel modifiers and they work just fine in 3.1. It appears to mess up only in the bmesh script and only in 3.1. I also noticed that if I save the file in 3.1 and then open it up in 3.01 the script doesn't work then either. If I open a new file in 3.01 and copy the script it will work. I know you updated python, but I don't see how that could affect it. I am puzzled because it doesn't make sense to me why a file saved in 3.1 and opened in 3.01 would treat the code differently than when it was written the same in 3.01. I will leave it to someone more capable than I to ferret out the cause. If you need any more info, let me know. Sincerely Chris Nichols
Member

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Member

Actually, I checked adding the wireframe and the bevel modifiers and they work just fine in 3.1.

Hi, this did not work for me when I apply both modifiers (works until they are in modifiers stack)

I also noticed that if I save the file in 3.1 and then open it up in 3.01 the script doesn't work then either.

This is not clear to me either. Maybe python 3.10 upgrade is responsible? (just a guess)

Speaking about the original report, I'm pretty sure its a duplicate of #96305 (Applying Wireframe modifier does not apply correctly)
But I'd like to confirm this from @HooglyBoogly

> Actually, I checked adding the wireframe and the bevel modifiers and they work just fine in 3.1. Hi, this did not work for me when I apply both modifiers (works until they are in modifiers stack) > I also noticed that if I save the file in 3.1 and then open it up in 3.01 the script doesn't work then either. This is not clear to me either. Maybe python 3.10 upgrade is responsible? (just a guess) Speaking about the original report, I'm pretty sure its a duplicate of #96305 (Applying Wireframe modifier does not apply correctly) But I'd like to confirm this from @HooglyBoogly

To whom it may concern, I did the modifiers (wireframe, bevel), and once applied (which I did not do before sorry) it didn't work. Since I try to work non-destructively, it did not occur to me to apply them.

To whom it may concern, I did the modifiers (wireframe, bevel), and once applied (which I did not do before sorry) it didn't work. Since I try to work non-destructively, it did not occur to me to apply them.
Member

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Member

This is related to #96305, but since this involves the Python API and the other doesn't, I think we should keep both open.

The issue is that the BMesh created by BM_mesh_bm_from_me doesn't always have valid normals. I think that's a good thing, because when creating a BMesh, the normals might not be necessary.
It often breaks though, because BMesh has no way to track whether the normals are dirty or not, and existing code creating a BMesh often assumed that normals were in a valid state.

I can think of a few solutions:

  1. Always calculate normals when creating a BMesh.
  • I don't think this is a good option.
  1. Change BMeshFromMeshParams.calc_face_normal to ``BMeshFromMeshParams.calc_normals` and also calculate vertex normals when this is true.
  • A good option I think.
  1. Add a calc_vertex_normal field to BMeshFromMeshParams and related API functions. Set this to true wherever calc_face_normal is already true.
  • This is slightly more complicated than option 2, but has the benefit that we can only calculate normals for one layer if necessary (which becomes more important when face corner normals are handled in a similar way in the future).
  1. Add dirty normal tracking to BMesh and do all the normal calculation automatically.
  • Maybe a "better" solution to have the design more similar to Mesh, but this isn't something I'm that interested in spending time on now.

@ideasman42 I think I'd go with option 3. With your go-ahead, I'd create a patch for this.

This is related to #96305, but since this involves the Python API and the other doesn't, I think we should keep both open. The issue is that the BMesh created by `BM_mesh_bm_from_me` doesn't always have valid normals. I think that's a good thing, because when creating a BMesh, the normals might not be necessary. It often breaks though, because BMesh has no way to track whether the normals are dirty or not, and existing code creating a BMesh often assumed that normals were in a valid state. I can think of a few solutions: 1. Always calculate normals when creating a BMesh. - I don't think this is a good option. 2. Change `BMeshFromMeshParams.calc_face_normal` to ``BMeshFromMeshParams.calc_normals` and also calculate vertex normals when this is true. - A good option I think. 3. Add a `calc_vertex_normal` field to `BMeshFromMeshParams` and related API functions. Set this to true wherever `calc_face_normal` is already true. - This is slightly more complicated than option 2, but has the benefit that we can only calculate normals for one layer if necessary (which becomes more important when face corner normals are handled in a similar way in the future). 4. Add dirty normal tracking to BMesh and do all the normal calculation automatically. - Maybe a "better" solution to have the design more similar to Mesh, but this isn't something I'm that interested in spending time on now. @ideasman42 I think I'd go with option 3. With your go-ahead, I'd create a patch for this.
Member

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'
Member

Actually, I think I'll merge the other report here, because these reproduction steps are simpler and get at the problem a bit better. Fixing the issue would fix both issues anyway.

Actually, I think I'll merge the other report here, because these reproduction steps are simpler and get at the problem a bit better. Fixing the issue would fix both issues anyway.
Member

Added subscriber: @Burhursta

Added subscriber: @Burhursta
Hans Goudey self-assigned this 2022-03-11 18:57:31 +01:00
Member

Added subscriber: @Rafamizi

Added subscriber: @Rafamizi
Member

Added subscriber: @xidingart

Added subscriber: @xidingart

This issue was referenced by fb2cb0324a

This issue was referenced by fb2cb0324a391041db3fdc6c66ce992adf9598aa

This issue was referenced by 64cd927519

This issue was referenced by 64cd927519748bbd50b856c25f7e4eac17d8c780
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Philipp Oeser changed title from Script using bmesh.ops.wireframe and bmesh.ops.bevel does not work the same in 3.1 and in 3.01. to Regression: Script using bmesh.ops.wireframe and bmesh.ops.bevel does not work the same in 3.1 and in 3.01. 2022-03-22 16:07:23 +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
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#96308
No description provided.