added two assert that checks that you have consistently prepared your mesh before feeding it into a grid for distance checking.

This commit is contained in:
Paolo Cignoni 2009-04-19 21:20:08 +00:00
parent fb261dc8bf
commit b399b4943f
1 changed files with 9 additions and 2 deletions

View File

@ -268,7 +268,13 @@ namespace vcg {
vcg::Point3<typename FaceType::ScalarType> & p ) vcg::Point3<typename FaceType::ScalarType> & p )
{ {
typedef typename FaceType::ScalarType ScalarType; typedef typename FaceType::ScalarType ScalarType;
// assert(f.cN().SquaredNorm() > 0.9999 && f.cN().SquaredNorm()<1.0001); // remember that the macro NDEBUG is defined when you want to optimize a lot.
#ifndef NDEBUG
static int staticCnt=0; // small piece of code that sometime check that face normals are really normalized
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)
#endif
Plane3<ScalarType> fPlane; Plane3<ScalarType> fPlane;
fPlane.Init(f.cP(0),f.cN()); fPlane.Init(f.cP(0),f.cN());
const ScalarType EPSILON = ScalarType( 0.000001); const ScalarType EPSILON = ScalarType( 0.000001);
@ -427,6 +433,7 @@ namespace vcg {
else return false; else return false;
} }
break; break;
default: assert(0); // if you get this assert it means that you forgot to set the required UpdateFlags<MeshType>::FaceProjection(m);
} }