5
$\begingroup$

I have several mesh islands inside -1 to 1 on both X and Y axis. I want Geometry Nodes to detect any island that has at least one of its points falling out of this -1 to 1 on both axis, and if so delete that island. How can I go about accomplishing this?

$\endgroup$

3 Answers 3

6
$\begingroup$

First I plug a Position node into a Vector Math node set to Absolute, this way all position values will be positive, i.e. if you want to check if values are below -1 or above +1, you can use a Compare node set to Greater Than 1.

So after getting the absolute values I take a Separate XYZ node and compare the X and Y values if they are greater than 1, the result I combine with a Boolean Math node set to Or, so that the result is always true if any X or Y value is outside the -1 to 1 range.

This value I plug into an Accumulate Field node, plug Island Index from a Mesh Island node into the Group Index, and the Total output I use as Selection for a Delete Geometry node (which I have set to Face domain here, but it works with Point and Edge as well).

As Geometry I have an external object referenced by an Object Info node consisting of some meshes, where some are outside the -1 to 1 range.

nodetree

On the left is the original object, four mesh islands have corners outside the -1 to 1 range on X or Y which are marked in red. On the right is the result of the Geometry Nodes modifier. Of course this also works if the meshes are more complex or exceed the range on both axes.

before & after

$\endgroup$
3
  • 1
    $\begingroup$ Oh right, accumulate field... I think this is more performant than mine! $\endgroup$ Commented Jul 10 at 8:43
  • $\begingroup$ @MarkusvonBroady But just a little bit... $\endgroup$ Commented Jul 10 at 9:06
  • $\begingroup$ According to your test almost 10 times faster but according to Crantisz' test over 20 times faster $\endgroup$ Commented Jul 10 at 11:26
5
$\begingroup$

You can avoid a repeat zone which will be a life-saver if you have thousands or more of mesh islands, if you use the below trick: move each point satisfying a criterion for deletion to the coordinate equal to mesh island index, then for each vertex check by proximity if some vertex (at least one) of the same mesh island was moved:

$\endgroup$
12
  • $\begingroup$ Oh, although I made basically the same of course it is much simpler to check if something is outside the range with the Not Equal node and then set the according Epsilon value... how stupid of me :D $\endgroup$ Commented Jul 10 at 8:37
  • $\begingroup$ I personally like accumulate filed approach. Using island index as position looks a bit hacky for me. Plus proximity and set position look expensive from a computational point of view $\endgroup$
    – Crantisz
    Commented Jul 10 at 8:42
  • $\begingroup$ ...although the question asked explicitly for X and Y, which I assume means those are flat meshes where it would not matter if you check the Z value as well - but if there were meshes outside -1 and 1 on Z but those should not be deletedand only X and Y mattered, then you would have compare them separately and combine the results anyway, which would then not make much of a difference compared to my result. But still I annoyed that I did not think of "equal" and "epsilon" :D $\endgroup$ Commented Jul 10 at 8:43
  • $\begingroup$ @Crantisz Actually the timings don't say that Markus' setup is computational very expensive, in fact a lot less than yours... especially since yours does not even do what is asked for in the question...? It only checks for Z values lower than 0, while the question is about X and Y outside of -1 to 1. $\endgroup$ Commented Jul 10 at 9:17
  • $\begingroup$ I think conditions are a smaller part in the computational cost. There is only one way to check - testing $\endgroup$
    – Crantisz
    Commented Jul 10 at 9:19
2
$\begingroup$

Here is the example how to remove all islands that Z is less then 0:

enter image description here

Basically, it loops through all islands and collect it if minimum of Z positions is grater than 0.

$\endgroup$

You must log in to answer this question.

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