src/ldObject.cc

branch
experimental
changeset 891
00d76b281021
parent 890
903ec1e46298
child 895
f0d14f16ae87
--- a/src/ldObject.cc	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/ldObject.cc	Tue Sep 09 01:17:36 2014 +0300
@@ -419,6 +419,7 @@
 	data->id = id();
 	data->num = num;
 	data->color = color().index();
+	data->winding = blockWinding();
 
 	for (int i = 0; i < data->numVertices(); ++i)
 		data->vertices[i] = vertex (i);
@@ -430,14 +431,29 @@
 //
 QList<LDPolygon> LDSubfile::inlinePolygons()
 {
+	bool isInverted (false);
+	LDBFCPtr bfc (previous().dynamicCast<LDBFC>());
+
+	if ((bfc != null and bfc->statement() == BFCStatement::InvertNext)
+		or transform().getDeterminant() < 0)
+	{
+		isInverted = true;
+	}
+
+	print ("inlining polygons of subfile-ref %1: inverted: %2", fileInfo()->name(), isInverted ? "true" : "false");
+
 	QList<LDPolygon> data = fileInfo()->inlinePolygons();
 
 	for (LDPolygon& entry : data)
 	{
 		for (int i = 0; i < entry.numVertices(); ++i)
 			entry.vertices[i].transform (transform(), position());
+
+		if (isInverted)
+			invertWinding (entry.winding);
 	}
 
+	print ("Using winding: %1\n", (data[0].winding == Winding::CCW) ? "CCW" : (data[0].winding == Winding::CW) ? "CW" : "None");
 	return data;
 }
 

mercurial