From b399b4943f328067cc5d02e6f93df6f5cf54a634 Mon Sep 17 00:00:00 2001 From: cignoni Date: Sun, 19 Apr 2009 21:20:08 +0000 Subject: [PATCH] added two assert that checks that you have consistently prepared your mesh before feeding it into a grid for distance checking. --- vcg/simplex/face/distance.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vcg/simplex/face/distance.h b/vcg/simplex/face/distance.h index 9f867352..607b4c99 100644 --- a/vcg/simplex/face/distance.h +++ b/vcg/simplex/face/distance.h @@ -268,7 +268,13 @@ namespace vcg { vcg::Point3 & p ) { 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 fPlane; fPlane.Init(f.cP(0),f.cN()); const ScalarType EPSILON = ScalarType( 0.000001); @@ -427,7 +433,8 @@ namespace vcg { else return false; } break; - + default: assert(0); // if you get this assert it means that you forgot to set the required UpdateFlags::FaceProjection(m); + } dist = ScalarType(fabs(d));