Fix #121004: bmesh.ops.dissolve_limit wrong in certain cases #121033

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:121004 into main 2024-04-26 07:48:10 +02:00
Member

Exposed by 6c774feba2

BM_mesh_decimate_dissolve_ex sets up DelimitData with layer offset
(start), size and end so that bm_edge_is_contiguous_loop_cd_all can
check a range of edges for being contiguous.

The way cd_loop_offset_end is calculated is wrong though, it does not
take the actual start into account (this has to be added to fix the
bug). When it is wrong, it can happen that start and end are the same,
so no check actually takes place and no delimiting edges are found.

It seems that prior to 6c774feba2 the customdata layer always had an
offset of zero, so never really showed in practice (at least I couldnt
make it break in 3.4), but after 6c774feba2 we can at least observe the
following:

  • when creating a bmesh, an offset would to the uv layer would still be
    zero in my tests
  • however, as soon as we iterate loops of a face (as done in the
    report), we get an additional layer CD_BM_ELEM_PYPTR
  • this then changes the offset
  • BM_uv_map_get_offsets_from_layer seems to do the right thing afaict

So to resolve, just add the "start" offset to the end, to get the right
range.

NOTE: there is a very similar DelimitData used in
bmesh.ops.join_triangles and the way in which bm_edge_delimit_cdata
sets up te range is exactly like what this PR proposes.

Exposed by 6c774feba2 `BM_mesh_decimate_dissolve_ex` sets up `DelimitData` with layer offset (start), size and end so that `bm_edge_is_contiguous_loop_cd_all` can check a range of edges for being contiguous. The way `cd_loop_offset_end` is calculated is wrong though, it does not take the actual start into account (this has to be added to fix the bug). When it is wrong, it can happen that start and end are the same, so no check actually takes place and no delimiting edges are found. It seems that prior to 6c774feba2 the customdata layer always had an offset of zero, so never really showed in practice (at least I couldnt make it break in 3.4), but after 6c774feba2 we can at least observe the following: - when creating a bmesh, an offset would to the uv layer would still be zero in my tests - however, as soon as we iterate loops of a face (as done in the report), we get an additional layer `CD_BM_ELEM_PYPTR` - this then changes the offset - `BM_uv_map_get_offsets_from_layer` seems to do the right thing afaict So to resolve, just add the "start" offset to the end, to get the right range. NOTE: there is a very similar `DelimitData` used in `bmesh.ops.join_triangles` and the way in which `bm_edge_delimit_cdata` sets up te range is exactly like what this PR proposes.
Philipp Oeser added 1 commit 2024-04-24 16:54:44 +02:00
f16849ee69 Fix #121004: bmesh.ops.dissolve_limit wrong in certain cases
Exposed by 6c774feba2

`BM_mesh_decimate_dissolve_ex` sets up `DelimitData` with layer offset
(start), size and end so that `bm_edge_is_contiguous_loop_cd_all` can
check a range of edges for being contiguous.

The way `cd_loop_offset_end` is calculated is wrong though, it does not
take the actual start into account (this has to be added to fix the
bug). When it is wrong, it can happen that start and end are the same,
so no check actually takes place and no delimiting edges are found.

It seems that prior to 6c774feba2 the customdata layer always had an
offset of zero, so never really showed in practice (at least I couldnt
make it break in 3.4), but after 6c774feba2 we can at least observe the
following:
- when creating a bmesh, an offset would to the uv layer would still be
zero in my tests
- however, as soon as we iterate loops of a face (as done in the
report), we get an additional layer `CD_BM_ELEM_PYPTR`
- this then changes the offset
- `BM_uv_map_get_offsets_from_layer` seems to do the right thing afaict

So to resolve, just add the "start" offset to the end, to get the right
range.

NOTE: there is a very similar `DelimitData` used in
`bmesh.ops.join_triangles` and the way in which `bm_edge_delimit_cdata`
sets up te range is exactly like what this PR proposes.
Philipp Oeser added this to the Modeling project 2024-04-24 16:54:59 +02:00
Philipp Oeser added the
Interest
UV Editing
label 2024-04-24 16:55:06 +02:00
Philipp Oeser requested review from Martijn Versteegh 2024-04-24 16:55:16 +02:00
Philipp Oeser requested review from Hans Goudey 2024-04-24 16:55:22 +02:00
Philipp Oeser requested review from Campbell Barton 2024-04-24 16:55:28 +02:00
Hans Goudey approved these changes 2024-04-24 17:23:41 +02:00
Hans Goudey left a comment
Member

Great investigation! The fix is clear, looks good to go.

Great investigation! The fix is clear, looks good to go.

Looks good to me. Must have been quite a goose chase.

Looks good to me. Must have been quite a goose chase.
Campbell Barton approved these changes 2024-04-25 04:21:37 +02:00
Martijn Versteegh approved these changes 2024-04-25 17:23:11 +02:00
Philipp Oeser merged commit e816b481e0 into main 2024-04-26 07:48:10 +02:00
Philipp Oeser deleted branch 121004 2024-04-26 07:48:13 +02: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#121033
No description provided.