improved triangulation so that empty triangles can get removed, which can happen with self-intersecting polygons
This commit is contained in:
parent
31c2eb204e
commit
d6b0dc454b
1 changed files with 4 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package canvas
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sort"
|
||||
|
||||
"github.com/tfriedel6/lm"
|
||||
|
@ -77,6 +78,9 @@ func triangulatePath(path []pathPoint, target []float32) []float32 {
|
|||
a := polygon[i]
|
||||
b := polygon[(i+1)%len(polygon)]
|
||||
c := polygon[(i+2)%len(polygon)]
|
||||
if isSamePoint(a, c, math.SmallestNonzeroFloat32) {
|
||||
break
|
||||
}
|
||||
for i2, p := range polygon {
|
||||
if i2 >= i && i2 <= i+2 {
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue