[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12099] trunk/blender/source/blender: added draw types for UVs

Campbell Barton cbarton at metavr.com
Fri Sep 21 12:28:04 CEST 2007


Revision: 12099
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12099
Author:   campbellbarton
Date:     2007-09-21 12:28:04 +0200 (Fri, 21 Sep 2007)

Log Message:
-----------
added draw types for UVs
speedup for UV display (the MTFace loopup is only done once and stored in the EditFaces temp pointer)

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/src/drawimage.c
    trunk/blender/source/blender/src/editsima.c

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h	2007-09-20 23:31:58 UTC (rev 12098)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h	2007-09-21 10:28:04 UTC (rev 12099)
@@ -238,12 +238,14 @@
 	short imtypenr, lock;
 	short showspare, pin;
 	float zoom;
+	char dt_uv; char pad[7]; /* UV draw type */
 	
 	float xof, yof;					/* user defined offset, image is centered */
 	float centx, centy;				/* storage for offset while render drawing */
 	
 	char *info_str, *info_spare;	/* info string for render */
 	struct ImBuf *spare;
+	
 } SpaceImage;
 
 typedef struct SpaceNla{
@@ -485,6 +487,7 @@
 		/* this means that the image is drawn until it reaches the view edge,
 		 * in the image view, its unrelated to the 'tile' mode for texface */
 #define SI_DRAW_TILE	1<<19 
+#define SI_SMOOTH_UV	1<<20 
 
 /* SpaceText flags (moved from DNA_text_types.h) */
 

Modified: trunk/blender/source/blender/src/drawimage.c
===================================================================
--- trunk/blender/source/blender/src/drawimage.c	2007-09-20 23:31:58 UTC (rev 12098)
+++ trunk/blender/source/blender/src/drawimage.c	2007-09-21 10:28:04 UTC (rev 12099)
@@ -187,7 +187,6 @@
 {
 	float xim=256, yim=256;
 	float x1, y1;
-	float zoom;
 	
 	if(image_preview_active(curarea, &xim, &yim));
 	else if(sima->image) {
@@ -223,17 +222,14 @@
 
 	x1-= sima->zoom*sima->xof;
 	y1-= sima->zoom*sima->yof;
-
-	/* float! */
-	zoom= sima->zoom;
 	
 	/* relative display right */
-	sima->v2d.cur.xmin= ((curarea->winrct.xmin - (float)x1)/zoom);
-	sima->v2d.cur.xmax= sima->v2d.cur.xmin + ((float)curarea->winx/zoom);
+	sima->v2d.cur.xmin= ((curarea->winrct.xmin - (float)x1)/sima->zoom);
+	sima->v2d.cur.xmax= sima->v2d.cur.xmin + ((float)curarea->winx/sima->zoom);
 	
 	/* relative display left */
-	sima->v2d.cur.ymin= ((curarea->winrct.ymin-(float)y1)/zoom);
-	sima->v2d.cur.ymax= sima->v2d.cur.ymin + ((float)curarea->winy/zoom);
+	sima->v2d.cur.ymin= ((curarea->winrct.ymin-(float)y1)/sima->zoom);
+	sima->v2d.cur.ymax= sima->v2d.cur.ymin + ((float)curarea->winy/sima->zoom);
 	
 	if(mode=='f') {		
 		sima->v2d.cur.xmin/= xim;
@@ -447,7 +443,11 @@
 	setlinestyle(0);
 }
 
-void draw_tfaces(void)
+/* draws uv's in the image space */
+
+
+
+void draw_uvs_sima(void)
 {
 	MTFace *tface,*activetface = NULL;
 	EditMesh *em = G.editMesh;
@@ -491,7 +491,13 @@
 					glVertex2fv(tface->uv[2]);
 					if(efa->v4) glVertex2fv(tface->uv[3]);
 					glEnd();
-				}					
+					
+					
+					efa->tmp.p = tface;
+				} else {
+					efa->tmp.p = NULL;
+				}
+					
 			}
 		}
 	}
@@ -507,8 +513,13 @@
 		glEnable(GL_BLEND);
 		
 		for (efa= em->faces.first; efa; efa= efa->next) {
-			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+			
+//			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+			
+			/*this is a shortcut to do the same as above but a faster for drawing */
+			if ((tface=(MTFace *)efa->tmp.p)) {
+			
 				if( SIMA_FACESEL_CHECK(efa, tface) )
 					glColor4ubv((GLubyte *)col2);
 				else
@@ -524,40 +535,119 @@
 		}
 		glDisable(GL_BLEND);
 	}
-	
-	for (efa= em->faces.first; efa; efa= efa->next) {
-		tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-		if (SIMA_FACEDRAW_CHECK(efa, tface)) {
-			cpack(0x0);
-			glBegin(GL_LINE_LOOP);
-				glVertex2fv(tface->uv[0]);
-				glVertex2fv(tface->uv[1]);
-				glVertex2fv(tface->uv[2]);
-				if(efa->v4) glVertex2fv(tface->uv[3]);
-			glEnd();
-		
-			setlinestyle(2);
-			cpack(0xFFFFFF);
-			glBegin(GL_LINE_STRIP);
-				glVertex2fv(tface->uv[0]);
-				glVertex2fv(tface->uv[1]);
-			glEnd();
 
-			glBegin(GL_LINE_STRIP);
-				glVertex2fv(tface->uv[0]);
-				if(efa->v4) glVertex2fv(tface->uv[3]);
-				else glVertex2fv(tface->uv[2]);
-			glEnd();
+	if (G.sima->flag & SI_SMOOTH_UV) {
+		glEnable( GL_LINE_SMOOTH );
+		glEnable(GL_BLEND);
+		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	}
 
-			glBegin(GL_LINE_STRIP);
-				glVertex2fv(tface->uv[1]);
-				glVertex2fv(tface->uv[2]);
-				if(efa->v4) glVertex2fv(tface->uv[3]);
-			glEnd();
-			setlinestyle(0);
+	switch (G.sima->dt_uv) {
+	case 0:
+		for (efa= em->faces.first; efa; efa= efa->next) {
+//			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+			
+			/*this is a shortcut to do the same as above but a faster for drawing */
+			if ((tface=(MTFace *)efa->tmp.p)) {
+			
+				cpack(0x0);
+				glBegin(GL_LINE_LOOP);
+					glVertex2fv(tface->uv[0]);
+					glVertex2fv(tface->uv[1]);
+					glVertex2fv(tface->uv[2]);
+					if(efa->v4) glVertex2fv(tface->uv[3]);
+				glEnd();
+			
+				setlinestyle(2);
+				cpack(0xFFFFFF);
+				glBegin(GL_LINE_STRIP);
+					glVertex2fv(tface->uv[0]);
+					glVertex2fv(tface->uv[1]);
+				glEnd();
+	
+				glBegin(GL_LINE_STRIP);
+					glVertex2fv(tface->uv[0]);
+					if(efa->v4) glVertex2fv(tface->uv[3]);
+					else glVertex2fv(tface->uv[2]);
+				glEnd();
+	
+				glBegin(GL_LINE_STRIP);
+					glVertex2fv(tface->uv[1]);
+					glVertex2fv(tface->uv[2]);
+					if(efa->v4) glVertex2fv(tface->uv[3]);
+				glEnd();
+				setlinestyle(0);
+			}
 		}
+		break;
+	case 1: /* black/white */
+	case 2: 
+		cpack((G.sima->dt_uv==1) ? 0x0 : 0xFFFFFF);
+		for (efa= em->faces.first; efa; efa= efa->next) {
+//			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+			
+			/*this is a shortcut to do the same as above but a faster for drawing */
+			if ((tface=(MTFace *)efa->tmp.p)) {
+			
+				glBegin(GL_LINE_LOOP);
+					glVertex2fv(tface->uv[0]);
+					glVertex2fv(tface->uv[1]);
+					glVertex2fv(tface->uv[2]);
+					if(efa->v4) glVertex2fv(tface->uv[3]);
+				glEnd();
+			}
+		}
+		break;
+	case 3:
+		glLineWidth(3);
+		cpack(0x0);
+		
+		for (efa= em->faces.first; efa; efa= efa->next) {
+//			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+			
+			/*this is a shortcut to do the same as above but a faster for drawing */
+			if ((tface=(MTFace *)efa->tmp.p)) {
+				
+				glBegin(GL_LINE_LOOP);
+					glVertex2fv(tface->uv[0]);
+					glVertex2fv(tface->uv[1]);
+					glVertex2fv(tface->uv[2]);
+					if(efa->v4) glVertex2fv(tface->uv[3]);
+				glEnd();
+			}
+		}
+		
+		
+		glLineWidth(1);
+		cpack(0xFFFFFF);
+		
+		for (efa= em->faces.first; efa; efa= efa->next) {
+//			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+			
+			/*this is a shortcut to do the same as above but a faster for drawing */
+			if ((tface=(MTFace *)efa->tmp.p)) {
+				
+				glBegin(GL_LINE_LOOP);
+					glVertex2fv(tface->uv[0]);
+					glVertex2fv(tface->uv[1]);
+					glVertex2fv(tface->uv[2]);
+					if(efa->v4) glVertex2fv(tface->uv[3]);
+				glEnd();
+			}
+		}
+		break;
 	}
 
+	if (G.sima->flag & SI_SMOOTH_UV) {
+		glDisable( GL_LINE_SMOOTH);
+		glDisable(GL_BLEND);
+	}
+	
+	
 	/* draw active face edges */
 		/* colors: R=u G=v */
 	activetface = get_active_mtface(&efa, NULL, 0);
@@ -602,8 +692,13 @@
 
 	bglBegin(GL_POINTS);
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-		if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+		
+//		tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//		if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+		
+		/*this is a shortcut to do the same as above but a faster for drawing */
+		if ((tface=(MTFace *)efa->tmp.p)) {
+		
 			if(SIMA_UVSEL_CHECK(efa, tface, 0)); else bglVertex2fv(tface->uv[0]);
 			if(SIMA_UVSEL_CHECK(efa, tface, 1)); else bglVertex2fv(tface->uv[1]);
 			if(SIMA_UVSEL_CHECK(efa, tface, 2)); else bglVertex2fv(tface->uv[2]);
@@ -621,8 +716,12 @@
 
 	bglBegin(GL_POINTS);
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-		if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+//		tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//		if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+		
+		/*this is a shortcut to do the same as above but a faster for drawing */
+		if ((tface=(MTFace *)efa->tmp.p)) {
+			
 			if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
 			if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
 			if(tface->unwrap & TF_PIN3) bglVertex2fv(tface->uv[2]);
@@ -639,8 +738,12 @@
 
 	bglBegin(GL_POINTS);
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-		if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+//		tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+//		if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+		
+		/*this is a shortcut to do the same as above but a faster for drawing */
+		if ((tface=(MTFace *)efa->tmp.p)) {
+		
 			if(!SIMA_UVSEL_CHECK(efa, tface, 0)); else bglVertex2fv(tface->uv[0]);
 			if(!SIMA_UVSEL_CHECK(efa, tface, 1)); else bglVertex2fv(tface->uv[1]);
 			if(!SIMA_UVSEL_CHECK(efa, tface, 2)); else bglVertex2fv(tface->uv[2]);
@@ -924,8 +1027,8 @@
 		}
 		
 		uiBlockBeginAlign(block);
-		uiDefButF(block, NUM, B_CURSOR_IMAGE, "Cursor X:",	165, 60, 145, 19, &ocent[0], -10*imx, 10.0*imx, step, digits, "");
-		uiDefButF(block, NUM, B_CURSOR_IMAGE, "Cursor Y:",	165, 40, 145, 19, &ocent[1], -10*imy, 10.0*imy, step, digits, "");
+		uiDefButF(block, NUM, B_CURSOR_IMAGE, "Cursor X:",	165, 120, 145, 19, &ocent[0], -10*imx, 10.0*imx, step, digits, "");
+		uiDefButF(block, NUM, B_CURSOR_IMAGE, "Cursor Y:",	165, 100, 145, 19, &ocent[1], -10*imy, 10.0*imy, step, digits, "");
 		uiBlockEndAlign(block);
 	}
 	else {	// apply event
@@ -1045,10 +1148,8 @@
 	if(uiNewPanel(curarea, block, "Transform Properties", "Image", 10, 10, 318, 204)==0)
 		return;
 	
-	//uiDefButBitI(block, TOG, SI_COORDFLOATS, B_REDR, "Normalized Coords",	10,80,140,19, &G.sima->flag, 0, 0, 0, 0, "Display coords from 0.0 to 1.0 rather then in pixels");
+	image_editvertex_buts(block);
 	
-	image_editvertex_buts(block);
-	//image_editcursor_buts(block);
 }
 
 static void image_panel_view_properties(short cntrl)	// IMAGE_HANDLER_VIEW_PROPERTIES
@@ -1062,18 +1163,27 @@
 		return;
 	
 	
-	uiDefButBitI(block, TOG, SI_DRAW_TILE, B_REDR, "Repeat Image",	10,100,140,19, &G.sima->flag, 0, 0, 0, 0, "Repeat/Tile the image display");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list