1
$\begingroup$

How can I select only the vertices that are the result of the Merge by Distance node?

Merge by Distance node is handy, but it doesn't have "Resulted Merged Points" or similar output socket sadly :(

I have created a RightClickSelect entry about it:
https://blender.community/c/rightclickselect/pRom/

Related:
Geometry Nodes: Delete Overlapping Vertices

$\endgroup$
7
  • $\begingroup$ tbh i don't think you can solve that via GN, except you have "insider" information how the merge by distance node works. As workaround you could write your "own" custom merge by distance with the node tree of Markus in the last question. Then you have control and know which points are merged and where. $\endgroup$
    – Chris
    Commented Jul 3 at 18:03
  • $\begingroup$ One way to work around this is simply find vertices that are not equal to the ones in the before geometry, but I’m not sure how to do that. $\endgroup$
    – TheLabCat
    Commented Jul 3 at 18:03
  • $\begingroup$ @TheLabCat: that won't work because the indices aren't the same after merge by distance and the positions change as well. so with what do you wanna compare the "before" and "after"? and it get's even worse if multiple vertices have the same position $\endgroup$
    – Chris
    Commented Jul 3 at 18:04
  • 1
    $\begingroup$ @TheLabCat: no problem, but maybe some genius have an idea - but i think it isn't possible (which is also a guess) $\endgroup$
    – Chris
    Commented Jul 3 at 18:05
  • 1
    $\begingroup$ I suspect that the solution could lie in the fact that the attributes are also interpolated when merging. For example, if one attribute (of a point/face/corner) has the value 1.0 and another has the value 2.0 ...what value does the merged attributes have at the end and how can this result be used? ...just a thought. $\endgroup$
    – quellenform
    Commented Jul 3 at 19:17

2 Answers 2

4
$\begingroup$

Well, maybe the solution is that instead of concentrating on the points, you take a closer look at the edges.

The problem with merging points is that their indices and positions change. Unfortunately, without a high error rate, you cannot simply compare the new mesh with the old one and find the differences.

However, what reliably does not change when merging are the indices of the edges.

Edges are either removed/replaced - for example, if both points of an edge are merged - or their length is simply changed.

And this is exactly where the following solution comes in:

Select merged vertices

  1. first I capture the indices of the edges.
  2. then I merge the vertices.
  3. then I compare the length of the resulting edges with those of the original mesh.

As a result, you get those edges as selections that are no longer present in the old mesh with the new length and interpolate these as float values into the point domain.

...However, there are pitfalls with this approach and, depending on the nature of the geometry, it can happen that the length of an edge after merging the vertices matches the length of another edge that then has the same index. This is particularly problematic with objects such as a cylinder, for example, where there are many edges that have the same length.


I have therefore refined this approach in a further step and included the index of the edge as a criterion for the comparison.

The rule is:

  • If points are merged, their edges remain with the original indices.
  • If adjacent points of a merged point are also merged, the edge between them is completely removed.
  • Depending on the nature of the geometry, new edges with new indices are also added if several adjacent points are merged.

The trick now is to set the original index of the edge in relation to the original length.

And here, funnily enough, the Random Value node helps. The random value generated by this node can be stabilized by adding an integer value to the input ID. And what would be more suitable here than the original index of the edge itself?

Because if this index or the length changes, one of the vertices connected to the edge must have been merged, as the generated value has changed.
However, if neither of these two values changes, Random Value always generates the same "random" value.

And it is precisely this value that I am comparing here before and after merging:

Select merged vertices v2

If I am not completely wrong about this idea, this should be the final solution.
...Without any Repeat Zone, complicated nesting or additional geometry.

$\endgroup$
15
  • $\begingroup$ I don't understand this algorithm. Let's test for a mesh line of 2 vertices 1 m apart, and merging them: i.imgur.com/1KR1bI6.png So it reports they're not merged even though they are, or am I misreading something? Not sure if I should copy-paste my answer here... $\endgroup$ Commented Jul 4 at 11:51
  • $\begingroup$ @MarkusvonBroady As far as I know, as soon as you merge a single line with two points to one single point, all lines/edges in between are removed. Therefore, this mechanism will not work in this case. Or have I misunderstood your question? $\endgroup$
    – quellenform
    Commented Jul 4 at 12:45
  • $\begingroup$ Could you describe what are the limitations of this algorithm? After merging there has to be at least one edge left on the merged vertex in order for it to detect that it has been merged? $\endgroup$ Commented Jul 4 at 12:48
  • $\begingroup$ @MarkusvonBroady Well, now that I've taken a closer look at it myself, I have to admit that there are a few general problems in some cases. ...need to be examined more closely. Funnily enough, it seems to have helped the questioner and it also seems to work for my test. ...hm $\endgroup$
    – quellenform
    Commented Jul 4 at 12:52
  • $\begingroup$ If you're using a heuristic, why not just check geometry proximity to the previous version? Will that be less reliable? $\endgroup$ Commented Jul 4 at 13:13
2
$\begingroup$

This solution is 100% reliable*, no "random" nodes.

It's pretty much the same as in my answer here:

Geometry Nodes: Delete Overlapping Vertices

Just check if the reported number is greater than $1$:

*conceptually, because bugs can exist. I think the algorithm is described in the linked answer in a way that makes sense and gives confidence it's correct, but you know what they say: confidence is a slow and insidious killer...

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .