Skip to content

Commit

Permalink
bugfix the three vertices are collinear when converting a polygon to …
Browse files Browse the repository at this point in the history
…a triangle.

Signed-off-by: Jackie9527 <80555200+Jackie9527@users.noreply.github.com>
  • Loading branch information
Jackie9527 committed Feb 25, 2023
1 parent 46ae853 commit 93e7450
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions code/PostProcessing/TriangulateProcess.cpp
Expand Up @@ -468,6 +468,20 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
continue;
}

// Skip when three point is in a line
aiVector2D left = *pnt0 - *pnt1;
aiVector2D right = *pnt2 - *pnt1;

left.Normalize();
right.Normalize();
auto mul = left * right;

// if the angle is 0 or 180
if (std::abs(mul - 1.f) < ai_epsilon || std::abs(mul + 1.f) < ai_epsilon) {
// skip this ear
continue;
}

// and no other point may be contained in this triangle
for ( tmp = 0; tmp < max; ++tmp) {

Expand Down

0 comments on commit 93e7450

Please sign in to comment.