4
$\begingroup$

I have the following mesh:

A bunch vertices connected by edges. The shape is composed of straight lines that go up, down, left, right, backwards and forwards, but never at an angle

And I'm instancing cubes on every vertex like this:

The same shape, with a cube at every vertex

Consider that each vertex can only connect to 6 edges (up, down, left, right, forward, backwards), is there a way to delete the faces that intersect the original edges?

What I have attempted:

  • In all attempts I tried using the Edge Vertices node, by subtracting position 1 from position 2 to get the edge direction.
  • I tried to use this edge direction to compare with the dot product of the face normal, but that didn't work correctly (some faces disappear, but not the ones I want)
  • I also tried to use the edge direction to raycast from the center of the cube instances, but that didn't work either (same as above)

This was my latest attempt:

geometry nodes graph geometry nodes graph

$\endgroup$
1
  • 1
    $\begingroup$ Always axis-aligned cubes and edges? $\endgroup$ Commented Nov 30 at 11:13

1 Answer 1

5
$\begingroup$

Since in your setup edges go exactly through face centers, you can just delete faces that have zero (near-zero, worrying about some float precision error) distance to the nearest edge:

Imgur mirror (SE image hosting has problems)

Imgur mirror

Explanation

"Geometry Proximity" by default uses "Position" of the evaluated element. So when evaluating in the context of a face, the face's position is used. Face position is simply the average position of all of its vertices. For a square, that's pretty much the center of it, regardless of how you define "center". Now because your edges are all axis-aligned, and your cubes are axis-aligned, whenever an edge intersects a face, it always intersects it at its exact center. So each intersected face will find an edge on the very spot it starts to search, its center. However non-intersected face will find an edge somewhere further away, and when that is the case, the algorithm doesn't delete such a face.

$\endgroup$
4
  • $\begingroup$ Could you add an explanation on how your setup works? It's not clear to me how exactly you managed to compare the edges and the faces when they are created in different node paths. Is it the join geometry? And if so, wouldn't this setup also compare the distance between the face and the cube's own edges? $\endgroup$
    – Luke B.
    Commented Nov 30 at 19:54
  • $\begingroup$ I'll mark your answer as accepted because it does answer the question I asked, but is there a solution that would work for a more complicated "cube"? one with subdivisions or details on the mesh? $\endgroup$
    – Luke B.
    Commented Nov 30 at 19:56
  • 1
    $\begingroup$ @LukeB. it depends on what is the intended behavior. If the cube is more complicated, but it still is 6 axis-aligned sections, that should be deleted in their entirety, you can use simple cubes for the checks and remap the change from them onto more complex geometry. If you want to remove just small intersected faces, then you would need to change the algorithm to use raycasting. $\endgroup$ Commented Nov 30 at 20:14
  • $\begingroup$ I understand, thanks!! $\endgroup$
    – Luke B.
    Commented Nov 30 at 21:05

You must log in to answer this question.

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