From: Sebastian M. <seb...@gm...> - 2009-02-02 08:23:38
|
Hi folks, After solving some other problems not directly related to GMTL, I think I have found a bug in the line segment vs. Box intersection. The problem are the tests of tIn and tOut. In my understanding, the should be between 0 and 1 for a line segment. What is done here is completely wrong, or do I misunderstand something? In my opinion, there has to be a test of tIn < 0.0 || tOut > 1.0 for early rejection. Any comments? <snip> template<class DATA_TYPE> bool intersect(const AABox<DATA_TYPE>& box, const LineSeg<DATA_TYPE>& seg, unsigned int& numHits, DATA_TYPE& tIn, DATA_TYPE& tOut) { numHits = 0; bool result = intersectAABoxRay(box, seg, tIn, tOut); if ( result ) { // If tIn is less than 0, then the origin of the line segment is // inside the bounding box (not on an edge)but the endpoint is // outside. if ( tIn < DATA_TYPE(0)) { numHits = 1; tIn = tOut; } // If tIn is less than 0, then the origin of the line segment is // outside the bounding box but the endpoint is inside (not on an // edge). else if ( tOut > DATA_TYPE(1) ) { numHits = 1; tOut = tIn; } // Otherwise, the line segement intersects the bounding box in two // places. tIn and tOut reflect those points of intersection. else { numHits = 2; } } return result; } </snip> cheers Sebastian |