I have a lot of AABB bouncing on the screen. Doing collision/response between 2 AABB is fairly easy, but how do you handle this when you can be pulling AABB's apart but making them getting into another AABB? I mean something like this scenario:
We have 3 AABBs.
We check if first one collides with the other two. No collision is found.
We check if second collides agains the third (we don't need to recheck agains first). We find a collision, we separate second AABB form third but it intersects now with first one.
This will produce a bad response/collision detection. How do you handle this chained collisions?
Edit: I forgot to say that all aabb are dynamics objects. I mean, they move.
Most physics engines that I have seen/used solves this problem by apply a force to the objects instead of directly changing the positions. This does it so that we only need to check collisions once between each object(or not even that if one is using culling algorithms) per update.
e.g. if you only have circles you simply give colliding objects a force away from the centre that is scaled to how close the other object is. AABBs is also somewhat simple as long as you don't need to rotate them. When I implemented a simple physics system(although we used OBBs but we still didn't care about angular velocity) we pushed the objects in the direction of its the closest edge.