Page MenuHome

Bmesh: New utility `BM_vert_splice_collapse`
Needs RevisionPublic

Authored by Germano Cavalcante (mano-wii) on Tue, Sep 3, 1:57 AM.



Currently for merging vertices, the BM_vert_splice and` BM_edge_collapse` functions are used.
However, these functions do not deal with duplicate faces and do not work to collapse faces in the middle (creating two faces) or to join vertices of different faces.

The weld_verts operator solves this problem by checking all faces that share a pair of vertices and split them.
It also creates edges for cases where different face vertices are used.

The new function BM_vert_splice_collapse solves all these different cases efficiently.

To test it the weld_verts operator has been redone.
Here are the results for the performance test on a Suzanne subdivided 2x:
(t1: original weld_verts | t2: new weld_verts)

Merge all suzanne verts with loose verts:
t1: 0.001805; t2: 0.000304; fac: 5.9375

Duplicate and merge all suzanne verts:
t1: 0.008582; t2: 0.005968; fac: 1.438002

Merge single suzanne vert:
t1: 0.001548; t2: 0.000007; fac: 176,571428

Move out suzanne:
t1: 0.001236; t2: 0.000004; fac: 325.213034

Diff Detail

rB Blender
arcpatch-D5663 (branched from master)
Build Status
Buildable 4748
Build 4748: arc lint + arc unit

Event Timeline

Germano Cavalcante (mano-wii) planned changes to this revision.

I found a mistake.

  • Fix crash by merging a single vertex
Germano Cavalcante (mano-wii) planned changes to this revision.Tue, Sep 3, 5:02 AM

I found a problem in the double faces detection

  • Quiet warnings, minor edits

While BM_vert_splice_collapse looks like a useful function, the internal logic seems a bit fragile and should be stress tested to check it's not corrupting the meshes.

Testing with this blend file crashes at the moment:

Once this is fixed it would still be good to make further tests to ensure it's working correctly.

  • Fix all bugs, crashes and conflicts.

The changes weld_verts operator are here justo for testing.
It's hard to understand what it really proposes to do with creating new faces and edges and changing the selecting history.

The patch where it will be used is the D5635

This patch still gives corrupt mesh data at times.

Attached an example.

  • In the attached file press Shift-D, Enter.
  • Do this a second time, Blender crashed.
BLI_assert failed: source/blender/editors/mesh/editmesh_automerge.c:340, EDBM_automerge_and_split(), at '_bm_elem_flag_test(&(v)->head, BM_ELEM_TAG)'

Another issue, after the first step, exit edit-mode and run: which prints many errors:

ERROR (bke.mesh): source/blender/blenkernel/intern/mesh_validate.c:690 BKE_mesh_validate_arrays:      Polys 7 and 9 use same 
ERROR (bke.mesh): source/blender/blenkernel/intern/mesh_validate.c:733 BKE_mesh_validate_arrays:      Loop 73 is unused.
Campbell Barton (campbellbarton) requested changes to this revision.Wed, Sep 4, 9:16 AM
This revision now requires changes to proceed.Wed, Sep 4, 9:16 AM