From b331b83cbc2bdd5dc1e1928c76e8e4778f8ed186 Mon Sep 17 00:00:00 2001 From: Leman Date: Tue, 21 May 2024 21:33:58 +0800 Subject: [PATCH] fix face area weighting in quadric edge collapse --- .../local_optimization/tri_edge_collapse_quadric.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric.h b/vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric.h index 8c1f0925e..687882e03 100644 --- a/vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric.h +++ b/vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric.h @@ -566,13 +566,17 @@ class TriEdgeCollapseQuadric: public TriEdgeCollapse< TriMeshType, VertexPair, M if((*fi).V(0)->IsR() &&(*fi).V(1)->IsR() &&(*fi).V(2)->IsR()) { Plane3 facePlane; - facePlane.SetDirection( ( (*fi).V(1)->cP() - (*fi).V(0)->cP() ) ^ ( (*fi).V(2)->cP() - (*fi).V(0)->cP() )); - if(!pp->UseArea) - facePlane.Normalize(); + const Point3 dirArea = ( (*fi).V(1)->cP() - (*fi).V(0)->cP() ) ^ ( (*fi).V(2)->cP() - (*fi).V(0)->cP() ); + facePlane.SetDirection(dirArea); + facePlane.Normalize(); + const ScalarType area = dirArea.Norm(); facePlane.SetOffset( facePlane.Direction().dot((*fi).V(0)->cP())); QuadricType q; - q.ByPlane(facePlane); + q.ByPlane(facePlane); + if (pp->UseArea) { + q *= area; + } // The basic < add face quadric to each vertex > loop for(int j=0;j<3;++j)