I'm learning processing. I'm trying to do sort of a 2d katamari-damacy-esque thing, where objects randomly float around and stick together when they collide.
What is the best way to handle collision detection in a scalable way? The best thing I could think of would be to keep an array graph[width][height], and each object would update the array each time it moved, storing a reference to each object at that position. If any array element referenced more than one object, do some physics stuff. That, or check every object versus every other object... which seems stupid.
It would be easy to do if every object were just a point... but I also want semi realistic physics where there is rotational inertia and such.
Also, how would I go about creating in-elastic collisions between objects, i.e. create a bouncy ball.