I want to understand the algorithmic approach to getting the normal of a raycast hit in Unity. I understand the math/theory behind raycasting against a simple collider, but once that is accomplished, how does the engine actually traverse the mesh and get the specific face that was hit?
Assuming there's some underlying spatial data structure (octree/k-d tree) at work here, what component (collider or mesh filter maybe?) stores it and how could I directly access this structure?
Lastly, is raycasthit.normal lazily evaluated or is it automatically computed with each raycast hit? Obviously this is important because I don't want some complex algorithm needlessly determining the specific normal of a cast on a complicated object if I'm only worried about the presence of a hit or not...
I cant seem to find long, detailed documentation on this.