diff --git a/vcg/space/intersection3.h b/vcg/space/intersection3.h index 7ef24d91..6e56cc83 100644 --- a/vcg/space/intersection3.h +++ b/vcg/space/intersection3.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.16 2005/09/28 19:40:55 m_di_benedetto +Added intersection for ray-triangle (with Ray3 type). + Revision 1.15 2005/06/29 15:28:31 callieri changed intersection names to more specific to avoid ambiguity @@ -479,6 +482,26 @@ bool Intersection (const Plane3 & plane0, const Plane3 & plane1, } +// Ray-Triangle Functor +template +class RayTriangleIntersectionFunctor { +public: + template + inline bool operator () (const TRIANGLETYPE & f, const Ray3 & ray, SCALARTYPE & t) { + typedef SCALARTYPE ScalarType; + ScalarType a; + ScalarType b; + + bool bret = Intersection(ray, Point3::Construct(f.P(0)), Point3::Construct(f.P(1)), Point3::Construct(f.P(2)), a, b, t); + if (BACKFACETEST) { + if (!bret) { + bret = Intersection(ray, Point3::Construct(f.P(0)), Point3::Construct(f.P(2)), Point3::Construct(f.P(1)), a, b, t); + } + } + return (bret); + } +}; + /*@}*/