Original Post
I have my Ray / Tri intersection test working but I now have a new problem as i bi-product. If my ray strikes a triangle in a model there is also a good chance that the ray will be long enough to strike a second triangle that is directly behind and parellel to the first polgon the ray hit. I need a way of determining which tri is closest to the rays origin. Measuring the distance to each tri''s plane intersection point won''t work i think (prove me wrong please) so i have come up with this :
fTriDist = LineSegLength(RayEndPoint, Tri[0]) +
LineSegLength(RayEndPoint, Tri[1]) +
LineSegLength(RayEndPoint, Tri[2]) / 3;
This will work for some polgons but not all. What if you have a large tri which is closest to the ray but has one vertex far away from the ray. This will screw up the scoring system above. How can i best tell the closest triangle to any given point?