From e66d045060ffc8f3386cba564441c30de440d46c Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Mon, 20 Jan 2020 10:19:20 +0100 Subject: [PATCH] Fix #11 - regression causing crash when abs(p1.y - p2.y) < 1e10 (#12) This reverts commit e0ba327ed83f3e32933cf6cc4f61fabc50191711. While the orignal commit silences a compiler warning, it introduces incorrect behavior in Edge constructor that causes crash later during triangulation. See #11 for an example of a simple polygon that would cause crash --- poly2tri/common/shapes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/poly2tri/common/shapes.h b/poly2tri/common/shapes.h index f329c7f..43bb40a 100644 --- a/poly2tri/common/shapes.h +++ b/poly2tri/common/shapes.h @@ -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"); }