1 #include "Triangle.hxx"
3 Triangle::Triangle(const Vec3f
& a
,
11 m_n( (b
-a
).cross(c
-a
) )
21 Triangle::Intersect(Ray
& ray
)
23 const Vec3f edge1
= m_b
-m_a
;
24 const Vec3f edge2
= m_c
-m_a
;
26 const Vec3f pvec
= ray
.direction().cross(edge2
);
28 const float det
= edge1
.dot(pvec
);
29 if (fabs(det
) < Epsilon
) return false;
31 const float inv_det
= 1.0f
/ det
;
33 const Vec3f tvec
= ray
.origin()-m_a
;
34 float lambda
= tvec
.dot( pvec
);
37 if (lambda
< 0.0f
|| lambda
> 1.0f
)
40 const Vec3f qvec
= tvec
.cross(edge1
);
41 float mue
= ray
.direction().dot(qvec
);
44 if (mue
< 0.0f
|| mue
+lambda
> 1.0f
)
47 float f
= edge2
.dot(qvec
);
49 if (ray
.t() <= f
|| f
< Epsilon
)
59 Triangle::GetNormal(Ray
& ray
)
65 Triangle::CalcBounds()
71 Triangle::InVoxel(const Box
& box
)
This page took 0.048319 seconds and 5 git commands to generate.