Skip to content

Commit

Permalink
Merge pull request #238 from flm8620/fix_edge_decimation
Browse files Browse the repository at this point in the history
fix face area weighting in quadric edge collapse
  • Loading branch information
alemuntoni authored Jun 3, 2024
2 parents 1016837 + b331b83 commit 48b5508
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ScalarType,false> 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<ScalarType> 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)
Expand Down

0 comments on commit 48b5508

Please sign in to comment.