Mesh: Subdivide op flushes selection too eagerly #83181

Open
opened 2020-11-29 13:49:53 +01:00 by Stanislav Blinov · 24 comments

Blender Version
Broken: 2.92 master
Worked: N/A

Short description of error

The Subdivide operator selects geometry that it shouldn't. Consider this example:

image.png

It looks as if the op flushes selection a bit too much. Note that the 'Expected' selection is valid selection in edge mode, as the edge rings around the rims are not selected. Those edges should neither participate in the op, nor be selected as the result of it, if vertex selection mode is not enabled.

A better example:

image.png

...here in face mode, a lone edge is getting selected by the op.

Exact steps for others to reproduce the error

  1. On the default cube, in face mode select top and bottom faces, inset and bridge them.
  2. In edge mode select vertical edge rings.
  3. Subdivide.

Alternatively, load this simplified example file:

subdivide_selection_issue.blend

...and Subdivide. Resulting selection of the middle face is unwarranted.

**Blender Version** Broken: 2.92 master Worked: N/A **Short description of error** The Subdivide operator selects geometry that it shouldn't. Consider this example: ![image.png](https://archive.blender.org/developer/F9407253/image.png) It looks as if the op flushes selection a bit too much. Note that the 'Expected' selection is valid selection in edge mode, as the edge rings around the rims are **not** selected. Those edges should neither participate in the op, nor be selected as the result of it, if vertex selection mode is not enabled. A better example: ![image.png](https://archive.blender.org/developer/F9415315/image.png) ...here in face mode, a lone edge is getting selected by the op. **Exact steps for others to reproduce the error** 1. On the default cube, in face mode select top and bottom faces, inset and bridge them. 2. In edge mode select vertical edge rings. 3. Subdivide. Alternatively, load this simplified example file: [subdivide_selection_issue.blend](https://archive.blender.org/developer/F9407395/subdivide_selection_issue.blend) ...and Subdivide. Resulting selection of the middle face is unwarranted.

Added subscriber: @Stan_Pancakes

Added subscriber: @Stan_Pancakes
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Think this is a similar problem/situation as {#73771}?
After subdivide, the original selection as well as the added geometry are selected. If this is flushed, you end up with everything selected

2.79b did the same thing, no?
image.png
image.png

Think this is a similar problem/situation as {#73771}? After subdivide, the original selection as well as the added geometry are selected. If this is flushed, you end up with everything selected 2.79b did the same thing, no? ![image.png](https://archive.blender.org/developer/F9413253/image.png) ![image.png](https://archive.blender.org/developer/F9413263/image.png)
Member

image.png
image.png

![image.png](https://archive.blender.org/developer/F9413272/image.png) ![image.png](https://archive.blender.org/developer/F9413277/image.png)
Member

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

Changed status from 'Needs Triage' to: 'Archived'
Member

So unless we can really make a point for this being a bug, I think we have to close this.
Like I said, feel free to comment again [we can always reopen], but as it stands now, I dont think this is a bug.

So unless we can really make a point for this being a bug, I think we have to close this. Like I said, feel free to comment again [we can always reopen], but as it stands now, I dont think this is a bug.

My bad, I must've done something wrong while testing on 2.79b. Re-testing indeed shows the same behavior as current.

Still, I maintain that this flush is incorrect. The new geometry in this case is that which is selected in my "Expected" case: the new loops and new faces, and as a result - edges around them. Had this been done in vertex selection mode, then yes, it should've selected the rim as well, as a consequence of vertex selection propagating to edges. But in this case this is done in edge selection mode, yet it seems the op is still flushing from verts.

My bad, I must've done something wrong while testing on 2.79b. Re-testing indeed shows the same behavior as current. Still, I maintain that this flush is incorrect. The new geometry in this case is that which is selected in my "Expected" case: the new loops and new faces, and as a result - edges around them. Had this been done in vertex selection mode, then yes, it should've selected the rim as well, as a consequence of vertex selection propagating to edges. But in this case this is done in edge selection mode, yet it seems the op is still flushing from verts.

Here's a more concrete indication that this is a bug:

image.png

In both edge and face mode, the edge between those original selections gets selected as a result of Subdivide. It shouldn't be, in either mode, especially in face mode as that creates selection inconsistent with current mode.

Here's a more concrete indication that this is a bug: ![image.png](https://archive.blender.org/developer/F9415315/image.png) In both edge and face mode, the edge between those original selections gets selected as a result of Subdivide. It shouldn't be, in either mode, especially in face mode as that creates selection inconsistent with current mode.

@lichtwerk Any thoughts wrt. above?

@lichtwerk Any thoughts wrt. above?

Should I open a new one?..

Should I open a new one?..
Member

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

Changed status from 'Archived' to: 'Needs Triage'
Member

Need to have a look again...

Need to have a look again...

Added subscriber: @wiwa

Added subscriber: @wiwa

This comment was removed by @wiwa

*This comment was removed by @wiwa*

This comment was removed by @wiwa

*This comment was removed by @wiwa*

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Removed subscribers: @dr.sybren, @wiwa

Removed subscribers: @dr.sybren, @wiwa
Member

@Stan_Pancakes : Still think this is expected behavior tbh.

We have https://docs.blender.org/api/current/bmesh.html#keeping-a-correct-state which tells us each faces vertices should get selected on the operation and flushed.
Both participating verts of the edge in question are selected in your example (and thus drawn selected).
In a way, your second example does not really differ from your first example?

This (drawing indirectly participating edges selected) doesnt happen on raw face selection (because I think flushing only takes places when changing to e.g. vertex or edge selection mode), so I would still think this is all expected actually.
Why again would you think the second example is different from the first?

@Stan_Pancakes : Still think this is expected behavior tbh. We have https://docs.blender.org/api/current/bmesh.html#keeping-a-correct-state which tells us each faces vertices should get selected on the operation and flushed. Both participating verts of the edge in question are selected in your example (and thus drawn selected). In a way, your second example does not really differ from your first example? This (drawing indirectly participating edges selected) doesnt happen on raw face selection (because I think flushing only takes places when changing to e.g. vertex or edge selection mode), so I would still think this is all expected actually. Why again would you think the second example is different from the first?

It's not different, it's the same thing just better illustraded. That edge is getting selected regardless of mode you're in. For face mode, that's not even a correct selection state - you can't achieve such selection through normal means (and should not be able to).

I haven't looked at the code yet, but from what's going on I gather that the op simply selects all the resulting verts and flushes from them. That's not correct behavior. If you're in edge selection mode, flushing should be done from edges to verts and to faces, but not to verts and then back to edges. I.e. something like this (quick mockup, not thoroughly tested):

import bpy
import bmesh

def subdivide_mockup(context):
    mesh = context.object.data
    bm = bmesh.from_edit_mesh(mesh)
    
    edges = [e for e in bm.edges if e.select]
    
    bpy.ops.mesh.select_all(action = 'DESELECT')
    
    # other options omitted for brevity
    result = bmesh.ops.subdivide_edges(bm, edges = edges, cuts = 1, use_grid_fill = True)
    
    for e in filter(lambda e: isinstance(e, bmesh.types.BMEdge), result['geom_inner']):
        e.select = True
        # also select new faces since that's what Subdivide appears to want to do
        for f in e.link_faces:
            f.select = True
            
    for g in result['geom_split']:
        g.select = True
    
    bm.select_flush_mode()
    bmesh.update_edit_mesh(mesh)
    
subdivide_mockup(bpy.context)
It's not different, it's the same thing just better illustraded. That edge is getting selected regardless of mode you're in. For face mode, that's not even a correct selection state - you can't achieve such selection through normal means (and should not be able to). I haven't looked at the code yet, but from what's going on I gather that the op simply selects all the resulting verts and flushes from them. That's not correct behavior. If you're in edge selection mode, flushing should be done from edges to verts and to faces, but not to verts and then back to edges. I.e. something like this (quick mockup, not thoroughly tested): ``` import bpy import bmesh def subdivide_mockup(context): mesh = context.object.data bm = bmesh.from_edit_mesh(mesh) edges = [e for e in bm.edges if e.select] bpy.ops.mesh.select_all(action = 'DESELECT') # other options omitted for brevity result = bmesh.ops.subdivide_edges(bm, edges = edges, cuts = 1, use_grid_fill = True) for e in filter(lambda e: isinstance(e, bmesh.types.BMEdge), result['geom_inner']): e.select = True # also select new faces since that's what Subdivide appears to want to do for f in e.link_faces: f.select = True for g in result['geom_split']: g.select = True bm.select_flush_mode() bmesh.update_edit_mesh(mesh) subdivide_mockup(bpy.context) ```
Member

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

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

Added subscribers: @DanielBystedt, @mont29, @ideasman42

Added subscribers: @DanielBystedt, @mont29, @ideasman42
Member

Afraid I cannot make the final call here.
To me, this does not look like a bug, but there are cases where the described behavior would be benificial.

CC @mont29
CC @ideasman42
CC @DanielBystedt

Afraid I cannot make the final call here. To me, this does not look like a bug, but there are cases where the described behavior would be benificial. CC @mont29 CC @ideasman42 CC @DanielBystedt
Member

Good find @Stan_Pancakes

I agree with what you write regarding not ending up with the expected selection after using the subdivide operator. I am stating this from a design perspective as it this might be the expected behavior based on how the code is written.


Below I did a test with the example you described above. I agree that after subdividing the "inner" and "outer" edge ring, the faces pointing in +Z and -Z should not be selected.

#83181 subdivide edges.mp4


Interesting enough, I ended up with the expected selection in this example below. After subdividing the selected faces I first changed to vertex select and then face select, which gave me a desired selection. I agree that the edge in the middle should not be selected after subdividing the faces in the example below

#83181 subdivide faces.mp4

Good find @Stan_Pancakes I agree with what you write regarding not ending up with the expected selection after using the subdivide operator. I am stating this from a design perspective as it this might be the expected behavior based on how the code is written. --- Below I did a test with the example you described above. I agree that after subdividing the "inner" and "outer" edge ring, the faces pointing in +Z and -Z should not be selected. [#83181 subdivide edges.mp4](https://archive.blender.org/developer/F9525862/T83181_subdivide_edges.mp4) --- Interesting enough, I ended up with the expected selection in this example below. After subdividing the selected faces I first changed to **vertex select** and then **face select**, which gave me a desired selection. I agree that the edge in the middle should not be selected after subdividing the faces in the example below [#83181 subdivide faces.mp4](https://archive.blender.org/developer/F9525867/T83181_subdivide_faces.mp4)

Yes, mode switching validates selection, thus enabling exclusive face selection mode while having a lone edge selected deselects that edge. This is why I maintain that such selection shouldn't be created by the op in the first place (i.e. that this behavior is actually a bug in the op). The thing is, the examples are equivalent: in both cases the stray edge is being selected due to flushing from vertices regardless of selection mode. It's just that the second example shows more clearly why this is a problem.

Yes, mode switching validates selection, thus enabling exclusive face selection mode while having a lone edge selected deselects that edge. This is why I maintain that such selection shouldn't be created by the op in the first place (i.e. that this behavior is actually a bug in the op). The thing is, the examples are equivalent: in both cases the stray edge is being selected due to flushing from vertices regardless of selection mode. It's just that the second example shows more clearly why this is a problem.
Philipp Oeser removed the
Interest
Modeling
label 2023-02-09 15:28:52 +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
5 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#83181
No description provided.