How would you handle finding the interior area of a grid selection?

Hey all,

So i have myself a little Blueprint (Grid_MASTER) that spawns a 6x6 grid of little Grid elements (These themselves are an actor blueprint (Grid_Element).

These Grid elements are stored in an array in Grid_MASTER and have both their Array Index and a X + Y Coordinate stored in them as if they were a 2d Array.

I’ve also built up a little drag and drop selector so I can drag over a bunch of grid elements and change their colour. The end idea is to be able to create a highlighted grid shape and turn it into a room.

My problem is I can’t for the life of me think of a way to get the outer edges of the selection. If it were always a simple rectangle by itself it would be easy, but these selections could be “L” shaped, or join onto other rooms.

How would you guys approach this problem?

Probably not the most optimal way to do it, but I’d probably spawn small-ish cube collision components beside each grid cell and check for overlaps. If it’s making rooms/buildings, I’d probably place the floors first on selected tiles, then add the collision comps outside the selection and see if they overlap a floor piece. Or maybe line traces down from tile centers ±grid size to check for floors. If no floors are hit or overlap (depending on method), it should usually be safe to assume the space is outside the building.