bmesh.ops.find_doubles
with keep_verts
doesn't work correctly #120750
Labels
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120750
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Blender Version
Broken: 4.1
Short description of error
I found this while investigating another issue I had with
keep_verts
(haven't been able to reproduce that one yet)(I confirmed that it also gets caused by this bug).When using
bmesh.ops.find_doubles(...)
with thekeep_verts
argument, together withbmesh.ops.weld_verts(...)
, one extra vertex (not present inkeep_verts
) gets kept.Exact steps for others to reproduce the error
Run this script in object mode:
You can try with different primitives by commenting the ops calls in/out.
For the Suzanne it always keeps vert 250 and for the Torus 358 (to check this, simply create another primitive of the same type, go into edit mode with Indices enabled and also enable wireframe rendering).
`bmesh.ops.find_doubles` with `keep_verts` keeps extra vertsto `bmesh.ops.find_doubles` with `keep_verts` doesn't work correctlyOkay I found out what the bug is here.
The current behavior is:
Do
find_doubles
and just keep all the vertices inkeep_verts
. (Yes, this generally sounds correct, but it isn't).While the advertised behavior from the docs is:
So any merging should only target vertices from keep_verts. While you could of course simply change the docs now, to reflect the current behavior, I'd strongly advise against that, because this behavior is actually useful (while the current one is not).
This matches up with my test script aswell. The extra vertex that gets kept simply is the vertex all other vertices get merged into. Nothing actually gets merged into the defined
keep_verts
, they just don't get merged, thus they stay.I edited the script to be easier to investigate.
In fact, the vertices set in "keep_verts" do not become targets, they can become targets, but they do not appear as source in the resulting "targetmap".
Therefore the documentation is wrong.
Even though it doesn't seem like a useful parameter, changing the behavior could break compatibility with addons. So it might not be the best approach.
Cc. @ideasman42
Ref. https://docs.blender.org/api/current/bmesh.ops.html#bmesh.ops.find_doubles
Well guess why I'm here ... because my addon is broken ^^
This was how I was handling things before, I'm basically manually doing what
find_doubles
withkeep_verts
is supposed to do there.This is much slower obviously and simply unnecessary.
As said previously, I'd strongly advise against simply changing the docs. There's probably like a dozen addons which actually use this functionality and I somewhat doubt any of them actually expect/know the how it currently behaves. I really can't think of a single valid usecase for the current behavior.
My addon pretty much breaks every second release and I simply take a look at the patch notes and change things accordingly. Fixing this and adding a simple note that this function now finally works as it's supposed to be would be sufficient.
Tracked down the commit where this got broken too:
4d148471b6
Seems like it was meant to fix a performance issue, but completely broke the implementation while doing so sadly. From what I can tell though, the correct behavior is probably not that easy to implement with the KDTrees? Not sure.
It would add quite a lot of code, but maybe the function should just fallback to the old implementation (or something similar) if
keep_verts
are provided.CC @ideasman42 ^^