Collision detection is naturally an O(n^2) problem.
You have a bunch of objects and you need to check if that object is colliding with every other object. Right now that is my naive approach and while it isn't a problem for a limited number of objects I'm now approaching the point that it is a bottleneck (after profiling my code).
Here is example of my simple program I'm working on:
There are 400 balls in the image and I have added up to 1000. 1000^2 is a million collision checks, each game update. I need to implement some broad phase pruning. It is too slow and you can tell in the simulations that it is taking a definite toll.
What technique do I need to use for my broad phase collision detection? I'm looking for what the best solution to this 2D use-case is. Is it QuadTrees? Is it BSP? What?