Algorithm to fill empty space with rectangles, given initial set of rectangles
Current implementation lacks some optimizations, but with larger grid block sizes it should work fast
I've implemented it mostly just for my wip game with procedural levels
White space in the following images are the rectangles from input set
Grid size in all images is 500x500
As one can see, with larger grid block size, algorithm skips some space

