mathlib: ClosestPointOnLineSegment: handle degenerate line segment

This commit is contained in:
Eric Wasylishen 2017-06-15 03:27:58 -06:00
parent 42af888f3d
commit c1f3a0f2e4
1 changed files with 2 additions and 2 deletions

View File

@ -762,9 +762,9 @@ float DistToLineSegment(const qvec3f &v, const qvec3f &w, const qvec3f& p)
qvec3f ClosestPointOnLineSegment(const qvec3f &v, const qvec3f &w, const qvec3f& p)
{
const float frac = FractionOfLine(v, w, p);
if (frac > 1)
if (frac >= 1)
return w;
if (frac < 0)
if (frac <= 0)
return v;
return ClosestPointOnLine(v, w, p);