diff -Naurw include/triangle3d.h include/triangle3d.h --- include/triangle3d.h 2005-09-16 13:15:50.000000000 +0200 +++ include/triangle3d.h 2005-11-27 00:05:02.000000000 +0100 @@ -60,7 +60,7 @@ bool isPointInside(const vector3d& p) const { return (isOnSameSide(p, pointA, pointB, pointC) && - isOnSameSide(p, pointB, pointA, pointC) && + isOnSameSide(p, pointB, pointC, pointA) && isOnSameSide(p, pointC, pointA, pointB)); } @@ -128,7 +128,7 @@ const vector3d& lineVect, vector3d& outIntersection) const { if (getIntersectionOfPlaneWithLine(linePoint, lineVect, outIntersection)) - return isPointInside(outIntersection); + return isPointInsideFast( outIntersection ); return false; } @@ -150,8 +149,12 @@ if (t2 == 0.0f) return false; - T d = pointA.dotProduct(normal); - T t = -(normal.dotProduct(linePoint) - d) / t2; + core::vector3d midPoint; + midPoint.X = ( pointA.X + pointB.X + pointC.X ) / 3.0f; + midPoint.Y = ( pointA.Y + pointB.Y + pointC.Y ) / 3.0f; + midPoint.Z = ( pointA.Z + pointB.Z + pointC.Z ) / 3.0f; + T d = -midPoint.dotProduct( normal ); + T t = -(( normal.dotProduct( linePoint ) + d ) / t2); outIntersection = linePoint + (lineVect * t); return true; }