I'm currently programming an opengl 2d particle system, but I've run into more of a general programing problem that I need help with.
Basically, I need a way to find if particles may be colliding, I.e. broad phase collision detection.
I've done a lot of reading on using Morton codes and kd trees for spacial partioning in order to cull lots of points that need not be tested for collision. However, it seems to me that kd trees are only useful when doing a nearest neighbor search. Instead, I want to get all the neighbors within a radius. The crucial problem is that I'd like to do this for every point.
So my question is: Is there any advantage to creating a kd tree using my Morton codes, or would a sorted Morton code list be sufficient? In theory, if I have an array of sorted Morton codes that correspond to sorted particle id's, could I simply look in the Morton array at the elements surrounding my current particle and check the distance? I imagine I'd keep doing this until the distance is greater than my defined radius.
Does that make sense? Or should I opt for some type of tree structure?