I have a bunch of spheres with different radius scattered all over the place in a 3D system.
What would be the fastest way to determine what sphere a point is inside, and if it is inside more than one - also the closest sphere based on the sphere's center.
The bruteforce method is to simply loop over all spheres, calculate the distance to the point, check if that distance is smaller than the sphere's radius and then find the sphere with the shortest disrance.
However, I got a couple million points to check (with about 100k spheres), so this would be incredibly slow.
Another idea of mine would be to build some kind of BVH Acceleration structure and save for each cell what sphere is the closest. However, there are also cases where one cell could be overlapped by two or more spheres etc. So a lot of edge-cases to consider.
And after all, the computation of the BVH tree should not be slower than the bruteforce.
Any ideas?