From c2c940338eb7c2676d74cab1f0db5e2f7cf91b18 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 18 Dec 2008 00:27:47 +0000 Subject: [PATCH] added a missing PerFaceFromCurrentVertexNormal mode --- vcg/complex/trimesh/update/normal.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/vcg/complex/trimesh/update/normal.h b/vcg/complex/trimesh/update/normal.h index 4482feb5..ea087d4c 100644 --- a/vcg/complex/trimesh/update/normal.h +++ b/vcg/complex/trimesh/update/normal.h @@ -162,8 +162,23 @@ static void PerVertexFromCurrentFaceNormal(ComputeMeshType &m) (*fi).V(j)->N() += (*fi).cN(); } } - - +/// \brief Calculates the vertex normal. Exploiting or current face normals. +/** + The normal of a face f is the average of the normals of the vertices of f. +*/ +static void PerFaceFromCurrentVertexNormal(ComputeMeshType &m) +{ + for (FaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi) + if( !(*fi).IsD()) + { + NormalType n; + n.SetZero(); + for(int j=0; j<3; ++j) + n += fi->V(j)->cN(); + n.Normalize(); + fi->N() = n; + } +} /// \brief Calculates the vertex normal. Without exploiting or touching face normals. /** The normal of a vertex v is the weigthed average of the normals of the faces incident on v.