Page MenuHome

Fix T94144: Duplicate edges in dual mesh node
ClosedPublic

Authored by Wannes Malfait (Wannes) on Dec 1 2021, 11:23 PM.

Details

Summary

The duplicated edges were caused by 'oversubdivided' edges, i.e. edges
where some of the vertices on them are only connected to two polygons.
For most 'normal' meshes this shouldn't occurr, or only very little, so
the performance impact of this change should be neglegible. In practice
this is also avoidable by triangulating the mesh first.

The fix finds these vertices and 'dissolves' them so that only one edge
is created.

Blend file with bad mesh (tested with BKE_mesh_is_valid):


Diff Detail

Repository
rB Blender
Branch
dual_mesh_2poly_verts (branched from master)
Build Status
Buildable 19137
Build 19137: arc lint + arc unit

Event Timeline

Wannes Malfait (Wannes) requested review of this revision.Dec 1 2021, 11:23 PM
Wannes Malfait (Wannes) created this revision.
source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
635

The comment should mention that the mesh is not dissolved in the input mesh, but only in the data structures you derived from it.

636

This entire loop should be moved to a separate function. It shouldn't clutter this "main" function because it rarely has an impact on the result.

644

It seems like it dissolves an edge, but that edge might not actually include vert_i, maybe I'm missing something.

652

Is there some guarantee above the order of indices in vertex_poly_indices? Would be good to add comments to vertex_poly_indices similar variables.

Wannes Malfait (Wannes) marked 4 inline comments as done.
  • Split code into new function and clean up comments
Hans Goudey (HooglyBoogly) requested changes to this revision.Dec 15 2021, 9:23 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
540

derived datastructures from the mesh -> data structures derived from the mesh

543

Sometimes when there's a rather confusing situation like this, I create a bug report with some images if there isn't one already, then you can write something like (see TXXXX) here

565–566

+1 for the comment. I'd rather see something more specific than "the way this is created". What about the way it's created?

568–581

These checks could be moved to a separate function to avoid the duplication (only v1 vs v2 is different between them. And maybe the function name could give some hint about the meaning of the check

572

Setting the type to "Loose" is a way to make it ignored later on, right? Do you think it would make more sense to have a separate Ignored type? I'm not sure myself.

585–586

I don't really understand how putting poly indices in the vert fields of MEdge makes sense. Is there something I'm missing?

This revision now requires changes to proceed.Dec 15 2021, 9:23 PM
Wannes Malfait (Wannes) marked 6 inline comments as done.
  • Split code into new function and clean up comments
  • Cleanup: comments and move check to separate function
Wannes Malfait (Wannes) retitled this revision from Fix duplicate edges in dual mesh node to Fix T94144: Duplicate edges in dual mesh node.
Wannes Malfait (Wannes) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
572

I think setting it to 'loose' is fine, as it corresponds to what happens. I think of it like the when you hold 'alt' in the node editor to 'detach' a node from a link. In the same way the vertex gets detached in this case from the edge (not actually but that's how it's treated afterwards), and is therefore 'loose'.

585–586

Polygon indices in the input mesh become vertex indices in the dual mesh. I also added a comment to clarify this.

The code looks good to me now. Thanks!

This revision is now accepted and ready to land.Dec 16 2021, 4:34 PM