[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12037] trunk/blender/source/blender: 2D Cursor in UV window

Campbell Barton cbarton at metavr.com
Fri Sep 14 18:12:18 CEST 2007


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

Log Message:
-----------
2D Cursor in UV window
this can be placed by the moused and used for transforming around.

still need numeric location input but no room left in the image panel.

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_editsima.h
    trunk/blender/source/blender/include/transform.h
    trunk/blender/source/blender/makesdna/DNA_view2d_types.h
    trunk/blender/source/blender/src/drawimage.c
    trunk/blender/source/blender/src/editsima.c
    trunk/blender/source/blender/src/header_image.c
    trunk/blender/source/blender/src/space.c
    trunk/blender/source/blender/src/transform_conversions.c
    trunk/blender/source/blender/src/transform_generics.c

Modified: trunk/blender/source/blender/include/BIF_editsima.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editsima.h	2007-09-14 13:25:39 UTC (rev 12036)
+++ trunk/blender/source/blender/include/BIF_editsima.h	2007-09-14 16:12:17 UTC (rev 12037)
@@ -49,6 +49,7 @@
 void transform_width_height_tface_uv(int *width, int *height);
 void transform_aspect_ratio_tface_uv(float *aspx, float *aspy);
 
+void mouseco_to_cursor_sima(void);
 void borderselect_sima(short whichuvs);
 void mouseco_to_curtile(void);
 void mouse_select_sima(void);

Modified: trunk/blender/source/blender/include/transform.h
===================================================================
--- trunk/blender/source/blender/include/transform.h	2007-09-14 13:25:39 UTC (rev 12036)
+++ trunk/blender/source/blender/include/transform.h	2007-09-14 16:12:17 UTC (rev 12037)
@@ -422,6 +422,7 @@
 void calculateCenterMedian(TransInfo *t);
 void calculateCenterCursor(TransInfo *t);
 
+void calculateCenterCursor2D(TransInfo *t);
 void calculatePropRatio(TransInfo *t);
 
 void getViewVector(float coord[3], float vec[3]);

Modified: trunk/blender/source/blender/makesdna/DNA_view2d_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_view2d_types.h	2007-09-14 13:25:39 UTC (rev 12036)
+++ trunk/blender/source/blender/makesdna/DNA_view2d_types.h	2007-09-14 16:12:17 UTC (rev 12037)
@@ -45,6 +45,10 @@
 	short keepaspect, keepzoom;
 	short oldwinx, oldwiny;
 	int flag;
+	
+	float cursor[2]; /* only used in the UV view for now*/
+	short around;
+	char pad[6];
 } View2D;
 
 /* v2d->keepzoom */

Modified: trunk/blender/source/blender/src/drawimage.c
===================================================================
--- trunk/blender/source/blender/src/drawimage.c	2007-09-14 13:25:39 UTC (rev 12036)
+++ trunk/blender/source/blender/src/drawimage.c	2007-09-14 16:12:17 UTC (rev 12037)
@@ -367,218 +367,266 @@
 	mval[1]= y;
 }
 
+static void drawcursor_sima(void)
+{
+	int wi, hi;
+	float w, h;
+	
+	transform_width_height_tface_uv(&wi, &hi);
+	w = (((float)wi)/256.0f)*G.sima->zoom;
+	h = (((float)hi)/256.0f)*G.sima->zoom;
+	
+	cpack(0xFFFFFF);
+	glTranslatef(G.v2d->cursor[0], G.v2d->cursor[1], 0.0f);  
+	fdrawline(-0.05/w, 0, 0, 0.05/h);
+	fdrawline(0, 0.05/h, 0.05/w, 0);
+	fdrawline(0.05/w, 0, 0, -0.05/h);
+	fdrawline(0, -0.05/h, -0.05/w, 0);
+	
+	setlinestyle(4);
+	cpack(0xFF);
+	fdrawline(-0.05/w, 0, 0, 0.05/h);
+	fdrawline(0, 0.05/h, 0.05/w, 0);
+	fdrawline(0.05/w, 0, 0, -0.05/h);
+	fdrawline(0, -0.05/h, -0.05/w, 0);
+	
+	
+	setlinestyle(0);
+	cpack(0x0);
+	fdrawline(-0.020/w, 0, -0.1/w, 0);
+	fdrawline(0.1/w, 0, .020/w, 0);
+	fdrawline(0, -0.020/h, 0, -0.1/h);
+	fdrawline(0, 0.1/h, 0, 0.020/h);
+	
+	setlinestyle(1);
+	cpack(0xFFFFFF);
+	fdrawline(-0.020/w, 0, -0.1/w, 0);
+	fdrawline(0.1/w, 0, .020/w, 0);
+	fdrawline(0, -0.020/h, 0, -0.1/h);
+	fdrawline(0, 0.1/h, 0, 0.020/h);
+	
+	glTranslatef(-G.v2d->cursor[0], -G.v2d->cursor[1], 0.0f);
+	setlinestyle(0);
+}
+
 void draw_tfaces(void)
 {
 	MTFace *tface,*activetface = NULL;
 	EditMesh *em = G.editMesh;
 	EditFace *efa;
 	
-	/*int a;*/
 	char col1[4], col2[4];
 	float pointsize= BIF_GetThemeValuef(TH_VERTEX_SIZE);
  	
-	if (G.obedit) {
-		if (CustomData_has_layer(&em->fdata, CD_MTFACE)) {
-			calc_image_view(G.sima, 'f');	/* float */
-			myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
-			glLoadIdentity();
-			
-			/* draw shadow mesh */
-			if ((G.sima->flag & SI_DRAWSHADOW) && (G.obedit==OBACT)) { /* TODO - editmesh */
-				DerivedMesh *dm;
+	if (!G.obedit || !CustomData_has_layer(&em->fdata, CD_MTFACE))
+		return;
+	
+	
+	calc_image_view(G.sima, 'f');	/* float */
+	myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
+	glLoadIdentity();
+	
+	/* draw shadow mesh */
+	if ((G.sima->flag & SI_DRAWSHADOW) && (G.obedit==OBACT)) { /* TODO - editmesh */
+		DerivedMesh *dm;
 
-				/* draw final mesh with modifiers applied */
-				/* should test - editmesh_get_derived_cage_and_final */
-				dm = editmesh_get_derived_base();
+		/* draw final mesh with modifiers applied */
+		/* should test - editmesh_get_derived_cage_and_final */
+		dm = editmesh_get_derived_base();
 
-				glColor3ub(112, 112, 112);
-				if (dm->drawUVEdges) dm->drawUVEdges(dm);
+		glColor3ub(112, 112, 112);
+		if (dm->drawUVEdges) dm->drawUVEdges(dm);
 
-				dm->release(dm);
-			}
-			else if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT)) {
-				/* draw mesh without modifiers applied */
+		dm->release(dm);
+	}
+	else if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT)) {
+		/* draw mesh without modifiers applied */
 
-				if (G.obedit) {		
-					glColor3ub(112, 112, 112);
-					for (efa= em->faces.first; efa; efa= efa->next) {
-						/*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/
-						if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {
-							tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-							glBegin(GL_LINE_LOOP);
-							glVertex2fv(tface->uv[0]);
-							glVertex2fv(tface->uv[1]);
-							glVertex2fv(tface->uv[2]);
-							if(efa->v4) glVertex2fv(tface->uv[3]);
-							glEnd();
-						}					
-					}
-				}
-			}
-
-			if((G.sima->flag & SI_DRAWTOOL) || !(G.obedit==OBACT))
-				return; /* only draw shadow mesh */
-			
-			/* draw transparent faces */
-			if(G.f & G_DRAWFACES) {
-				BIF_GetThemeColor4ubv(TH_FACE, col1);
-				BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
-				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-				glEnable(GL_BLEND);
-				
-				for (efa= em->faces.first; efa; efa= efa->next) {
-					if(efa->f & SELECT) {
-						tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-						if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
-						   (!efa->v4 || tface->flag & TF_SEL4))
-							glColor4ubv((GLubyte *)col2);
-						else
-							glColor4ubv((GLubyte *)col1);
-							
-						glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
-							glVertex2fv(tface->uv[0]);
-							glVertex2fv(tface->uv[1]);
-							glVertex2fv(tface->uv[2]);
-							if(efa->v4) glVertex2fv(tface->uv[3]);
-						glEnd();
-					}
-				}
-				glDisable(GL_BLEND);
-			}
-			
+		if (G.obedit) {		
+			glColor3ub(112, 112, 112);
 			for (efa= em->faces.first; efa; efa= efa->next) {
-				if (efa->f & SELECT) {
+				/*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/
+				if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {
 					tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-					
-					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]);
+					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_DRAWTOOL) || !(G.obedit==OBACT))
+		return; /* only draw shadow mesh */
 	
-					glBegin(GL_LINE_STRIP);
-						glVertex2fv(tface->uv[1]);
-						glVertex2fv(tface->uv[2]);
-						if(efa->v4) glVertex2fv(tface->uv[3]);
-					glEnd();
-					setlinestyle(0);
-				}
-			}
-
-			/* draw active face edges */
-			/*if (activetface){*/
-				/* colors: R=u G=v */
-			activetface = get_active_mtface(&efa, NULL);
-			if (activetface) {
-				setlinestyle(2);
-				tface=activetface; 
-				/*mface=activemface;*/ 
-
-				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();
+	/* draw transparent faces */
+	if(G.f & G_DRAWFACES) {
+		BIF_GetThemeColor4ubv(TH_FACE, col1);
+		BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
+		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+		glEnable(GL_BLEND);
+		
+		for (efa= em->faces.first; efa; efa= efa->next) {
+			if(efa->f & SELECT) {
+				tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+				if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
+				   (!efa->v4 || tface->flag & TF_SEL4))
+					glColor4ubv((GLubyte *)col2);
+				else
+					glColor4ubv((GLubyte *)col1);
 					
-				cpack(0xFF00);
-				glBegin(GL_LINE_STRIP);
+				glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
 					glVertex2fv(tface->uv[0]);
 					glVertex2fv(tface->uv[1]);
-				glEnd();
-
-				cpack(0xFF);
-				glBegin(GL_LINE_STRIP);
-					glVertex2fv(tface->uv[0]);
-					if(efa->v4) glVertex2fv(tface->uv[3]);
-					else glVertex2fv(tface->uv[2]);
-				glEnd();
-
-				cpack(0xFFFFFF);
-				glBegin(GL_LINE_STRIP);
-					glVertex2fv(tface->uv[1]);
 					glVertex2fv(tface->uv[2]);
 					if(efa->v4) glVertex2fv(tface->uv[3]);
 				glEnd();
- 				
-				setlinestyle(0);
 			}
+		}
+		glDisable(GL_BLEND);
+	}
+	
+	for (efa= em->faces.first; efa; efa= efa->next) {
+		if (efa->f & SELECT) {
+			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+			
+			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();
 
-            /* unselected uv's */
-			BIF_ThemeColor(TH_VERTEX);
- 			glPointSize(pointsize);
+			glBegin(GL_LINE_STRIP);
+				glVertex2fv(tface->uv[0]);
+				if(efa->v4) glVertex2fv(tface->uv[3]);
+				else glVertex2fv(tface->uv[2]);
+			glEnd();
 
-			bglBegin(GL_POINTS);
-			for (efa= em->faces.first; efa; efa= efa->next) {
-				if (efa->f & SELECT) {
-					tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-					if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
-					if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
-					if(tface->flag & TF_SEL3); else bglVertex2fv(tface->uv[2]);
-					if(efa->v4) {
-						if(tface->flag & TF_SEL4); else bglVertex2fv(tface->uv[3]);
-					}
-				}
+			glBegin(GL_LINE_STRIP);
+				glVertex2fv(tface->uv[1]);
+				glVertex2fv(tface->uv[2]);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list