There are different approaches.
Paposos looks like a variant of a scanline algorithm which will definitely work.
A different approach would be the usage of a quad tree (as you are only interested in 2D dimensions)
If we are talking of your engine here: as you use a physics system behind, you might consider to checkout if it provides such a feature as well, otherwise you potentially do twice the same work, as physics, at least newer newton and physx, need such algorithms for fast collision testing and resting
Paposos looks like a variant of a scanline algorithm which will definitely work.
A different approach would be the usage of a quad tree (as you are only interested in 2D dimensions)
If we are talking of your engine here: as you use a physics system behind, you might consider to checkout if it provides such a feature as well, otherwise you potentially do twice the same work, as physics, at least newer newton and physx, need such algorithms for fast collision testing and resting