diff options
Diffstat (limited to 'core/math/triangulate.cpp')
-rw-r--r-- | core/math/triangulate.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp index cbcb232745..ae278b034d 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -103,13 +103,16 @@ bool Triangulate::snip(const Vector<Vector2> &p_contour, int u, int v, int w, in // To avoid that we allow zero-area triangles if all else failed. float threshold = relaxed ? -CMP_EPSILON : CMP_EPSILON; - if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) return false; + if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) + return false; for (p = 0; p < n; p++) { - if ((p == u) || (p == v) || (p == w)) continue; + if ((p == u) || (p == v) || (p == w)) + continue; Px = contour[V[p]].x; Py = contour[V[p]].y; - if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed)) return false; + if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed)) + return false; } return true; @@ -119,7 +122,8 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul /* allocate and initialize list of Vertices in polygon */ int n = contour.size(); - if (n < 3) return false; + if (n < 3) + return false; Vector<int> V; V.resize(n); @@ -161,11 +165,14 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul /* three consecutive vertices in current polygon, <u,v,w> */ int u = v; - if (nv <= u) u = 0; /* previous */ + if (nv <= u) + u = 0; /* previous */ v = u + 1; - if (nv <= v) v = 0; /* new v */ + if (nv <= v) + v = 0; /* new v */ int w = v + 1; - if (nv <= w) w = 0; /* next */ + if (nv <= w) + w = 0; /* next */ if (snip(contour, u, v, w, nv, V, relaxed)) { int a, b, c, s, t; |