From: frohlich Date: Sun, 15 Mar 2009 12:50:24 +0000 (+0000) Subject: Make triangle sphere intersection tests usable with mixes types. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=61084cf1ba342f2fa3355276296ba90c51fe38ac;p=simgear.git Make triangle sphere intersection tests usable with mixes types. Modified Files: simgear/math/SGIntersect.hxx --- diff --git a/simgear/math/SGIntersect.hxx b/simgear/math/SGIntersect.hxx index b2438dc6..6ffffeb8 100644 --- a/simgear/math/SGIntersect.hxx +++ b/simgear/math/SGIntersect.hxx @@ -743,9 +743,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 +753,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)); @@ -954,9 +954,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); }