[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40244] branches/soc-2011-onion-uv-tools/ source/blender/editors: More stuff to ensure each UV gets added to selection only once.

Antony Riakiotakis kalast at gmail.com
Thu Sep 15 21:32:03 CEST 2011


Revision: 40244
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40244
Author:   psy-fi
Date:     2011-09-15 19:32:02 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
More stuff to ensure each UV gets added to selection only once. Changed the user preferences stuff subversion to 2.61.0. This exposed a bug where, in uv synch mode, the theme color used for previewing verts was lost due to context switch between spaceimage and 3dview. Will rectify asap.

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

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/interface/resources.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/interface/resources.c	2011-09-15 19:01:32 UTC (rev 40243)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/interface/resources.c	2011-09-15 19:32:02 UTC (rev 40244)
@@ -670,7 +670,7 @@
 	SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
 	SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);               // alpha 80 is not meant editable, used for wire+action draw
 	
-	
+
 	/* space buttons */
 	/* to have something initialized */
 	btheme->tbuts= btheme->tv3d;
@@ -1638,7 +1638,7 @@
 		}
 	}
 
-	if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 1)){
+	if (bmain->versionfile < 261){
 		bTheme *btheme;
 		for(btheme= U.themes.first; btheme; btheme= btheme->next) {
 			SETCOLF(btheme->tima.preview_stitch_face, 0.5, 0.5, 0.0, 0.2);

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c	2011-09-15 19:01:32 UTC (rev 40243)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c	2011-09-15 19:32:02 UTC (rev 40244)
@@ -2207,8 +2207,8 @@
 	return 0;
 }
 
-/* registers uvs so that they can be */
-static void stitch_setup_preview_for_uv_group(UvElement *element, StitchState *state){
+/* registers uvs so that they can be shown in preview */
+static void stitch_setup_preview_for_uv_group(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data){
 	StitchPreviewer *preview = uv_get_stitch_previewer();
 
 	UvElement *element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
@@ -2223,9 +2223,11 @@
 				stitch_set_face_preview_buffer_position(element_iter->face, preview);
 
 				uniqueIndex = state->map[element_iter - state->elementMap->buf];
-				state->uvs[uniqueIndex]->flag |= STITCH_STITCHABLE;
-
-				if(element_iter->separate){
+				if(!(state->uvs[uniqueIndex]->flag & STITCH_STITCHABLE)){
+					state->uvs[uniqueIndex]->flag |= STITCH_STITCHABLE;
+					if(state->snapIslands){
+						island_stitch_data[element_iter->island].addedForPreview = 1;
+					}
 					preview->numOfOrig++;
 				}
 			}
@@ -2234,9 +2236,11 @@
 			/* if no limit exists, then the mere existence of a separate uv means that the uv is stitchable */
 			stitch_set_face_preview_buffer_position(element_iter->face, preview);
 			uniqueIndex = state->map[element_iter - state->elementMap->buf];
-			state->uvs[uniqueIndex]->flag |= STITCH_STITCHABLE;
-
-			if(element_iter->separate){
+			if(!(state->uvs[uniqueIndex]->flag & STITCH_STITCHABLE)){
+				state->uvs[uniqueIndex]->flag |= STITCH_STITCHABLE;
+				if(state->snapIslands){
+					island_stitch_data[element_iter->island].addedForPreview = 1;
+				}
 				preview->numOfOrig++;
 			}
 		}
@@ -2265,6 +2269,10 @@
 		efa->tmp.l = -1;
 	}
 
+	if(state->snapIslands){
+		island_stitch_data = MEM_callocN(sizeof(*island_stitch_data)*state->elementMap->totalIslands, "stitch_island_data");
+	}
+
 	/* Store Indices to editVerts. This is not always needed according to current code so using a flag.
 	 * This may be recipe for trouble later though, if something changes. */
 	if(doIndexInit){
@@ -2278,7 +2286,7 @@
 		for(i = 0; i < state->selection_size; i++){
 			UvElement *element = (UvElement *)state->selection_stack[i];
 			if(determine_uv_stitchability(element, state)){
-				stitch_setup_preview_for_uv_group(element, state);
+				stitch_setup_preview_for_uv_group(element, state, island_stitch_data);
 			}else{
 				/* Add to preview */
 				preview->numOfOrig++;
@@ -2300,52 +2308,58 @@
 			preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfOrig*sizeof(unsigned int)*2, "stitch_preview_colors");
 		}
 
-		/* Fill the preview buffers with stitchable only faces */
-		for(i = 0; i < state->numOfSeparateUvs; i++){
-			UvElement *element = (UvElement *)state->uvs[i];
-			if(element->flag & STITCH_STITCHABLE){
-				MTFace *mt;
-				UvElement *element_iter;
+		if(state->mode == VERT_STITCH){
+			/* Fill the preview buffers with stitchable only faces */
+			for(i = 0; i < state->numOfSeparateUvs; i++){
+				UvElement *element = (UvElement *)state->uvs[i];
+				if(element->flag & STITCH_STITCHABLE){
+					MTFace *mt;
+					UvElement *element_iter;
 
-				efa = element->face;
-				mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
-				preview->previewOrig[origBufferIndex*2] = mt->uv[element->tfindex][0];
-				preview->previewOrig[origBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
-				UI_GetThemeColor4ubv(TH_STITCH_PREVIEW_STITCHABLE, (unsigned char *)&preview->previewOrigColors[origBufferIndex++]);
+					efa = element->face;
+					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+					preview->previewOrig[origBufferIndex*2] = mt->uv[element->tfindex][0];
+					preview->previewOrig[origBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
+					UI_GetThemeColor4ubv(TH_STITCH_PREVIEW_STITCHABLE, (unsigned char *)&preview->previewOrigColors[origBufferIndex++]);
 
-				element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
+					element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
 
-				for(element_iter = element; element_iter; element_iter = element_iter->next){
-					/* necessary to avoid cleaning up preview of vertices for common stitchable uvs */
-					if(element_iter->separate && element_iter != element)
-						break;
-					efa = element_iter->face;
-					if(efa->tmp.l != -1)
-					{
-						mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+					for(element_iter = element; element_iter; element_iter = element_iter->next){
+						/* necessary to avoid cleaning up preview of vertices for common stitchable uvs */
+						if(element_iter->separate && element_iter != element)
+							break;
+						efa = element_iter->face;
+						if(efa->tmp.l != -1)
+						{
+							mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-						if(efa->v4) {
-							memcpy(preview->previewQuads+efa->tmp.l, &mt->uv[0][0], 8*sizeof(float));
-						} else {
-							memcpy(preview->previewTris+efa->tmp.l, &mt->uv[0][0], 6*sizeof(float));
+							if(efa->v4) {
+								memcpy(preview->previewQuads+efa->tmp.l, &mt->uv[0][0], 8*sizeof(float));
+							} else {
+								memcpy(preview->previewTris+efa->tmp.l, &mt->uv[0][0], 6*sizeof(float));
+							}
+							/* avoids re-copying */
+							efa->tmp.l = -1;
 						}
 					}
 				}
-			}
-			else if(element->flag & STITCH_SELECTED){
-				MTFace *mt;
-				efa = element->face;
-				mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+				else if(element->flag & STITCH_SELECTED){
+					MTFace *mt;
+					efa = element->face;
+					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-				preview->previewOrig[origBufferIndex*2] = mt->uv[element->tfindex][0];
-				preview->previewOrig[origBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
-				UI_GetThemeColor4ubv(TH_STITCH_PREVIEW_UNSTITCHABLE, (unsigned char *)&preview->previewOrigColors[origBufferIndex++]);
+					preview->previewOrig[origBufferIndex*2] = mt->uv[element->tfindex][0];
+					preview->previewOrig[origBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
+					UI_GetThemeColor4ubv(TH_STITCH_PREVIEW_UNSTITCHABLE, (unsigned char *)&preview->previewOrigColors[origBufferIndex++]);
+				}
+				/* keep only the selection flag */
+				element->flag &= STITCH_SELECTED;
 			}
-			/* keep only the selection flag */
-			element->flag &= STITCH_SELECTED;
 		}
 	}
 
+	if(island_stitch_data)
+		MEM_freeN(island_stitch_data);
 
 	return 1;
 }
@@ -2437,10 +2451,10 @@
 				UvElement *element  = get_uv_element(stitch_state->elementMap, efa, i);
 				uniqueIndex = stitch_state->map[element - stitch_state->elementMap->buf];
 				/* count a uv only once, or duplicates will happen */
-				if(stitch_state->uvs[uniqueIndex]->flag != STITCH_SELECTED){
+				if(!(stitch_state->uvs[uniqueIndex]->flag & STITCH_SELECTED)){
 					stitch_state->selection_stack[stitch_state->selection_size++] = stitch_state->uvs[uniqueIndex];
+					stitch_state->uvs[uniqueIndex]->flag |= STITCH_SELECTED;
 				}
-				stitch_state->uvs[uniqueIndex]->flag = STITCH_SELECTED;
 			}
 		}
 	}
@@ -2455,7 +2469,7 @@
 
 static int stitch_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
-	Object *obedit = CTX_data_edit_object(C);;
+	Object *obedit = CTX_data_edit_object(C);
 	if(!stitch_init(C, op))
 		return OPERATOR_CANCELLED;
 




More information about the Bf-blender-cvs mailing list