-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
Hi,
I'm not sure if this is a bug or design limitation, but: the tesselator appears to create a colinear triangle (e.g. a triangle where all 3 vertices are colinear) if the input is a single contour with colinear vertices on a vertical right side.
Here's my test program.
static void test()
{
float v[10] = {
-20.0, 5.00,
0.00, 5.00,
0.00, 15.00,
0.00, 25.00,
-20.0, 25.00
};
TESStesselator * t = tessNewTess(nullptr);
tessAddContour(t, 2, v, 2 * sizeof(float), 5);
float nrm[3] = { 0, 0, 1 };
int ok = tessTesselate(t, TESS_WINDING_POSITIVE, TESS_POLYGONS, 3, 2, nrm);
if(ok)
{
const float * v = tessGetVertices(t);
int ic = tessGetElementCount(t);
const int * idx = tessGetElements(t);
while(ic--)
{
int i1 = *idx++;
int i2 = *idx++;
int i3 = *idx++;
printf("Tri: (%.2f,%.2f) (%.2f,%.2f) (%.2f,%.2f)\n",
v[i1*2],v[i1*2+1],
v[i2*2],v[i2*2+1],
v[i3*2],v[i3*2+1]);
}
}
tessDeleteTess(t);
}
The output is:
Tri: (-20.00,25.00) (0.00,5.00) (0.00,25.00)
Tri: (0.00,5.00) (-20.00,25.00) (-20.00,5.00)```
My expectation is that the 3 right-most colinear vertical vertices would not be organized into a single triangle.
Note that if the data is rotated 180 so that the left side has the colinear vertices, the colinear triangle does not occur. Changing the vertex table to
``` float v[10] = {
20.0, -5.00,
0.00, -5.00,
0.00, -15.00,
0.00, -25.00,
20.0, -25.00
};
gives us
Tri: (0.00,-5.00) (20.00,-25.00) (20.00,-5.00)
Tri: (0.00,-15.00) (20.00,-25.00) (0.00,-5.00)
Tri: (20.00,-25.00) (0.00,-15.00) (0.00,-25.00)
where each triangle is non-colinear.
Metadata
Metadata
Assignees
Labels
No labels