# Geometry Nodes: How to stop Instances from clipping through each other?

I'm working on creating a city with Geometry Nodes (Blender 3.5) and I want to distribute different sized houses along a curve, but I've noticed that the bigger houses get clipped through the other houses. My conclusion is: This happens because the distribution count is treated as if each instance is the same size. But that is not the case here.

So I was wondering if there is a way in Geometry Nodes to use the individual size of the instances to control the number of distributed instances. So, basically, if I make a building bigger, the number should decrease. But right now, no instance respects the space of the others, and I'm looking for solutions to change that.

If anyone has any ideas, let me know.

• The reason is that the instance on points node does not know the size of the instances or anything of that sort. The instance on points node does exactly what it's named. It takes a point and places an instance on that point. Here the issue is that your points are not spaced in a way that willl prevent the instances from clipping thorugh each other. Commented Aug 3, 2023 at 8:17
• Love the scene, BTW Commented Aug 3, 2023 at 20:11

As already correctly noted in The Kalaakaar's comment, the information about the dimensions of an object is unfortunately not available to you when instantiating it.

The solution would therefore be to obtain this information beforehand.

This is inconvenient and can only be achieved in a roundabout way, but you could solve it like this:

To get the information about the respective width of an object, I first instantiate all objects along a mesh line here (the distance between the points is irrelevant, but must not be $$0$$).

Then I create bounding boxes from these instances and scale them so that only one line remains (you have to choose the axis of scaling depending on the orientation of your objects). By realizing these bounding box instances, merging their points and converting them into a curve, I get for each object a curve whose length is exactly equal to the width of an object. So you have the required values and the first part is done.

Then you instantiate the final objects. But since you don't know at this point how many objects will fit along your curve, you have to go the other way around and specify a certain number of objects first. Also, you have to capture the index of the instance to be selected (I assume you want to do this randomly) in the point domain beforehand. With this index, you can now sample the previously captured dimensions after instantiation. In this case, it is simply the length of each spline.

Now you are faced with the task of placing these instances along the curve. To do this, you need the position and the rotation. Therefore you have to divide the curve into segments beforehand, so that you always get exactly the normal of a curve segment as rotation, and no interpolated values. In this example I achieve this with the trick Curve to Mesh > Split Edges > Mesh to Curve.

To get the position, you accumulate the previously captured values. In this example, all my objects have their center in the middle, so I always have to accumulate half of their width, as well as half of the width of the object in front of them.

Finally, you use the node Sample Curve and activate the option All Curves, because you have previously divided the curve into segments. The values for Position and Rotation obtained in this way then correspond exactly to the values you are looking for and since we still have instances here, you can use them directly with Translate Instances and Rotate Instances.

However, the only unsolved problem remains: Depending on the width of your objects, it can happen at sharp corners of a curve that the instantiated objects protrude beyond the corner, ...but that is another question and would definitely go beyond the scope here.

(Blender 3.5.1+)