[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39571] branches/soc-2011-onion/source/ blender/editors/uvedit/uvedit_ops.c: smart stitching

Antony Riakiotakis kalast at gmail.com
Sat Aug 20 21:16:47 CEST 2011


Revision: 39571
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39571
Author:   psy-fi
Date:     2011-08-20 19:16:46 +0000 (Sat, 20 Aug 2011)
Log Message:
-----------
smart stitching
====================
Half-fix for stitch not working in uv synch mode. Still it will need some better fix. Edge stitching does not work correctly in synch mode yet while vertex stitch works as expected.

I have started a re-write of the operator using the techniques developed in the uv paint brushes, though the code is not in this commit, I hope to finish by Monday.

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c

Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c	2011-08-20 17:39:13 UTC (rev 39570)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c	2011-08-20 19:16:46 UTC (rev 39571)
@@ -1529,7 +1529,6 @@
 
 	MTFace *mt;
 	short preview_enabled = preview->enabled;
-	const char FACE_UVS_SELECTED = TF_SEL1 | TF_SEL2 | TF_SEL3 | TF_SEL4;
 
 	/* cleanup previous preview */
 	stitch_preview_delete();
@@ -1564,328 +1563,328 @@
 
 	/* Iterate over all faces and find selected uv's */
 	for(editFace = state->em->faces.first ; editFace; editFace=editFace->next){
+		int vertsPerFace;
+
 		mt = CustomData_em_get(&state->em->fdata, editFace->data, CD_MTFACE);
-		/* if face has any UV's selected... */
-		if(mt->flag & FACE_UVS_SELECTED){
-			int vertsPerFace = editFace->v4 ? 4 : 3;
+		vertsPerFace = editFace->v4 ? 4 : 3;
 
-			for(i = 0; i < vertsPerFace; i++){
-				/************ Vert stitching case **********************/
-				if(state->mode == VERT_STITCH){
-					if(mt->flag & TF_SEL_MASK(i))
+		for(i = 0; i < vertsPerFace; i++){
+			/************ Vert stitching case **********************/
+			if(state->mode == VERT_STITCH){
+				if(uvedit_uv_selected(scene, editFace, mt, i))
+				{
+					int averageIndex;
+					int iter = 0;
+					int iter2;
+					UvElement *el_iter;
+					EditVert *vt = *(&(editFace->v1)+i);
+					/* ...we'll iterate through all shared UV's of the corresponding vertex */
+					el_iter = vmap->vert[vt->tmp.l];
+
+					/* First we need the UVMapVert that corresponds to our uv */
+					for(;el_iter; el_iter =  el_iter->next)
 					{
-						int averageIndex;
-						int iter = 0;
-						int iter2;
-						UvElement *el_iter;
-						EditVert *vt = *(&(editFace->v1)+i);
-						/* ...we'll iterate through all shared UV's of the corresponding vertex */
-						el_iter = vmap->vert[vt->tmp.l];
-
-						/* First we need the UVMapVert that corresponds to our uv */
-						for(;el_iter; el_iter =  el_iter->next)
+						/* Here we assume face does not use the same vertex twice. */
+						if(el_iter->face == editFace)
 						{
-							/* Here we assume face does not use the same vertex twice. */
-							if(el_iter->face == editFace)
-							{
-								/* Assign first UV coincident */
-								element = el_iter;
-								averageIndex = element - vmap->buf;
-							}
+							/* Assign first UV coincident */
+							element = el_iter;
+							averageIndex = element - vmap->buf;
 						}
+					}
 
-						/* Add preview only if it hasn't been added already */
-						if(!(element->flag & (STITCH_STITCHABLE | STITCH_PROCESSED))){
-							preview->numOfOrig++;
-						}
+					/* Add preview only if it hasn't been added already */
+					if(!(element->flag & (STITCH_STITCHABLE | STITCH_PROCESSED))){
+						preview->numOfOrig++;
+					}
 
-						uv_average[averageIndex].count ++;
-						uv_average[averageIndex].uv[0] += mt->uv[i][0];
-						uv_average[averageIndex].uv[1] += mt->uv[i][1];
+					uv_average[averageIndex].count ++;
+					uv_average[averageIndex].uv[0] += mt->uv[i][0];
+					uv_average[averageIndex].uv[1] += mt->uv[i][1];
 
-						for(el_iter = vmap->vert[vt->tmp.l], iter = 0; el_iter; el_iter = el_iter->next){
-							MTFace *tmptface;
+					for(el_iter = vmap->vert[vt->tmp.l], iter = 0; el_iter; el_iter = el_iter->next){
+						MTFace *tmptface;
 
-							if(el_iter == element){
-								continue;
-							}
+						if(el_iter == element){
+							continue;
+						}
 
-							efa = el_iter->face;
-							tmptface = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+						efa = el_iter->face;
+						tmptface = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-							if(fabs((mt->uv[i][0] - tmptface->uv[el_iter->tfindex][0]) < STD_UV_CONNECT_LIMIT) &&
+						if(fabs((mt->uv[i][0] - tmptface->uv[el_iter->tfindex][0]) < STD_UV_CONNECT_LIMIT) &&
 								(fabs(mt->uv[i][1] - tmptface->uv[el_iter->tfindex][1]) < STD_UV_CONNECT_LIMIT))
-							{
-								/* if the uv being iterated is coincident with the original, just add it to be updated later if
-								 * original uv is stitchable */
-								commonVertMaps[iter++] = el_iter;
-							}
-							else if((!state->use_limit) || ( (fabs(mt->uv[i][0] - tmptface->uv[el_iter->tfindex][0]) < state->limitDist
+						{
+							/* if the uv being iterated is coincident with the original, just add it to be updated later if
+							 * original uv is stitchable */
+							commonVertMaps[iter++] = el_iter;
+						}
+						else if((!state->use_limit) || ( (fabs(mt->uv[i][0] - tmptface->uv[el_iter->tfindex][0]) < state->limitDist
 								&& fabs(mt->uv[i][1] - tmptface->uv[el_iter->tfindex][1]) < state->limitDist) ))
-							{
-								commonVertMaps[iter++] = el_iter;
-								element->flag |= STITCH_STITCHABLE;
-								if(el_iter->separate){
-									uv_average[averageIndex].count++;
-									uv_average[averageIndex].uv[0] += tmptface->uv[el_iter->tfindex][0];
-									uv_average[averageIndex].uv[1] += tmptface->uv[el_iter->tfindex][1];
-								}
+						{
+							commonVertMaps[iter++] = el_iter;
+							element->flag |= STITCH_STITCHABLE;
+							if(el_iter->separate){
+								uv_average[averageIndex].count++;
+								uv_average[averageIndex].uv[0] += tmptface->uv[el_iter->tfindex][0];
+								uv_average[averageIndex].uv[1] += tmptface->uv[el_iter->tfindex][1];
 							}
 						}
+					}
 
-						element->flag |= STITCH_PROCESSED;
-						/* here we update coincident uvs */
-						if(element->flag & STITCH_STITCHABLE)
+					element->flag |= STITCH_PROCESSED;
+					/* here we update coincident uvs */
+					if(element->flag & STITCH_STITCHABLE)
+					{
+						/* add original face to preview */
+						if(state->snapIslands){
+							island_stitch_data[element->island].addedForPreview = 1;
+						}
+						else {
+							stitch_update_face_preview_index(editFace, preview);
+						}
+						for(iter2 = 0; iter2 < iter; iter2++)
 						{
-							/* add original face to preview */
+							int averageIndex2;
+							el_iter = commonVertMaps[iter2];
+							efa = el_iter->face;
+							averageIndex2 = el_iter - vmap->buf;
+							/* Add preview only if it hasn't been added already */
+							if(!(el_iter->flag & (STITCH_STITCHABLE | STITCH_PROCESSED))){
+								preview->numOfOrig++;
+							}
+							el_iter->flag |= STITCH_STITCHABLE;
+							//el_iter->flag |= STITCH_PROCESSED;
+
+							uv_average[averageIndex2].count += uv_average[averageIndex].count;
+							uv_average[averageIndex2].uv[0] += uv_average[averageIndex].uv[0];
+							uv_average[averageIndex2].uv[1] += uv_average[averageIndex].uv[1];
 							if(state->snapIslands){
-								island_stitch_data[element->island].addedForPreview = 1;
+								island_stitch_data[el_iter->island].addedForPreview = 1;
 							}
 							else {
-								stitch_update_face_preview_index(editFace, preview);
+								stitch_update_face_preview_index(efa, preview);
 							}
-							for(iter2 = 0; iter2 < iter; iter2++)
-							{
-								int averageIndex2;
-								el_iter = commonVertMaps[iter2];
-								efa = el_iter->face;
-								averageIndex2 = el_iter - vmap->buf;
-								/* Add preview only if it hasn't been added already */
-								if(!(el_iter->flag & (STITCH_STITCHABLE | STITCH_PROCESSED))){
-									preview->numOfOrig++;
-								}
-								el_iter->flag |= STITCH_STITCHABLE;
-								//el_iter->flag |= STITCH_PROCESSED;
-
-								uv_average[averageIndex2].count += uv_average[averageIndex].count;
-								uv_average[averageIndex2].uv[0] += uv_average[averageIndex].uv[0];
-								uv_average[averageIndex2].uv[1] += uv_average[averageIndex].uv[1];
-								if(state->snapIslands){
-									island_stitch_data[el_iter->island].addedForPreview = 1;
-								}
-								else {
-									stitch_update_face_preview_index(efa, preview);
-								}
-							}
 						}
 					}
+				}
 				/****************** Edge stitching case *************************/
-				} else {
-					/* Is this edge selected? */
-					if(mt->flag & TF_SEL_MASK(i))
-					{
-						EditVert *v1, *v2;
-						/* The sep hold the first UVElement coincident with our elements. If edge
-						 * is stitchable we must update all these. */
-						UvElement *el_iter, *element2, *el_sep1, *el_sep2, *iter_sep1, *iter_sep2;
-						float uv1[2][2];
-						int nverts, stack_iter;
-						int stackSize1 = 0;
-						int stackSize2 = 0;
-						int index1, index2;
-						UVVertAverage uv_average_tmp[2];
-						/* need another one of these for each of the 2 verts*/
-						UvElement **commonVertMaps2 = MEM_mallocN(state->em->totface*sizeof(UvElement *), "commonVertMaps2");
+			} else {
+				/* Is this edge selected? */
+				if(uvedit_uv_selected(scene, editFace, mt, i))
+				{
+					EditVert *v1, *v2;
+					/* The sep hold the first UVElement coincident with our elements. If edge
+					 * is stitchable we must update all these. */
+					UvElement *el_iter, *element2, *el_sep1, *el_sep2, *iter_sep1, *iter_sep2;
+					float uv1[2][2];
+					int nverts, stack_iter;
+					int stackSize1 = 0;
+					int stackSize2 = 0;
+					int index1, index2;
+					UVVertAverage uv_average_tmp[2];
+					/* need another one of these for each of the 2 verts*/
+					UvElement **commonVertMaps2 = MEM_mallocN(state->em->totface*sizeof(UvElement *), "commonVertMaps2");
 
-						memset(uv_average_tmp, 0, sizeof(uv_average_tmp));
+					memset(uv_average_tmp, 0, sizeof(uv_average_tmp));
 
-						v1 = *(&editFace->v1 + i);
-						v2 = *(&editFace->v1 + (i + 1)%vertsPerFace);
+					v1 = *(&editFace->v1 + i);
+					v2 = *(&editFace->v1 + (i + 1)%vertsPerFace);
 
-						/* Find the uv element that matches the current face */
-						for(el_iter = vmap->vert[v1->tmp.l]; el_iter; el_iter = el_iter->next){
-							if(el_iter->separate)
-								el_sep1 = el_iter;
-							efa = el_iter->face;
-							nverts = efa->v4 ? 4 : 3;
-							if(efa == editFace){
-								UvElement *el_iter2;
-								element = el_iter;
-								/* Find the uv element for the other uv too */
-								for(el_iter2 = vmap->vert[v2->tmp.l]; el_iter2; el_iter2 = el_iter2->next){
-									if(el_iter2->separate)
-										el_sep2 = el_iter2;
-									if(el_iter2->face == efa){
-										element2 = el_iter2;
-										break;
-									}
+					/* Find the uv element that matches the current face */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list