Skip to content

Commit

Permalink
Fix jhasse#11 - regression causing crash when abs(p1.y - p2.y) < 1e10
Browse files Browse the repository at this point in the history
This reverts commit e0ba327.

While the orignal commit silences a compiler warning, it introduces incorrect
behavior in Edge constructor that causes crash later during triangulation.

See jhasse#11 for an example of a simple polygon that would cause crash
  • Loading branch information
wonder-sk committed Jan 9, 2020
1 parent e6e63dd commit 6ba292d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions poly2tri/common/shapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ struct Edge {
if (p1.y > p2.y) {
q = &p1;
p = &p2;
} else if (std::abs(p1.y - p2.y) < 1e-10) {
} else if (p1.y == p2.y) {
if (p1.x > p2.x) {
q = &p1;
p = &p2;
} else if (std::abs(p1.x - p2.x) < 1e-10) {
} else if (p1.x == p2.x) {
// Repeat points
throw std::runtime_error("Edge::Edge: p1 == p2");
}
Expand Down

0 comments on commit 6ba292d

Please sign in to comment.