Dissolve can create duplicate faces / invalid geometry (leading to crashes on further modeling operators such as Subdivide Edges) #70977

Open
opened 2019-10-21 01:07:59 +02:00 by Stanislav Blinov · 18 comments

System Information
Operating system:
Graphics card:

Blender Version
Broken: 2.81 R970d7ed all the way back to 2.70a
Worked: likely never

Short description of error
Using the dissolve tool it's possible to create faces sharing the same boundary edges.

Exact steps for others to reproduce the error (using Dissolve Faces):
Based on the default startup .blend file,

  1. Enter Edit Mode with Tab and select a face.
  2. Invert selection Ctrl-I and dissolve the selected faces to leave just one square in the 3d viewport
  3. Use the Edge -> Subdivide operator in Edit Mode
  4. In the Adjust Last Operator panel try to increase the value of the Number of Cuts field by pressing the right arrow
  5. The program crashes immediately.

See also #120143 for a example of .blend file that crashes

Exact steps for others to reproduce the error (using Dissolve Vertices):

  1. In the default scene, edit the cube.
  2. In vertex selection mode, select one face (4 vertices).
  3. Still in vertex mode, dissolve using {key Ctrl X}.

You should be left with a "plane" that has 4 vertices, 4 edges, and 2 faces. None of the options for the Dissolve Selection (the ctrl+x) tool seem to help against it. I don't think that any of the built-in clean up helpers can detect these either, at least directly. Select Non-Manifold can be of some small help, if there's some adjacent geometry, but if there isn't (as in this example), it won't select anything.

Exact steps for others to reproduce the error (using Limited Dissolve):

  1. Create a plane and go into Edit Mode
  2. Select a triangular part by selecting 3 vertices and pressing F
  3. Select the opposite triangle part by selecting another 3 vertices on the opposite side
  4. Press A and X > Limited Dissolve
  5. Notice that you have 2 faces now.
  6. Repeat this procedure and you can have as many faces as you like all sharing exactly the same 4 vertices

image.png

infinite.gif

Then try to dissolve one vertex with X > Dissolve Vertex. One face gets deleted.

**System Information** Operating system: Graphics card: **Blender Version** Broken: 2.81 R970d7ed all the way back to 2.70a Worked: likely never **Short description of error** Using the dissolve tool it's possible to create faces sharing the same boundary edges. **Exact steps for others to reproduce the error (using __Dissolve Faces__):** Based on the default startup .blend file, 1. Enter Edit Mode with Tab and select a face. 2. Invert selection Ctrl-I and dissolve the selected faces to leave just one square in the 3d viewport 3. Use the Edge -> Subdivide operator in Edit Mode 4. In the Adjust Last Operator panel try to increase the value of the Number of Cuts field by pressing the right arrow 5. The program crashes immediately. See also #120143 for a example of .blend file that crashes **Exact steps for others to reproduce the error (using *Dissolve Vertices*):** 1. In the default scene, edit the cube. 2. In **vertex** selection mode, select one face (4 vertices). 3. Still in vertex mode, dissolve using {key Ctrl X}. You should be left with a "plane" that has 4 vertices, 4 edges, and **2** faces. None of the options for the Dissolve Selection (the ctrl+x) tool seem to help against it. I don't think that any of the built-in clean up helpers can detect these either, at least directly. Select Non-Manifold can be of some small help, if there's some adjacent geometry, but if there isn't (as in this example), it won't select anything. **Exact steps for others to reproduce the error (using *Limited Dissolve*):** 1. Create a plane and go into Edit Mode 2. Select a triangular part by selecting 3 vertices and pressing `F` 3. Select the opposite triangle part by selecting another 3 vertices on the opposite side 4. Press `A` and `X` *> Limited Dissolve* 5. Notice that you have 2 faces now. 6. Repeat this procedure and you can have as many faces as you like all sharing exactly the same 4 vertices ![image.png](https://archive.blender.org/developer/F14096169/image.png) ![infinite.gif](https://archive.blender.org/developer/F14096171/infinite.gif) Then try to dissolve one vertex with `X` *> Dissolve Vertex*. One face gets deleted.

Added subscriber: @Stan_Pancakes

Added subscriber: @Stan_Pancakes

#103482 was marked as duplicate of this issue

#103482 was marked as duplicate of this issue

Sorry, the commit hash isn't meant to imply that commit broke the tool (i.e. the 'mention'). It's simply the hash of the beta build used.

Sorry, the commit hash isn't meant to imply that commit broke the tool (i.e. the 'mention'). It's simply the hash of the beta build used.

Added subscriber: @RodDavis

Added subscriber: @RodDavis

More info is needed.
image.png

Click "Report a bug" from blender. A template will be autofilled with the Operating System, Graphics card, and Broken build. Copy this info and paste it in this bug report.

More info is needed. ![image.png](https://archive.blender.org/developer/F7843184/image.png) Click "Report a bug" from blender. A template will be autofilled with the **Operating System**, **Graphics card**, and **Broken build**. Copy this info and paste it in this bug report.

@RodDavis, unless you mean to tell me that on your system and graphics card (which are irrelevant in this case) you're not able to reproduce the issue, the report shall stay as is, thank you very much.

@RodDavis, unless you mean to tell me that on your system and graphics card (which are irrelevant in this case) you're not able to reproduce the issue, the report shall stay as is, thank you very much.
Member

Added subscribers: @mont29, @ideasman42, @lichtwerk

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

Can confirm.

Not quite sure if this would be considered a bug [I guess so though], confirming for now.
Note you can always run ob.data.validate() [this will correct those kind of issues]

There is code detecting this in the corresponding part of BKE_mesh_validate_arrays (BM_mesh_validate doesnt catch this), but not sure if this is really desired? (could be slow?) Are there alternatives? implement something like IS_FACE_FACE_DUPE in bmesh_elem_check?

CC @ideasman42
CC @mont29

Can confirm. Not quite sure if this would be considered a bug [I guess so though], confirming for now. Note you can always run `ob.data.validate()` [this will correct those kind of issues] There is code detecting this in the corresponding part of `BKE_mesh_validate_arrays` (`BM_mesh_validate` doesnt catch this), but not sure if this is really desired? (could be slow?) Are there alternatives? implement something like `IS_FACE_FACE_DUPE` in `bmesh_elem_check`? CC @ideasman42 CC @mont29

AFAIK, it has been like that since... pretty much since dissolve existed, I guess. So it could be dubbed a historical notabug :) Joking aside though, this kind of geometry is rather nasty, so if user-facing tools can be made to avoid creating it, IMHO it should be done.

AFAIK, it has been like that since... pretty much since dissolve existed, I guess. So it could be dubbed a historical notabug :) Joking aside though, this kind of geometry is rather nasty, so if user-facing tools can be made to avoid creating it, IMHO it should be done.
Sybren A. Stüvel changed title from Dissolve can create lamina faces to Dissolve can create duplicate faces 2020-01-23 15:27:58 +01:00

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Updated the task description to simplify it a bit. The issue is still the same, though.

bpy.object.data.validate() indeed fixes the issue, but IMO such a step should be done after the dissolve operator has run.

I tested with Blender 2.65a and there it produces completely wrong geometry. 2.70a already had this duplicate face bug.

I've marked this as a known issue as it's been in Blender for so long, there is a workaround (albeit a oneliner of code), and I don't know when this will be fixed.

Updated the task description to simplify it a bit. The issue is still the same, though. `bpy.object.data.validate()` indeed fixes the issue, but IMO such a step should be done after the dissolve operator has run. I tested with Blender 2.65a and there it produces completely wrong geometry. 2.70a already had this duplicate face bug. I've marked this as a known issue as it's been in Blender for so long, there is a workaround (albeit a oneliner of code), and I don't know when this will be fixed.

Fair enough, I've edited as well to make repro even simpler.

Fair enough, I've edited as well to make repro even simpler.

Added subscribers: @Harry-Kunz, @mano-wii

Added subscribers: @Harry-Kunz, @mano-wii

Added subscriber: @vasiln

Added subscriber: @vasiln

I would like to make the case that this is not a bug. This is important not just for this particular issue, but as part of a wider philosophy. I am coming here from a discussion at https://blender.stackexchange.com/questions/282322/is-having-2-or-more-faces-with-all-shared-vertices-a-bug-or-valid-geometry/282325#282325 , and I'll try and offer a synopsis of my arguments there.

Blender regularly allows users to make "bad" meshes. If the user has a problem with bad meshes, then the solution is for the user to not make bad meshes.

It is expected and unavoidable that 3D tools work in an expected context and have unusual behavior outside those contexts. Automatic weights don't work well on meshes with holes; unwrapping can't figure out how to handle 3 faces connected by a single edge. That's okay.

Additionally, what makes a mesh "bad" is dependent on the context of how that mesh is going to be used. Is that 3-face, 1-edge mesh "bad"? It's not good for a lot of purposes, but it interacts differently with a smooth modifier, and it can be followed up with a mask modifier to make it "good" again. Non-manifold geometry is often "bad" for rendering but useful for other purposes, and I give the examples of physics meshes where I regularly use non-manifold geometry to create the forces that I want.

I do not use doubled faces; the behaviors I mentioned above can be done with loose edges rather than any faces. But there are conceivable situations where a user would need doubled faces to get some technique. After all, they can't have face or corner attributes for use in GN without having faces. They can then "fix" their geometry by deleting the bad stuff when they're done with what they needed those attributes for.

Again, the solution to bad geometry is for the user to not make bad geometry if they don't want it, not to take away the users' power to make it when they want it.

In some cases, we can find that a tool can be improved to work in contexts broader than it was originally intended for. For example, a merge by distance could be made to be more aware of the potential for non-manifold geo and doubled faces. In these cases, it's appropriate to adjust the specific tool (also, appropriate to say, "Then don't use it that way.") But it's part of life that Blender's operations act on expectations, and when they behave strangely in unanticipated contexts, it is not the context that is the bug.

I would like to make the case that this is *not* a bug. This is important not just for this particular issue, but as part of a wider philosophy. I am coming here from a discussion at https://blender.stackexchange.com/questions/282322/is-having-2-or-more-faces-with-all-shared-vertices-a-bug-or-valid-geometry/282325#282325 , and I'll try and offer a synopsis of my arguments there. Blender regularly allows users to make "bad" meshes. If the user has a problem with bad meshes, then the solution is for the user to not make bad meshes. It is expected and unavoidable that 3D tools work in an expected context and have unusual behavior outside those contexts. Automatic weights don't work well on meshes with holes; unwrapping can't figure out how to handle 3 faces connected by a single edge. That's okay. Additionally, what makes a mesh "bad" is dependent on the context of how that mesh is going to be used. Is that 3-face, 1-edge mesh "bad"? It's not good for a lot of purposes, but it interacts differently with a smooth modifier, and it can be followed up with a mask modifier to make it "good" again. Non-manifold geometry is often "bad" for rendering but useful for other purposes, and I give the examples of physics meshes where I regularly use non-manifold geometry to create the forces that I want. I do not use doubled faces; the behaviors I mentioned above can be done with loose edges rather than any faces. But there are conceivable situations where a user *would* need doubled faces to get some technique. After all, they can't have face or corner attributes for use in GN without having faces. They can then "fix" their geometry by deleting the bad stuff when they're done with what they needed those attributes for. Again, the solution to bad geometry is for the user to not make bad geometry if they don't want it, not to take away the users' power to make it when they want it. In some cases, we can find that a tool can be improved to work in contexts broader than it was originally intended for. For example, a merge by distance could be made to be more aware of the potential for non-manifold geo and doubled faces. In these cases, it's appropriate to adjust the specific tool (also, appropriate to say, "Then don't use it that way.") But it's part of life that Blender's operations act on expectations, and when they behave strangely in unanticipated contexts, it is not the context that is the bug.

the solution to bad geometry is for the user to not make bad geometry if they don't want it > This is an assumption that this type of doubled-face geometry only happens when the user chooses to create it. Unfortunately that is not always the case. This type of bad geometry is not always intentionally created. There is a discussion for example in this thread where the users were confused on what was going on and how they could fix their dilemma. I am sure there are many more of these confusing cases. Fortunately there is a workaround for m in D.meshes: m.validate() but you need to know about it first and it isn't exactly easy to discover the solution. Also if you dissolve just 1 vertex, all the faces merge into 1 face which meant that Blender detected this as bad geometry and fixed it. If the double-faced geometry was desired then Blender should not have merged these faces.

*the solution to bad geometry is for the user to not make bad geometry if they don't want it* > This is an assumption that this type of doubled-face geometry only happens when the user chooses to create it. Unfortunately that is not always the case. This type of bad geometry is not always intentionally created. There is a discussion for example in [this thread](https://blender.stackexchange.com/questions/183795/two-faces-inside-of-each-other-sharing-same-4-vertices-why-and-how-to-fix) where the users were confused on what was going on and how they could fix their dilemma. I am sure there are many more of these confusing cases. Fortunately there is a workaround `for m in D.meshes: m.validate()` but you need to know about it first and it isn't exactly easy to discover the solution. Also if you dissolve just 1 vertex, all the faces merge into 1 face which meant that Blender detected this as bad geometry and fixed it. If the double-faced geometry was desired then Blender should not have merged these faces.
Philipp Oeser removed the
Interest
Modeling
label 2023-02-09 15:29:34 +01:00
Member

I would also vote for blenders tools/operators to not result in something that mesh.validate() would deny as valid.

Also: this kind of geometry can easily lead to crashes afterwards, as reported in #116217

I would also vote for blenders tools/operators to not result in something that `mesh.validate()` would deny as valid. Also: this kind of geometry can easily lead to crashes afterwards, as reported in #116217
Philipp Oeser changed title from Dissolve can create duplicate faces to Dissolve can create duplicate faces / invalid geometry (leading to crashes on further modeling operators such as Subdivide Edges) 2023-12-15 13:05:10 +01:00
Campbell Barton self-assigned this 2023-12-15 13:14:36 +01:00

I have a model with duplicate edges. 2 vertices shared by 2 edges. So this is apparently also possible with edges, not just faces. I have attached a blend version 4.0 file where you can reproduce it. Just select the object and run the script in the blend file. You will see an orange line appear in object mode. Go into edit mode and delete all the other edges one by one until you are left with the last doubled edge sharing same 2 vertices.

import bpy

def auto_merge_vertices(obj):
    s = bpy.context.scene.tool_settings
    s.use_mesh_automerge = True
    s.use_mesh_automerge_and_split = True
    ops = bpy.ops
    ops.object.mode_set(mode='EDIT')
    ops.mesh.select_all(action='SELECT')
    ops.transform.translate(value=(0, 0, 0))
    ops.mesh.remove_doubles()
    ops.object.mode_set(mode='OBJECT')
    
auto_merge_vertices(bpy.context.object)
I have a model with duplicate edges. 2 vertices shared by 2 edges. So this is apparently also possible with edges, not just faces. I have attached a blend version 4.0 file where you can reproduce it. Just select the object and run the script in the blend file. You will see an orange line appear in object mode. Go into edit mode and delete all the other edges one by one until you are left with the last doubled edge sharing same 2 vertices. ``` import bpy def auto_merge_vertices(obj): s = bpy.context.scene.tool_settings s.use_mesh_automerge = True s.use_mesh_automerge_and_split = True ops = bpy.ops ops.object.mode_set(mode='EDIT') ops.mesh.select_all(action='SELECT') ops.transform.translate(value=(0, 0, 0)) ops.mesh.remove_doubles() ops.object.mode_set(mode='OBJECT') auto_merge_vertices(bpy.context.object) ```
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
8 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#70977
No description provided.