Back to class index
| Triangle::IntersectLineTriSyntaxfloat Triangle::IntersectLineTri(const float4 &linePos, const float4 &lineDir, const float4 &v0, const float4 &v1, const float4 &v2, float &u, float &v); [43 lines of code]A helper function used in line-triangle tests. Calculates the intersection between a line and a triangle. The facing is not accounted for, so rays are reported to intersect triangles that are both front and backfacing. According to "T. Möller, B. Trumbore. Fast, Minimum Storage Ray/Triangle Intersection. 2005." http://jgt.akpeters.com/papers/MollerTrumbore97/ Parametersconst float4 &linePosThe starting point of the line. const float4 &lineDirThe direction vector of the line. This does not need to be normalized. const float4 &v0Vertex 0 of the triangle. const float4 &v1Vertex 1 of the triangle. const float4 &v2Vertex 2 of the triangle. float &u [out]The barycentric u coordinate is returned here if an intersection occurred.float &v [out]The barycentric v coordinate is returned here if an intersection occurred. Return ValueThe distance along the ray to the point of intersection, or +inf if no intersection occurred. If no intersection, then u and v and t will contain undefined values. If lineDir was not normalized, then to get the real world-space distance, one must scale the returned value with lineDir.Length(). If the returned value is negative, then the intersection occurs 'behind' the line starting position, with respect to the direction vector lineDir. |