ear clipping using pnpoly algorithm - #156
Conversation
|
Super cool! Merged! |
|
@raspofabs We found a bug that internal angle test in trinangulation fails in some case: https://github.com/tinyobjloader/tinyobjloader/issues/295 The situation is
Computing signed @raspofabs Do you think this is the correct solution? |
Sorry, my mistake. Yes, it looks like the problem is precision during the area calculation. so, take a vertex at random (first is fine), then subtract that vertex's values from all others before doing analysis of the vertices. I can't work on this at the moment as I don't have a machine set up for development right now. |
|
@raspofabs Thanks!
I see. So compute area over polygon(not per trinagle) based on relative vertex coordinate(e.g. move the first vertex to the origin) would solve the issue. I will try it to implement. BTW I have integrated mapbox's earcut into tinyobjloader. We can verify the correctness with it: #298 |
|
@raspofabs After reading algorithm description of earcut, area is calculated per face, not over the polygon. Precision wasn't a problem. |
ear clipping using pnpoly algorithm
I noticed a bug with badly selecting the axis. pnpoly required selecting an axis for running against its 2D algorithm. Doing what it suggested turned out to be a bad idea on some geometry, so I fixed it, and now here's a new PR.