'Calculate points inside the mesh of other instances with Geometry Nodes

I'm working on a procedural terrain generator using Geometry Nodes and I want to include the option of having buildings or other objects placed inside a collection that the terrain uses as a reference for where not to put grass, pebbles and rocks. The issue I have is that I've been only able to do it with the faces of the objects in the collection, and when they are big enough, that causes the points to be distributed inside the object. Here's a capture: 1

I've scoured the internet for help, but since the change in the geometry nodes on 3.0, most of the answers I can find use the old system and I can't find a way to adapt it, so I'm asking for help here, because I ran out of ideas. Here's the current set up I have to make the selection to know where not to put points for the grass: 2

I did try using the Mesh Boolean approach, but it is too resource heavy. For the buildings is not a problem, but when I use it for avoiding grass from spawning inside the big rocks, it makes the entire geometry nodes really heave resources wise.

Any Help is appreciated, I've been fighting this "bug" for three days now and it's driving me crazy. Thanks!



Solution 1:[1]

After many searches, I've managed to find a solution that works! It is using the method explained in this tutorial: https://www.youtube.com/watch?v=tvb2aCeTANM

Basically, you create a raycast on top of the scene and use a Boolean Math node to detect if it's hitting or not. In my case, for deleting the Geometry in the mesh where the points are distributed, I used a "Or" operation. You can see the node setup here: New Node Setup

Hope this helps anyone else having the same problem :). Of course if anyone can think of a better solution, feel free to add it!

Solution 2:[2]

Just use Raycast node with position node to evaluate a dot product and then add map range with clamp checkbox enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Casandra Toledo
Solution 2 Alexander Bicukow