mirror of
https://github.com/vrld/HC.git
synced 2024-12-08 15:04:23 +00:00
Merge pull request #58 from MartyMaro/master
Ensure triangulated vertices are not collinear
This commit is contained in:
commit
58490756e3
@ -320,10 +320,12 @@ function Polygon:triangulate()
|
||||
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 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
|
||||
n_vert, skipped = n_vert - 1, 0
|
||||
end
|
||||
else
|
||||
skipped = skipped + 1
|
||||
assert(skipped <= n_vert, "Cannot triangulate polygon")
|
||||
|
Loading…
Reference in New Issue
Block a user