[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12070] trunk/blender/source/blender: New feature for UV/Editmode - 'Sync Mesh Selection' a button in the UV header this mode is disabled by default.

Campbell Barton cbarton at metavr.com
Mon Sep 17 20:22:06 CEST 2007


Revision: 12070
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12070
Author:   campbellbarton
Date:     2007-09-17 20:22:06 +0200 (Mon, 17 Sep 2007)

Log Message:
-----------
New feature for UV/Editmode - 'Sync Mesh Selection' a button in the UV header this mode is disabled by default.
This is implimented by defining macro's that take the mode into account when get/set/checking the selection and that a face can be drawn.

When this is enabled, things work a bit differently
* all faces are drawn in the UV view (except hidden faces).
* selecting faces/verts in the UV window selects them on the mesh also and vice vercer.
* when EditMode (Face only) is enabled, selecting faces in the UV view is not sticky.
* hiding/(de)select all and invert selection simle call the editmesh functions.
* there is no way to select 1 uv corner of 1 face (because a mesh cannot have this as a valid selection) either all UV's that use a vert (sticky), or the whole face.

Modified Paths:
--------------
    trunk/blender/source/blender/include/BDR_editface.h
    trunk/blender/source/blender/include/BIF_editsima.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/drawimage.c
    trunk/blender/source/blender/src/editface.c
    trunk/blender/source/blender/src/editmesh_mods.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/unwrapper.c

Modified: trunk/blender/source/blender/include/BDR_editface.h
===================================================================
--- trunk/blender/source/blender/include/BDR_editface.h	2007-09-17 15:39:03 UTC (rev 12069)
+++ trunk/blender/source/blender/include/BDR_editface.h	2007-09-17 18:22:06 UTC (rev 12070)
@@ -38,7 +38,7 @@
 struct Mesh;
 struct MCol;
 
-struct MTFace *get_active_mtface(struct EditFace **efa, struct MCol **mcol);
+struct MTFace *get_active_mtface(struct EditFace **efa, struct MCol **mcol, short partsel);
 void calculate_uv_map(unsigned short mapmode);
 void default_uv(float uv[][2], float size);
 void make_tfaces(struct Mesh *me);

Modified: trunk/blender/source/blender/include/BIF_editsima.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editsima.h	2007-09-17 15:39:03 UTC (rev 12069)
+++ trunk/blender/source/blender/include/BIF_editsima.h	2007-09-17 18:22:06 UTC (rev 12070)
@@ -32,9 +32,28 @@
 
 struct Mesh;
 struct EditMesh;
+
+/* id can be from 0 to 3 */
 #define TF_PIN_MASK(id) (TF_PIN1 << id)
 #define TF_SEL_MASK(id) (TF_SEL1 << id)
 
+
+#define SIMA_FACEDRAW_CHECK(efa) \
+	((G.sima->flag & SI_SYNC_UVSEL) ? (efa->h==0) : (efa->h==0 && efa->f & SELECT))
+#define SIMA_FACESEL_CHECK(efa, tf) \
+	((G.sima->flag & SI_SYNC_UVSEL) ? (efa->f & SELECT) : (!(~tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&(!efa->v4 || tf->flag & TF_SEL4)))
+#define SIMA_FACESEL_SET(efa, tf) \
+	((G.sima->flag & SI_SYNC_UVSEL) ? (EM_select_face(efa, 1))	: (tf->flag |=  (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)))
+#define SIMA_FACESEL_UNSET(efa, tf) \
+	((G.sima->flag & SI_SYNC_UVSEL) ? (EM_select_face(efa, 0))	: (tf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)))
+
+#define SIMA_UVSEL_CHECK(efa, tf, i)	(G.sima->flag & SI_SYNC_UVSEL ? \
+	(G.scene->selectmode == SCE_SELECT_FACE ? efa->f & SELECT :		((*(&efa->v1 + i))->f & SELECT) )	: (tf->flag &   TF_SEL_MASK(i) ))
+#define SIMA_UVSEL_SET(efa, tf, i)		(G.sima->flag & SI_SYNC_UVSEL ? \
+	(G.scene->selectmode == SCE_SELECT_FACE ? EM_select_face(efa, 1) : ((*(&efa->v1 + i))->f |=  SELECT) ) : (tf->flag |=  TF_SEL_MASK(i) ))
+#define SIMA_UVSEL_UNSET(efa, tf, i)	(G.sima->flag & SI_SYNC_UVSEL ? \
+	(G.scene->selectmode == SCE_SELECT_FACE ? EM_select_face(efa, 0) : ((*(&efa->v1 + i))->f &= ~SELECT) ) : (tf->flag &= ~TF_SEL_MASK(i) ))
+
 struct Object;
 
 void object_uvs_changed(struct Object *ob);
@@ -88,3 +107,5 @@
 
 /* checks images for forced updates on frame change */
 void BIF_image_update_frame(void);
+
+

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c	2007-09-17 15:39:03 UTC (rev 12069)
+++ trunk/blender/source/blender/src/buttons_editing.c	2007-09-17 18:22:06 UTC (rev 12070)
@@ -4836,7 +4836,7 @@
 	case B_COPY_TF_COL:
 	case B_COPY_TF_TEX:
 		me= get_mesh(OBACT);
-		activetf= get_active_mtface(NULL, &activemcol);
+		activetf= get_active_mtface(NULL, &activemcol, 0);
 
 		if(me && activetf) {
 			for (a=0, tf=me->mtface, mf=me->mface; a < me->totface; a++, tf++, mf++) {
@@ -4890,7 +4890,7 @@
 		break;
 
 	case B_TFACE_HALO:
-		activetf = get_active_mtface(NULL, NULL);
+		activetf = get_active_mtface(NULL, NULL, 0);
 		if(activetf) {
 			activetf->mode &= ~TF_BILLBOARD2;
 			allqueue(REDRAWBUTSEDIT, 0);
@@ -4898,7 +4898,7 @@
 		break;
 
 	case B_TFACE_BILLB:
-		activetf = get_active_mtface(NULL, NULL);
+		activetf = get_active_mtface(NULL, NULL, 0);
 		if(activetf) {
 			activetf->mode &= ~TF_BILLBOARD;
 			allqueue(REDRAWBUTSEDIT, 0);
@@ -5289,7 +5289,7 @@
 	uiNewPanelTabbed("Multires", "Editing");
 	if(uiNewPanel(curarea, block, "Texture Face", "Editing", 960, 0, 318, 204)==0) return;
 	
-	tf = get_active_mtface(NULL, NULL);
+	tf = get_active_mtface(NULL, NULL, 0);
 	if(tf) {
 		uiBlockBeginAlign(block);
 		uiDefButBitS(block, TOG, TF_TEX, B_REDR_3D_IMA, "Tex",	600,160,60,19, &tf->mode, 0, 0, 0, 0, "Render face with texture");

Modified: trunk/blender/source/blender/src/drawimage.c
===================================================================
--- trunk/blender/source/blender/src/drawimage.c	2007-09-17 15:39:03 UTC (rev 12069)
+++ trunk/blender/source/blender/src/drawimage.c	2007-09-17 18:22:06 UTC (rev 12070)
@@ -250,7 +250,7 @@
 		if(sima->image && sima->image->source==IMA_SRC_VIEWER) {}
 		else if (G.obedit == OBACT) {
 			sima->image= NULL;
-			activetf = get_active_mtface(NULL, NULL);
+			activetf = get_active_mtface(NULL, NULL, 1); /* partially selected face is ok */
 			
 			if(activetf && activetf->mode & TF_TEX) {
 				sima->image= activetf->tpage;
@@ -305,7 +305,8 @@
 	}
 
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		if (efa->f & SELECT) {
+		/*if (efa->f & SELECT) {*/
+		if (SIMA_FACEDRAW_CHECK(efa)) {
 			tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 		
 			if(dotile==2) {
@@ -446,7 +447,8 @@
 			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)) {
+				/*if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {*/
+				if (SIMA_FACEDRAW_CHECK(efa)) {
 					tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 					glBegin(GL_LINE_LOOP);
 					glVertex2fv(tface->uv[0]);
@@ -470,10 +472,10 @@
 		glEnable(GL_BLEND);
 		
 		for (efa= em->faces.first; efa; efa= efa->next) {
-			if(efa->f & SELECT) {
+			/*if(efa->f & SELECT) {*/
+			if (SIMA_FACEDRAW_CHECK(efa)) {
 				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))
+				if( SIMA_FACESEL_CHECK(efa, tface) )
 					glColor4ubv((GLubyte *)col2);
 				else
 					glColor4ubv((GLubyte *)col1);
@@ -490,7 +492,8 @@
 	}
 	
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		if (efa->f & SELECT) {
+		/*if (efa->f & SELECT) {*/
+		if (SIMA_FACEDRAW_CHECK(efa)) {
 			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 			
 			cpack(0x0);
@@ -526,7 +529,7 @@
 	/* draw active face edges */
 	/*if (activetface){*/
 		/* colors: R=u G=v */
-	activetface = get_active_mtface(&efa, NULL);
+	activetface = get_active_mtface(&efa, NULL, 0);
 	if (activetface) {
 		setlinestyle(2);
 		tface=activetface; 
@@ -569,13 +572,14 @@
 
 	bglBegin(GL_POINTS);
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		if (efa->f & SELECT) {
+		/*if (efa->f & SELECT) {*/
+		if (SIMA_FACEDRAW_CHECK(efa)) {
 			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(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]);
 			if(efa->v4) {
-				if(tface->flag & TF_SEL4); else bglVertex2fv(tface->uv[3]);
+				if(SIMA_UVSEL_CHECK(efa, tface, 3)); else bglVertex2fv(tface->uv[3]);
 			}
 		}
 	}
@@ -588,7 +592,8 @@
 
 	bglBegin(GL_POINTS);
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		if (efa->f & SELECT) {
+		/*if (efa->f & SELECT) {*/
+		if (SIMA_FACEDRAW_CHECK(efa)) {
 			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
 			if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
 			if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
@@ -606,13 +611,14 @@
 
 	bglBegin(GL_POINTS);
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		if (efa->f & SELECT) {
+		/*if (efa->f & SELECT) {*/
+		if (SIMA_FACEDRAW_CHECK(efa)) {
 			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-			if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
-			if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
-			if(tface->flag & TF_SEL3) bglVertex2fv(tface->uv[2]);
+			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]);
 			if(efa->v4) {
-				if(tface->flag & TF_SEL4) bglVertex2fv(tface->uv[3]);
+				if(!SIMA_UVSEL_CHECK(efa, tface, 3)); else bglVertex2fv(tface->uv[3]);
 			}
 		}
 	}
@@ -683,18 +689,35 @@
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA); 
 	
-	if(G.sima->flag & SI_STICKYUVS) {
-		BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY2_UVS, 1.0f);
+	
+	if (G.sima->flag & SI_SYNC_UVSEL) {
+		/* take settings from the editmesh */
+		if (G.scene->selectmode == SCE_SELECT_FACE) {
+			BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY_UVS, 1.0f);
+		} else {
+			BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY2_UVS, 1.0f);
+		}
 		xPos = 25.0;
+		
+		if (G.scene->selectmode == SCE_SELECT_FACE || G.sima->flag & SI_SELACTFACE) {
+			BIF_icon_draw_aspect(xPos, 5.0, ICON_DRAW_UVFACES, 1.0f);
+		}
+		
+	} else {
+		/* use the flags for UV mode - normal operation */	
+		if(G.sima->flag & SI_STICKYUVS) {
+			BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY2_UVS, 1.0f);
+			xPos = 25.0;
+		}
+		else if(!(G.sima->flag & SI_LOCALSTICKY)) {
+			BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY_UVS, 1.0f);
+			xPos = 25.0;
+		}
+	
+		if(G.sima->flag & SI_SELACTFACE) {
+			BIF_icon_draw_aspect(xPos, 5.0, ICON_DRAW_UVFACES, 1.0f);
+		}
 	}
-	else if(!(G.sima->flag & SI_LOCALSTICKY)) {
-		BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY_UVS, 1.0f);
-		xPos = 25.0;
-	}
-
-	if(G.sima->flag & SI_SELACTFACE) {
-		BIF_icon_draw_aspect(xPos, 5.0, ICON_DRAW_UVFACES, 1.0f);
-	}
 	
 	glBlendFunc(GL_ONE,  GL_ZERO); 
 	glDisable(GL_BLEND);
@@ -768,29 +791,31 @@
 	image_transform_but_attr(&imx, &imy, &step, &digits);
 	
 	for (efa= em->faces.first; efa; efa= efa->next) {
-		if (!(efa->f & SELECT)) continue;
-		tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-		
-		if (tf->flag & TF_SEL1) {
-			cent[0]+= tf->uv[0][0];
-			cent[1]+= tf->uv[0][1];
-			nactive++;
+		/*if ((efa->f & SELECT)) { */
+		if (SIMA_FACEDRAW_CHECK(efa)) {
+			tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+			
+			if (SIMA_UVSEL_CHECK(efa, tf, 0)) {
+				cent[0]+= tf->uv[0][0];
+				cent[1]+= tf->uv[0][1];
+				nactive++;
+			}
+			if (SIMA_UVSEL_CHECK(efa, tf, 1)) {
+				cent[0]+= tf->uv[1][0];
+				cent[1]+= tf->uv[1][1];
+				nactive++;
+			}

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list