X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGIntersect.hxx;h=533bd2dc005db90668737ec250fdd1a64db4ead2;hb=578af00b0d48100c540154f54293a1b77a0655fe;hp=b2438dc6e3dd05a379f9cadcff765390b017d872;hpb=e417903c231bd63da3e988113b43dcfc0b0abe18;p=simgear.git diff --git a/simgear/math/SGIntersect.hxx b/simgear/math/SGIntersect.hxx index b2438dc6..533bd2dc 100644 --- a/simgear/math/SGIntersect.hxx +++ b/simgear/math/SGIntersect.hxx @@ -572,13 +572,15 @@ closestPoint(const SGTriangle& tri, const SGVec3& p) T u = b*e - c*d; T v = b*d - a*e; +/* // Regions // \2| // \| - // |\ + // |\ // 3 |0\ 1 //---------- // 4 | 5 \ 6 +*/ if (u + v <= det) { if (u < 0) { @@ -743,9 +745,9 @@ inline SGVec3 closestPoint(const SGVec3& p, const SGTriangle& tri) { return closestPoint(tri, p); } -template +template inline bool -intersects(const SGTriangle& tri, const SGSphere& sphere) +intersects(const SGTriangle& tri, const SGSphere& sphere) { // This method minimizes the distance function Q(u, v) = || p - x || // where x is a point in the trialgle given by the vertices v_i @@ -753,7 +755,7 @@ intersects(const SGTriangle& tri, const SGSphere& sphere) // The theoretical analysis is somehow too long for a comment. // May be it is sufficient to see that this code passes all the tests. - SGVec3 off = tri.getBaseVertex() - sphere.getCenter(); + SGVec3 off = tri.getBaseVertex() - SGVec3(sphere.getCenter()); T baseDist2 = dot(off, off); T a = dot(tri.getEdge(0), tri.getEdge(0)); T b = dot(tri.getEdge(0), tri.getEdge(1)); @@ -766,13 +768,15 @@ intersects(const SGTriangle& tri, const SGSphere& sphere) T u = b*e - c*d; T v = b*d - a*e; +/* // Regions // \2| // \| - // |\ + // |\ // 3 |0\ 1 //---------- // 4 | 5 \ 6 +*/ if (u + v <= det) { if (u < 0) { @@ -954,9 +958,9 @@ intersects(const SGTriangle& tri, const SGSphere& sphere) } } } -template +template inline bool -intersects(const SGSphere& sphere, const SGTriangle& tri) +intersects(const SGSphere& sphere, const SGTriangle& tri) { return intersects(tri, sphere); }