Number of boxes:

Moving boxes:

FPS:

Incremental 2D sweep and prune collision detection, based on this article by Pierre Terdiman.

SAP is a broad-phase algorithm whose goal is to determine overlapping pairs of objects. An object in the SAP is defined by an AABB. Given a set of N boxes, the goal is to find the subset of overlapping pairs. In this context, "incremental" means that the SAP provides the added and removed pairs each frame, instead of a full list.