Building placement within enclosed tile (procedural generation city)

Hi all, I’m trying to procedurally generate a city. I’m stuck on splicing each cell that would contain multiple buildings on it.

I already have two different algorithms I would use to layout the city and streets, voronoi diagram and l-system.
I’m currently stuck on how I would place buildings within each “cell” my idea would be, to divide the cell even further like this:

source: https://www.youtube.com/watch?app=desktop&v=lVxhVFj7Vx8\

and then, once I have every small space within the cell, I would proceed to place prefab buildings on them, not like in the video, where he just extrudes the points.

what I have so far is this, I managed to inset the polygon using clipper2 from Angus Johnson

Now I want to add perpendicular lines intersecting the inner and outer bounds at different locations to have a separation between parcels of buildings, but I don’t know how to proceed.

The general case of solving this is pretty tricky and must account for corner mitering, changes in the number of verts (eg, a flattened corner might have only a single interior corner, as in your picture above at the top of the leftmost island) and any other edge case polygon shape stuff, such as islands that are too small or narrow to accommodate a fixed perimeter.

Might even be easier to turn the problem inside-out and start from the interior and build the buildings into the road.

As far as getting arbitrary polygons to fit within others, that is also an undefined tricky problem, as any arbitrary set of inputs probably has a lot of different possible outputs.

If you want to get started, treat the perimeter of each area as a linear line and just put buildings along that line, either inside, outside, or on it, and orient them to the line normal.

The general solution for stuff like this is the field of constructive solid geometry (CSG). This is what is usually used for boolean operators between arbitrary shapes. In your case you would use CSG to “cut” individual buildings out of a an initial larger building spanning the entire block.

Personally I would focus on getting something up and going, even if the corners have issues, and then you can solve that problem later. :slight_smile:

Thanks for your input. I think you’re right I will start by just generating buildings on the tiles because this is too tricky I have to take into account so many cases, since the l-system can also give concave polygons this makes it very hard