From: <pat...@us...> - 2011-03-27 17:31:17
|
Revision: 1271 http://ggt.svn.sourceforge.net/ggt/?rev=1271&view=rev Author: patrickh Date: 2011-03-27 17:31:11 +0000 (Sun, 27 Mar 2011) Log Message: ----------- Added an overload of gmtl::intersectDoubleSided() for Tri/LineSeg intersection that ignores the triangle winding. Submitted by: Sebastian Messerschmidt Modified Paths: -------------- trunk/ChangeLog trunk/gmtl/Intersection.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-27 17:26:29 UTC (rev 1270) +++ trunk/ChangeLog 2011-03-27 17:31:11 UTC (rev 1271) @@ -1,5 +1,9 @@ DATE AUTHOR CHANGE ---------- ------------ ------------------------------------------------------- +2011-03-27 patrickh Added an overload of gmtl::intersectDoubleSided() for + Tri/LineSeg intersection that ignores the triangle + winding. + Submitted by Sebastian Messerschmidt 2011-03-27 patrickh Added a new Sphere/Sphere intersection function. Submitted by Sebastian Messerschmidt 2010-11-21 patrickh gmtl.pc is once again generated for pkg-config usage. Modified: trunk/gmtl/Intersection.h =================================================================== --- trunk/gmtl/Intersection.h 2011-03-27 17:26:29 UTC (rev 1270) +++ trunk/gmtl/Intersection.h 2011-03-27 17:31:11 UTC (rev 1271) @@ -928,6 +928,45 @@ else { return false; } } + + /** + * Tests if the given triangle intersects with the given ray, from both + * sides. + * + * @param tri The triangle (ccw ordering). + * @param lineseg The line segment + * @param u Tangent space u-coordinate of the intersection. + * @param v Tangent space v-coordinate of the intersection. + * @param t An indicator of the intersection location. + * + * @post \p t gives you the intersection point: + * \code sect = lineseg.getDir() * t + lineseg.getOrigin() \endcode + * + * @return true if the lineseg intersects the triangle. + * + * @see from http://www.acm.org/jgt/papers/MollerTrumbore97/code.html + * + * @since 0.7.0 + */ + template<class DATA_TYPE> + bool intersectDoubleSided(const Tri<DATA_TYPE>& tri, + const LineSeg<DATA_TYPE>& lineseg, + DATA_TYPE& u, DATA_TYPE& v, DATA_TYPE& t) + { + const DATA_TYPE eps = static_cast<DATA_TYPE>(0.0001010101); + const DATA_TYPE l = length(lineseg.getDir()); + + if (eps < l) + { + Ray<DATA_TYPE> temp(lineseg.getOrigin(), lineseg.getDir()); + const bool result = intersectDoubleSided(tri, temp, u, v, t); + return result && t <= static_cast<DATA_TYPE>(1.0); + } + else + { + return false; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |