added support for BFC CLIP/NOCLIP

Fri, 02 Aug 2013 13:58:14 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 02 Aug 2013 13:58:14 +0300
changeset 418
c435027ee5cd
parent 417
14bfeed046f3
child 419
d21b0a61d3b7

added support for BFC CLIP/NOCLIP

changelog.txt file | annotate | diff | comparison | revisions
src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/file.cpp file | annotate | diff | comparison | revisions
src/gldraw.cpp file | annotate | diff | comparison | revisions
src/ldtypes.cpp file | annotate | diff | comparison | revisions
src/ldtypes.h file | annotate | diff | comparison | revisions
--- a/changelog.txt	Thu Aug 01 17:00:14 2013 +0300
+++ b/changelog.txt	Fri Aug 02 13:58:14 2013 +0300
@@ -10,6 +10,8 @@
 	- Fixed: "Hi-Res" was not prepended to the names of 48/ primitives.
 	- Fixed: Checking the Hi-Res option would not allow segment values over 16.
 	- Added support for multiple spaces before the ring number.
+- Added support for '0 BFC CLIP' and '0 BFC NOCLIP' and added auto-correction
+	from errorneous MLCAD syntax ('0 BFC CERTIFY CLIP').
 
 =================================================
 == Changes in version 0.2-alpha
--- a/src/addObjectDialog.cpp	Thu Aug 01 17:00:14 2013 +0300
+++ b/src/addObjectDialog.cpp	Fri Aug 02 13:58:14 2013 +0300
@@ -83,8 +83,13 @@
 	case LDObject::BFC:
 		rb_bfcType = new RadioBox ("Statement", {}, 0, Qt::Vertical);
 		
-		for (int i = 0; i < LDBFCObject::NumStatements; ++i)
+		for (int i = 0; i < LDBFCObject::NumStatements; ++i) {
+			// Separate these in two columns
+			if (i == LDBFCObject::NumStatements / 2)
+				rb_bfcType->rowBreak();
+			
 			rb_bfcType->addButton (LDBFCObject::statements[i]);
+		}
 		
 		if (obj)
 			rb_bfcType->setValue ((int) static_cast<LDBFCObject*> (obj)->type);
--- a/src/file.cpp	Thu Aug 01 17:00:14 2013 +0300
+++ b/src/file.cpp	Fri Aug 02 13:58:14 2013 +0300
@@ -642,9 +642,19 @@
 			
 			// MLCAD is notorious for stuffing these statements in parts it
 			// creates. The above block only handles valid statements, so we
-			// need to handle MLCAD-style invertnext separately.
-			if (comm == "BFC CERTIFY INVERTNEXT")
-				return new LDBFCObject (LDBFCObject::InvertNext);
+			// need to handle MLCAD-style invertnext, clip and noclip separately.
+			struct {
+				const char* a;
+				LDBFCObject::Type b;
+			} BFCData[] = {
+				{ "INVERTNEXT", LDBFCObject::InvertNext },
+				{ "NOCLIP", LDBFCObject::NoClip },
+				{ "CLIP", LDBFCObject::Clip }
+			};
+			
+			for (const auto& i : BFCData)
+				if (comm == fmt ("BFC CERTIFY %1", i.a))
+					return new LDBFCObject (i.b);
 		}
 		
 		if (tokens.size() > 2 && tokens[1] == "!LDFORGE") {
--- a/src/gldraw.cpp	Thu Aug 01 17:00:14 2013 +0300
+++ b/src/gldraw.cpp	Fri Aug 02 13:58:14 2013 +0300
@@ -741,6 +741,8 @@
 		break;
 	
 	case LDObject::CondLine:
+		// Draw conditional lines with a dash pattern - however, use a full
+		// line when drawing a pick list to make selecting them easier.
 		if (list != GL::PickList) {
 			glLineStipple (1, 0x6666);
 			glEnable (GL_LINE_STIPPLE);
@@ -782,40 +784,6 @@
 		}
 		break;
 	
-#if 0
-	TODO: find a proper way to draw vertices without having them be affected by zoom.
-	case LDObject::Vertex:
-		{
-			LDVertex* pVert = static_cast<LDVertex*> (obj);
-			LDTriangle* pPoly;
-			vertex* vPos = &(pVert->pos);
-			const double fPolyScale = max (fZoom, 1.0);
-			
-#define BIPYRAMID_COORD(N) ((((i + N) % 4) >= 2 ? 1 : -1) * 0.3f * fPolyScale)
-			
-			for (int i = 0; i < 8; ++i) {
-				pPoly = new LDTriangle;
-				pPoly->coords[0] = {vPos->x, vPos->y + ((i >= 4 ? 1 : -1) * 0.4f * fPolyScale), vPos->z};
-				pPoly->coords[1] = {
-					vPos->x + BIPYRAMID_COORD (0),
-					vPos->y,
-					vPos->z + BIPYRAMID_COORD (1)
-				};
-				
-				pPoly->coords[2] = {
-					vPos->x + BIPYRAMID_COORD (1),
-					vPos->y,
-					vPos->z + BIPYRAMID_COORD (2)
-				};
-				
-				pPoly->dColor = pVert->dColor;
-				compileOneObject (pPoly, list);
-				delete pPoly;
-			}
-		}
-		break;
-#endif // 0
-	
 	default:
 		break;
 	}
--- a/src/ldtypes.cpp	Thu Aug 01 17:00:14 2013 +0300
+++ b/src/ldtypes.cpp	Fri Aug 02 13:58:14 2013 +0300
@@ -159,6 +159,10 @@
 	"CW",
 	"NOCERTIFY",
 	"INVERTNEXT",
+	"CLIP",
+	"CLIP CCW",
+	"CLIP CW",
+	"NOCLIP",
 };
 
 str LDBFCObject::raw() {
--- a/src/ldtypes.h	Thu Aug 01 17:00:14 2013 +0300
+++ b/src/ldtypes.h	Fri Aug 02 13:58:14 2013 +0300
@@ -241,6 +241,10 @@
 		CW,
 		NoCertify,
 		InvertNext,
+		Clip,
+		ClipCCW,
+		ClipCW,
+		NoClip,
 		NumStatements
 	};
 	

mercurial