From 17ed6bdac4b6ded10e1117f08f4c1f035959e034 Mon Sep 17 00:00:00 2001 From: mcallieri Date: Fri, 10 Jan 2014 13:00:09 +0000 Subject: [PATCH] in the function used to compute normals for pointclouds, added a check during consensus propagation to avoid flipping normals backface w.r.t. the specified wiewposition. It does seem redundant, but it may happen, by mere chance, that the starting point used for consensus propagation, forces other points to flip even if the resulting flip places them backface w.r.t. the specified wiewposition --to be tested-- --- vcg/complex/algorithms/pointcloud_normal.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vcg/complex/algorithms/pointcloud_normal.h b/vcg/complex/algorithms/pointcloud_normal.h index 872ee2b9..4099de65 100644 --- a/vcg/complex/algorithms/pointcloud_normal.h +++ b/vcg/complex/algorithms/pointcloud_normal.h @@ -143,7 +143,9 @@ public: if(!a.trg->IsV()) { a.trg->SetV(); - if(a.src->cN()*a.trg->cN()<0) a.trg->N()=-a.trg->N(); + if(a.src->cN()*a.trg->cN()<0.0f) + if(!p.useViewPoint || ( a.trg->N().dot(p.viewPoint- a.trg->P())<0.0f)) // test to prevent flipping according to viewpos + a.trg->N()=-a.trg->N(); AddNeighboursToHeap(m,a.trg,tree,heap); } }