Added a test to check in the point to face distance computation to manage the case of degenerated faces. Now correctly resort to distance point to segment.
This commit is contained in:
parent
d340b8b92a
commit
5ef6d30d37
vcg/simplex/face
|
@ -62,6 +62,7 @@ created
|
||||||
|
|
||||||
#include <vcg/math/base.h>
|
#include <vcg/math/base.h>
|
||||||
#include <vcg/space/point3.h>
|
#include <vcg/space/point3.h>
|
||||||
|
#include <vcg/space/segment3.h>
|
||||||
|
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
|
@ -310,9 +311,23 @@ namespace vcg {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
static int staticCnt=0; // small piece of code that sometime check that face normals are really normalized
|
static int staticCnt=0; // small piece of code that sometime check that face normals are really normalized
|
||||||
if((staticCnt++%100)==0)
|
if((staticCnt++%100)==0)
|
||||||
assert(f.cN().SquaredNorm() > 0.9999 && f.cN().SquaredNorm()<1.0001); // if you get this assert you have forgot to make a UpdateNormals::PerFaceNormalized(m)
|
assert((f.cN().SquaredNorm() ==0) || (f.cN().SquaredNorm() > 0.9999 && f.cN().SquaredNorm()<1.0001)); // if you get this assert you have forgot to make a UpdateNormals::PerFaceNormalized(m)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(f.cN()==Point3<ScalarType>(0,0,0)) // to correctly manage the case of degenerate triangles we consider them as segments.
|
||||||
|
{
|
||||||
|
Box3<ScalarType> bb;
|
||||||
|
f.GetBBox(bb);
|
||||||
|
Segment3<ScalarType> degenTri(bb.min,bb.max);
|
||||||
|
Point3<ScalarType> closest= ClosestPoint( degenTri, q );
|
||||||
|
ScalarType d = Distance(closest, q);
|
||||||
|
if( d>dist || d<-dist ) // Risultato peggiore: niente di fatto
|
||||||
|
return false;
|
||||||
|
dist=d;
|
||||||
|
p=closest;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Plane3<ScalarType> fPlane;
|
Plane3<ScalarType> fPlane;
|
||||||
fPlane.Init(f.cP(0),f.cN());
|
fPlane.Init(f.cP(0),f.cN());
|
||||||
const ScalarType EPS = ScalarType( 0.000001);
|
const ScalarType EPS = ScalarType( 0.000001);
|
||||||
|
|
Loading…
Reference in New Issue