Skip to content
Snippets Groups Projects
Commit 655e0c11 authored by bobarna's avatar bobarna
Browse files

asd

parent 4de7ef74
No related branches found
No related tags found
No related merge requests found
...@@ -229,17 +229,23 @@ public: ...@@ -229,17 +229,23 @@ public:
vec2 currPotDiag1 = *getNextVertex(currVertex); vec2 currPotDiag1 = *getNextVertex(currVertex);
vec2 currPotDiag2 = *getPreviousVertex(currVertex); vec2 currPotDiag2 = *getPreviousVertex(currVertex);
//check if current potential diagonal intersects any edges auto intersectsOtherEdges = [&]() -> bool {
// skipping edges that share a vertex with it
for (auto currEdgeStart = getPreviousVertex(getPreviousVertex(currVertex)); for (auto currEdgeStart = getPreviousVertex(getPreviousVertex(currVertex));
currEdgeStart != getNextVertex(getNextVertex(currVertex)); currEdgeStart = getPreviousVertex(currEdgeStart)) currEdgeStart != getNextVertex(getNextVertex(currVertex));
currEdgeStart = getPreviousVertex(currEdgeStart))
if (intersectEachOther(vec2(currEdgeStart->x, currEdgeStart->y), if (intersectEachOther(vec2(currEdgeStart->x, currEdgeStart->y),
vec2(getNextVertex(currEdgeStart)->x, getNextVertex(currEdgeStart)->y), vec2(getNextVertex(currEdgeStart)->x, getNextVertex(currEdgeStart)->y),
currPotDiag1, currPotDiag2)) { currPotDiag1, currPotDiag2)) {
currVertex++; return true;
break;
} }
return false;
};
//check if current potential diagonal intersects any edges
// skipping edges that share a vertex with it
if (intersectsOtherEdges()) {
currVertex++;
}
//check if current potential diagonal is fully outside the polygon //check if current potential diagonal is fully outside the polygon
vec2 infinity(200, 200); vec2 infinity(200, 200);
...@@ -253,7 +259,7 @@ public: ...@@ -253,7 +259,7 @@ public:
numberOfIntersections++; numberOfIntersections++;
if (numberOfIntersections % 2 == 0) { if (numberOfIntersections % 2 == 0) {
currVertex++; currVertex++;
break; // the potential diagonal is fully outside, it's not an ear. continue; // the potential diagonal is fully outside, it's not an ear.
} }
//it's an ear! //it's an ear!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment