Fix #116183: Mirror sometimes chooses the wrong vertex #116202

Open
Germano Cavalcante wants to merge 1 commits from mano-wii/blender:fix_116183 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

The non-topology option of EDBM_verts_mirror_cache_begin_ex only uses
the vertices position to determine whether it is a mirror. However,
some vertices may have the same position. In these cases, another value
can be used to compare.

This commit proposes using the normal and connected edges of a vertex
to determine the best vertex in a group of vertices with the same
position.


Issue

Test file: bugReport.blend

The non-topology option of `EDBM_verts_mirror_cache_begin_ex` only uses the vertices position to determine whether it is a mirror. However, some vertices may have the same position. In these cases, another value can be used to compare. This commit proposes using the normal and connected edges of a vertex to determine the best vertex in a group of vertices with the same position. --- ## Issue <video src="/attachments/6206bf21-8f43-4e0e-9a0d-d806ab915879" controls></video> Test file: [bugReport.blend](attachments/0f74ce9c-28f1-4e6b-83ed-e8e57da6f405)
Germano Cavalcante added the
Module
Modeling
label 2023-12-14 19:08:20 +01:00
Germano Cavalcante added 1 commit 2023-12-14 19:08:27 +01:00
8d9f4e2b90 Fix #116183: Mirror sometimes chooses the wrong vertex
The non-topology option of `EDBM_verts_mirror_cache_begin_ex` only uses
the vertices position to determine whether it is a mirror. However,
some vertices may have the same position. In these cases, another value
can be used to compare.

This commit proposes using the normal and connected edges of a vertex
to determine the best vertex in a group of vertices with the same
position.
Germano Cavalcante requested review from Campbell Barton 2023-12-14 19:08:48 +01:00

This is interesting but I think it could be approached differently since this is adding involved logic to support a fairly uncommon use case. Currently mirror just doesn't support exactly overlapping vertices, so #116183 isn't a bug. I checked the user manual and this could be made more explicit.

There are some things to consider:

  • Even if this is supported in edit-mode, it wont be supported in weight-paint mirroring, so if we support this it should eventually be supported there too.

  • There would be rare cases where there are many vertices with the range, while unlikely it means each lookup could potentially allocate a large array, which is then inspected using expensive operations.

  • I'd expect the common case to be slower on high poly meshes because BLI_kdtree_3d_range_search is more expensive and allocates an array (even for a single item).


Having said all this - the functionality would be nice to support.

Suggestions:

2nd pass for un-assigned vertices

When some vertices don't have mirrored vertices (and aren't axis-aligned),
perform a second pass.

  • Loop over the vertices, checking for missing indices.
  • When found, perform a nearest lookup for vertices at this vertices location, filtering to include only vertices that have a mirrored location (API support would need to be added).
  • If found, a more expensive tests can be performed to check if this vertex is a better candidate (tests similar to the ones in this PR can work).

This method has the advantage that there is practically no overhead unless there are vertices without matches (only detecting when there are vertices that have no match).
Avoiding performance regressions for users with high-poly, symmetrical meshes.


Add dimensions to the KD-tree

A way to avoid gathering vertices within a range, then performing a search on those vertices could be to add additional dimensions to the KD tree: e.g. the normal / combined-edge-location could be added and the current logic of performing a nearest lookup can be kept.

The extra dimensions would need to be scaled down so the location would be dominant.

The advantage with this is it will have predictable performance & can be more easily implemented for Mesh data (not just BMesh).

A possible disadvantage is unwanted bias from the extra dimensions that could result in issues choosing between very near vertices, although this issue exists with any method that favors other attributes over nearest location.

It will also be slower, even in situations where it's not needed.

For this reason it could be optional, although I'm also not that keen on adding more options.

This is interesting but I think it could be approached differently since this is adding involved logic to support a fairly uncommon use case. Currently mirror just doesn't support exactly overlapping vertices, so #116183 isn't a bug. I checked the user manual and this could be made more explicit. There are some things to consider: - Even if this is supported in edit-mode, it wont be supported in weight-paint mirroring, so if we support this it should eventually be supported there too. - There would be rare cases where there are many vertices with the range, while unlikely it means each lookup could potentially allocate a large array, which is then inspected using expensive operations. - I'd expect the common case to be slower on high poly meshes because BLI_kdtree_3d_range_search is more expensive and allocates an array (even for a single item). ---- Having said all this - the functionality would be nice to support. **Suggestions:** ### 2nd pass for un-assigned vertices When some vertices don't have mirrored vertices (and aren't axis-aligned), perform a second pass. - Loop over the vertices, checking for missing indices. - When found, perform a nearest lookup for vertices at this vertices location, filtering to include only vertices that have a mirrored location (API support would need to be added). - If found, a more expensive tests can be performed to check if this vertex is a better candidate (tests similar to the ones in this PR can work). This method has the advantage that there is practically no overhead *unless* there are vertices without matches *(only detecting when there are vertices that have no match).* Avoiding performance regressions for users with high-poly, symmetrical meshes. ---- ### Add dimensions to the KD-tree A way to avoid gathering vertices within a range, then performing a search on those vertices could be to add additional dimensions to the KD tree: e.g. the normal / combined-edge-location could be added and the current logic of performing a nearest lookup can be kept. The extra dimensions would need to be scaled down so the location would be dominant. The advantage with this is it will have predictable performance & can be more easily implemented for Mesh data (not just BMesh). A possible disadvantage is unwanted bias from the extra dimensions that could result in issues choosing between very near vertices, although this issue exists with any method that favors other attributes over nearest location. It will also be slower, even in situations where it's not needed. For this reason it could be optional, although I'm also not that keen on adding more options.
Merge conflict checking is in progress. Try again in few moments.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fix_116183:mano-wii-fix_116183
git checkout mano-wii-fix_116183
Sign in to join this conversation.
No reviewers
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
2 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#116202
No description provided.