Room detection using flood-fill algorithm like The Sims

I am trying to implement a home building system like in The Sims.

I can create the walls and place them in the grid, but I am struggling to find the right logic to detect when a set of walls create a new room.

I know a good way could be using the floodfill algorithm, but the only example I could find are applied to 2d games, in 3d things are more tricky.

Any good reference or any open source solution available for this?

Thanks!

Wait… why isn’t a 2D problem, even if your models are 3D? Surely you can work on one (two-dimensional) floor at a time for this purpose?