I have a sphere (icosphere) consisting of potentially thousands of triangles. Given a point in 3d space, I want to know which triangle is "under" that point if you were to shoot a ray from the point towards the center of the sphere. To put it into an analogy, if the earths surface were made up of many triangles and I look down, I want to know which one is directly below me.
Some of my thoughts thus far, there is probably no elegant O(1) lookup solution (or at least I was not able to find anything searching). Doing a ray -> triangle intersection test for every triangle is likely to be too costly as this needs to be done for several points every frame.
The best I can come up with is a short of hashing method with brute checking at the end. Position longitudinally would be the hash key. I would once (at game start) create my hash map. Have "bins" every X degrees on the longitude. Then, for every triangle of the sphere, add the triangle to the bin for which its points fall. Note: A triangle might be placed into two bins if it falls across one of these division lines and that's ok. Then, given my point, I calculate its hash key (position longitudinally), and use that to then do an intersection test between a ray from the point to center of the sphere against every triangle in that bin. It's possible I could further hash it by also using latitude in combination with longitude.
Any thoughts?