Open udit opened 3 years ago
cc @Xrayez
Godot's triangulator may fail when there are:
This could be considered a duplicate of #40911, or rather part of the triangulation error problem (see potential solutions and workarounds there).
I am quite sure that the example polygon with 6 vertices doesn't fall into 1,2,4 category. Can you explain what you mean by vertices touch edges scenario?
Can you explain what you mean by vertices touch edges scenario?
This one:
But it appears that this case works in fact. I'm not actually sure what could cause the error, the cases I listed are more like common causes for triangulation libraries...
Could floating point error be the cause since the points are quite close in my example? I transposed the polygon towards origin on x axis and the error disappeared and it comes back on some positions as I keep moving it.
Godot compares floats in some cases using CMP_EPSILON
. When used in the context of triangulation, perhaps this is where those errors come from...
Therefore, I suggest snapping coordinates to integer values for procedurally generated stuff as a workaround, but I don't know whether it would resolve all errors.
Godot version
3.3.3.stable
System information
Windows 10
Issue description
My game procedurally generates polygons and I noticed that it was intermittently throwing
Invalid polygon data, triangulation failed error
when I enable visible collision shapes. I have isolated few points when this error occurs:As you can see the points form a valid polygon and are in correct order, but it still throws following error:
Steps to reproduce
Provided minimal reproduction project below
Minimal reproduction project
PolygonTest.zip