From 88ef8fa03bdf51a0d90343baca022847cbd415a7 Mon Sep 17 00:00:00 2001 From: mtarini Date: Mon, 7 Sep 2009 17:54:39 +0000 Subject: [PATCH] minor performance optimizations. --- vcg/complex/trimesh/bitquad_optimization.h | 10 +++++----- vcg/complex/trimesh/bitquad_support.h | 9 +++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/vcg/complex/trimesh/bitquad_optimization.h b/vcg/complex/trimesh/bitquad_optimization.h index aafbd303..c833620a 100644 --- a/vcg/complex/trimesh/bitquad_optimization.h +++ b/vcg/complex/trimesh/bitquad_optimization.h @@ -248,7 +248,7 @@ marks (Quality=0) and approx. counts profitable vertex rotations (vertex rotations which make edge shorter */ template -static int MarkVertexRotations(MeshType &m, Pos *p=NULL) +static int MarkVertexRotations(MeshType &m, Pos *affected=NULL) { int res=0; for (VertexIterator vi = m.vert.begin(); vi!=m.vert.end(); vi++) if (!vi->IsD()) vi->ClearV(); @@ -266,8 +266,8 @@ static int MarkVertexRotations(MeshType &m, Pos *p=NULL) res++; MarkVertex(&*fi, k, m); //fi->Q()=0; } else { - if (BQ::RotateVertex(*fi, k, p)) res++; //fi->Q()=0; - if (p) return res; // uncomment for only one rotation + if (BQ::RotateVertex(*fi, k, m, affected)) res++; //fi->Q()=0; + if (affected) return res; // uncomment for only one rotation } } } @@ -291,8 +291,8 @@ static int MarkEdgeRotations(MeshType &m, Pos *p=NULL) if (fi->FFp(k)<= &*fi) continue; // only once per real (non faux) edge, and only for non border ones int best = BQ::TestEdgeRotation(*fi, k); if (perform) { - if (best==+1) if (BQ::template RotateEdge< true>(*fi, k, p)) count++; - if (best==-1) if (BQ::template RotateEdge(*fi, k, p)) count++; + if (best==+1) if (BQ::template RotateEdge< true>(*fi, k, m, p)) count++; + if (best==-1) if (BQ::template RotateEdge(*fi, k, m, p)) count++; if (p) if (count>0) return count; } else { diff --git a/vcg/complex/trimesh/bitquad_support.h b/vcg/complex/trimesh/bitquad_support.h index 08bbbd41..29ce7a94 100644 --- a/vcg/complex/trimesh/bitquad_support.h +++ b/vcg/complex/trimesh/bitquad_support.h @@ -150,12 +150,9 @@ static bool RotateEdge(FaceType& f, int w0a, MeshType &m, Pos *affected=NULL){ if (fa->IsF(w2a) == verse) { if (!CheckFlipDiag(*fa)) return false; FlipDiag(*fa); - // recover edge index, so that (f, w0a) identifies the same edge as before - FaceType *fc = fa->FFp(FauxIndex(fa)); - for (int i=0; i<3; i++){ - if ( v0==fa->V0(i) && v1==fa->V1(i) ) w0a = i; - if ( v0==fc->V0(i) && v1==fc->V1(i) ) { fa = fc; w0a = i; } - } + // hack: recover edge index, so that (f, w0a) identifies the same edge as before + fa = fb->FFp(w0b); + w0a = fb->FFi(w0b); } if (fb->IsF(w2b) == verse) {