schteppe/poly-decomp.js

Easily returns a concave poly instead of array of convex polys

colludium opened this issue · 3 comments

Thanks for this library but If I pass a simple concave shape array then it is simply returned as if it's a convex shape (this is easily repeatable with other simple concave shapes). For example:

[[0.2, 0.2], [0.5, -0.5], [0.5, 0.5], [-0.5, 0.5]]

Sorry -not a bug - the library is intact - it appears to be a floating point problem: if I pass integers then everything works! Thanks for your work on this :)

Out of curiosity - what code did you run to get this floating point problem?

It was a simple four-vertex array, with values like 0.499995 in the console. I've just tried to repeat the problem but no luck. My 'fix' was to multiply the values and use Math.floor() prior to sending the array to polygonDecomp(). Not sure what might have 'fixed' it as it doesn't appear to be my using integers...