Finding the vertices of each edge of a mesh face found by a raycast hit
I am firing a raycast at a mesh and hitting one face. From that hit.point, I want to find the four vertices that would surround that object.
Initially I considered something along the lines of:
 int array of 4 of closest vertex indexes
 for each vertex
     for each close indice
         is the distance closer than the current closest vertex
             yes - move this and every array member after up and make this the new indice and break from close indice for loop
             no - carry on
 return the int array
But I don't think this will work for meshes that are thin and have an abnormal shape to them, like a thin width cube with a vertex in the centre of each face.
I'm sort of lost, as most mesh tutorials online only cover the basics; what a vertex is, normals, uvs. Could anyone advise me a direction for getting a solution to this issue?
I'm thinking I could solve this issue by comparing the UV coordinates of the four mesh indices. If they are not (0,0)(1,0)(0,1) and (1,1), they wouldn't be the correct ones surrounding the face. I don't plan to use the UV coordinates for anything else, either.
Your answer
 
 
             Follow this Question
Related Questions
Unity shader vertex displace doesn't work 0 Answers
Rotate a point around a mesh vertex 1 Answer
How do i calculate the outer bounds??? 0 Answers
Maya Vertex Animation import 1 Answer
Right Click and Drag Formation Line RTS 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                