11 #ifndef __solve_RayTriangleIntersect_h__ 12 #define __solve_RayTriangleIntersect_h__ 14 #define FE_RTI_DEBUG FALSE 16 #define FE_MOLLER_EPSILON (1e-6) 17 #define FE_MOLLER_TEST_CULL FALSE //* ignore backside using implied normal 41 static void resolveContact(
64 feLog(
"vert %s %s %s\n",c_print(vert0),c_print(vert1),c_print(vert2));
65 feLog(
"origin %s\n",c_print(origin));
66 feLog(
"direction %s\n",c_print(direction));
75 cross3(pvec,direction,edge2);
78 T det=dot(edge1, pvec);
81 #if FE_MOLLER_TEST_CULL 82 if(det<T(FE_MOLLER_EPSILON))
85 feLog(
" miss: det=%.6G\n",det);
98 feLog(
" miss: u=%.6G\n",u);
105 cross3(qvec,tvec,edge1);
108 T v=dot(direction,qvec);
109 if(v<T(0) || u+v>det)
112 feLog(
" miss: u=%.6G v=%.6G\n",u,v);
118 T range=dot(edge2,qvec);
126 if(det>-T(FE_MOLLER_EPSILON) && det<T(FE_MOLLER_EPSILON))
129 feLog(
" miss: det=%.6G\n",det);
139 T u=dot(tvec,pvec)*inv_det;
143 feLog(
" miss: u=%.6G\n",u);
150 cross3(qvec,tvec,edge1);
153 T v=dot(direction,qvec)*inv_det;
154 if(v<T(0) || u+v>T(1))
157 feLog(
" miss: u=%.6G v=%.6G\n",u,v);
163 T range=dot(edge2,qvec)*inv_det;
167 barycenter.setUV(u,v);
170 feLog(
" hit: u=%.6G v=%.6G range=%.6G\n",u,v,range);
177 template <
typename T>
192 intersection=origin+direction*range;
197 cross(normal,edge1,edge2);
199 normal=location(barycenter,norm0,norm1,norm2);
201 normalizeSafe(normal);
kernel
Definition: namespace.dox:3
Barycentric coordinates for a triangle.
Definition: Barycenter.h:26
Find intersection between ray and triangle.
Definition: RayTriangleIntersect.h:32