ensure triangulated vertices are not collinear

This commit is contained in:
Tanner Rogalsky 2016-09-26 14:12:39 -04:00
parent 410cf048e2
commit 47d64e42cf

View File

@ -319,7 +319,7 @@ function Polygon:triangulate()
while n_vert > 3 do
next, prev = next_idx[current], prev_idx[current]
local p,q,r = vertices[prev], vertices[current], vertices[next]
if isEar(p,q,r, concave) then
if isEar(p,q,r, concave) and not areCollinear(p, q, r) then
triangles[#triangles+1] = newPolygon(p.x,p.y, q.x,q.y, r.x,r.y)
next_idx[prev], prev_idx[next] = next, prev
concave[q] = nil