1
$\begingroup$

Using this node setup: find out if vertices are inside or outside of another mesh, using geometry nodes

I want to delete all points of a 3D grid (Size of the bounding box) that are outside the mesh.

In this particular case (Suzanne rotated x -20° & y 30° and applied rotation), there's some points on a line that are not properly detected.

enter image description here

Here's the nodetree: enter image description here

The issue has to do with the raycast node since the lines have the same direction as the direction vector. (Using a different direction vector fixes the issue same as having a different rotation of the object)

Why does this artifact occur and how can it be avoided? Is there a different approach for detecting if a point is inside a mesh?

$\endgroup$
1
  • 1
    $\begingroup$ Default Suzanne is not a manifold mesh. Detection of inside/outside doesn't make a lot of sense for her. $\endgroup$
    – Nathan
    Commented Mar 23 at 15:19

1 Answer 1

1
$\begingroup$

(Using Blender 3.6.8)

The artefact comes from some outside points such that the associated ray is tangent to the surface and it is hitting an edge of the target geometry. If the normals to each face sharing this edge are very different, picking one face can triggered the test deleting outside nodes, but not the other one. So which face is picked first by the Raycast node is very sensitive. And the whole process is sensitive to numerical accuracy.
To illustrate that, the following case is using a cube of size 1 instead of Suzanne mesh. The two bottom points should have been deleted. The blue vector is the ray direction. If the bottom face with green normal had been hit, the dot product had been negative and the points deleted. But the right face is hit and the dot product is equal to 1 ( as (1,1,1).dot.(1,0,0)). As a consequence, the points are not deleted.
To improve the robustness of the process, it is mandatory to do at least two different tests, by slightly shifting the points position or by changing the ray direction. Points positive to at least one of those tests should be deleted. Inside points should be negative to both tests.

Picture showing normals and hit point

$\endgroup$

You must log in to answer this question.

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