jaquadro / LilyPath

A 2D path and shape drawing library for MonoGame and XNA.
MIT License
93 stars 12 forks source link

Triangulator gets "IndexOutOfRangeException" #9

Open Sussumu opened 8 years ago

Sussumu commented 8 years ago

I was trying to draw a map using filled path but on the Initialize() method I got IndexOutOfRangeException on "_triPrev" variable on for() loop because "count" goes much higher than the array. The map's vectors are not broken since I can still draw its path using Lines. I tried messing with the values but I don't get all the math behind the code.

jaquadro commented 8 years ago

I believe the aglorithm was implemented from a page in Real-time Collision Detection (https://www.crcpress.com/Real-Time-Collision-Detection/Ericson/9781558607323). My implementation must be slightly off, breaking on an edge case.

The algorithm is the "Ear Clipping" method.

Sussumu commented 8 years ago

Thanks! I'll see if I can correct this or implement another algorithm and do a pull request, though I still need to get used with this Github thing.