Add TESS_REVERSE_CONTOURS to TessOption
diff --git a/Include/tesselator.h b/Include/tesselator.h
index 6d4aa39..31d91f1 100755
--- a/Include/tesselator.h
+++ b/Include/tesselator.h
@@ -118,10 +118,15 @@
// TESS_CONSTRAINED_DELAUNAY_TRIANGULATION
// If enabled, the initial triagulation is improved with non-robust Constrained Delayney triangulation.
// Disable by default.
+//
+// TESS_REVERSE_CONTOURS
+// If enabled, tessAddContour() will treat CW contours as CCW and vice versa
+// Disabled by default.
enum TessOption
{
TESS_CONSTRAINED_DELAUNAY_TRIANGULATION,
+ TESS_REVERSE_CONTOURS
};
typedef float TESSreal;
@@ -192,7 +197,7 @@
// pointer - pointer to the first coordinate of the first vertex in the array.
// stride - defines offset in bytes between consecutive vertices.
// count - number of vertices in contour.
-void tessAddContour( TESStesselator *tess, int size, const void* pointer, int stride, int count, int reversed );
+void tessAddContour( TESStesselator *tess, int size, const void* pointer, int stride, int count );
// tessSetOption() - Toggles optional tessellation parameters
// Parameters:
diff --git a/Source/tess.c b/Source/tess.c
index ff1fb07..c293768 100755
--- a/Source/tess.c
+++ b/Source/tess.c
@@ -629,6 +629,8 @@
tess->bmax[0] = 0;
tess->bmax[1] = 0;
+ tess->reverseContours = 0;
+
tess->windingRule = TESS_WINDING_ODD;
if (tess->alloc.regionBucketSize < 16)
@@ -911,7 +913,7 @@
}
void tessAddContour( TESStesselator *tess, int size, const void* vertices,
- int stride, int numVertices, int reversed )
+ int stride, int numVertices )
{
const unsigned char *src = (const unsigned char*)vertices;
TESShalfEdge *e;
@@ -973,8 +975,8 @@
* vertices in such an order that a CCW contour will add +1 to
* the winding number of the region inside the contour.
*/
- e->winding = (reversed) ? -1 : 1;
- e->Sym->winding = (reversed) ? 1 : -1;
+ e->winding = (tess->reverseContours) ? -1 : 1;
+ e->Sym->winding = (tess->reverseContours) ? 1 : -1;
}
}
@@ -985,6 +987,9 @@
case TESS_CONSTRAINED_DELAUNAY_TRIANGULATION:
tess->processCDT = value > 0 ? 1 : 0;
break;
+ case TESS_REVERSE_CONTOURS:
+ tess->reverseContours = value > 0 ? 1 : 0;
+ break;
}
}
diff --git a/Source/tess.h b/Source/tess.h
index c1f981f..f54458d 100755
--- a/Source/tess.h
+++ b/Source/tess.h
@@ -62,7 +62,8 @@
TESSreal bmax[2];
int processCDT; /* option to run Constrained Delayney pass. */
-
+ int reverseContours; /* tessAddContour() will treat CCW contours as CW and vice versa */
+
/*** state needed for the line sweep ***/
int windingRule; /* rule for determining polygon interior */