Apex › Storage & databases

How games skip the n² collision test (spatial hash)

SAT is the exact test — but running it on every pair of objects is O(n²), which explodes. The broad phase is a cheap pre-filter: overlay a uniform grid, bucket each object into its cell, and only test pairs that share a cell, since anything farther can’t touch. Verified against a brute-force oracle: it finds the identical collisions from about 1% of the pair-tests (248 vs 19,900 for 200 objects). Toggle brute force vs the grid and watch the candidate count collapse while the collisions stay the same.

More in Storage & databases