How would you optimize a collision detection system for hundreds of architectural objects in a web browser?
Implement the collision query for axis-aligned rectangular objects using a uniform spatial hash. Return every pair whose interiors overlap, excluding objects that only touch at an edge or corner.
detect_collisions(objects, cell_size) receives a list of dictionaries with integer id, x, y, width, and height fields. Return sorted [id1, id2] pairs, with each pair ordered by ID.
def detect_collisions(objects, cell_size):