Skip to content

Commit

Permalink
Merge pull request #710 from zeux/simp-flip
Browse files Browse the repository at this point in the history
simplify: Make hasTriangleFlip predicate use an angle cutoff
  • Loading branch information
zeux authored Jun 25, 2024
2 parents f13503c + 1f42cf0 commit 452f7d1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/simplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,13 @@ static bool hasTriangleFlip(const Vector3& a, const Vector3& b, const Vector3& c
Vector3 nbc = {eb.y * ec.z - eb.z * ec.y, eb.z * ec.x - eb.x * ec.z, eb.x * ec.y - eb.y * ec.x};
Vector3 nbd = {eb.y * ed.z - eb.z * ed.y, eb.z * ed.x - eb.x * ed.z, eb.x * ed.y - eb.y * ed.x};

return nbc.x * nbd.x + nbc.y * nbd.y + nbc.z * nbd.z <= 0;
float ndp = nbc.x * nbd.x + nbc.y * nbd.y + nbc.z * nbd.z;
float abc = nbc.x * nbc.x + nbc.y * nbc.y + nbc.z * nbc.z;
float abd = nbd.x * nbd.x + nbd.y * nbd.y + nbd.z * nbd.z;

// scale is cos(angle); somewhat arbitrarily set to ~75 degrees
// note that the "pure" check is ndp <= 0 (90 degree cutoff) but that allows flipping through a series of close-to-90 collapses
return ndp <= 0.25f * sqrtf(abc * abd);
}

static bool hasTriangleFlips(const EdgeAdjacency& adjacency, const Vector3* vertex_positions, const unsigned int* collapse_remap, unsigned int i0, unsigned int i1)
Expand Down

0 comments on commit 452f7d1

Please sign in to comment.