CHANGE to the VERY USED PointDistanceBase, the basic functor used to find the closest point to a face in all the grids.
It has a bug that could return a nan in some degnerate case where an almost null face has different vertices but the squared distance between them could be zero. Now it should handle also these cases.
This commit is contained in:
parent
b57a747441
commit
f58551601a
|
@ -324,15 +324,19 @@ namespace vcg {
|
||||||
Box3<ScalarType> bb;
|
Box3<ScalarType> bb;
|
||||||
f.GetBBox(bb);
|
f.GetBBox(bb);
|
||||||
Segment3<ScalarType> degenTri(bb.min,bb.max);
|
Segment3<ScalarType> degenTri(bb.min,bb.max);
|
||||||
//Point3<ScalarType> closest= ClosestPoint( degenTri, q );
|
|
||||||
//ScalarType d = Distance(closest, q);
|
|
||||||
Point3<ScalarType> closest;
|
Point3<ScalarType> closest;
|
||||||
ScalarType d;
|
ScalarType d;
|
||||||
|
if(bb.Diag()>0)
|
||||||
vcg::SegmentPointDistance<ScalarType>(degenTri,q,closest,d);
|
vcg::SegmentPointDistance<ScalarType>(degenTri,q,closest,d);
|
||||||
if( d>dist || d<-dist ) // Risultato peggiore: niente di fatto
|
else // very degenerate triangle (just a point)
|
||||||
return false;
|
{
|
||||||
|
closest = bb.min;
|
||||||
|
d=Distance(q,closest);
|
||||||
|
}
|
||||||
|
if( d>dist) return false;
|
||||||
dist=d;
|
dist=d;
|
||||||
p=closest;
|
p=closest;
|
||||||
|
assert(!math::IsNAN(dist));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue