[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43146] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit/uvedit_smart_stitch.c: smart stitch

Antony Riakiotakis kalast at gmail.com
Wed Jan 4 23:14:36 CET 2012


Revision: 43146
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43146
Author:   psy-fi
Date:     2012-01-04 22:14:23 +0000 (Wed, 04 Jan 2012)
Log Message:
-----------
smart stitch
==============

- Select with shift-Right click instead of V, Ctrl-V. It now functions as toggle.
- More edge code cleanup.

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

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_smart_stitch.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_smart_stitch.c	2012-01-04 21:40:00 UTC (rev 43145)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_smart_stitch.c	2012-01-04 22:14:23 UTC (rev 43146)
@@ -408,71 +408,7 @@
 }
 
 
-/* Checks for remote uvs that may be stitched with a certain uv, flags them if stitchable. */
-static void determine_edge_stitchability(UvEdge *edge, StitchState *state, IslandStitchData *island_stitch_data){
-	if(edge->flag & STITCH_BOUNDARY){
-		UvElement *element1 = state->uvs[edge->uv1];
-		UvElement *element2 = state->uvs[edge->uv2];
 
-		UvElement *element_iter1 = state->elementMap->vert[(*(&element1->face->v1 + element1->tfindex))->tmp.l];
-
-		for(;element_iter1; element_iter1 = element_iter1->next){
-			UvElement *element_iter2 = state->elementMap->vert[(*(&element2->face->v1 + element2->tfindex))->tmp.l];
-
-			for(;element_iter2; element_iter2 = element_iter2->next){
-				int uniqueIndex1;
-				int uniqueIndex2;
-				UvEdge tmp_edge, *edge_iter;
-
-				uniqueIndex1 = state->map[element_iter1 - state->elementMap->buf];
-				uniqueIndex2 = state->map[element_iter2 - state->elementMap->buf];
-
-				if(uniqueIndex2 > uniqueIndex1){
-					tmp_edge.uv1 = uniqueIndex1;
-					tmp_edge.uv2 = uniqueIndex2;
-				}else{
-					tmp_edge.uv1 = uniqueIndex2;
-					tmp_edge.uv2 = uniqueIndex1;
-				}
-
-				/* Same edge. If we don't use this, internal edges will always be stitchable */
-				if(tmp_edge.uv1 == edge->uv1 && tmp_edge.uv2 == edge->uv2){
-					continue;
-				}
-
-				edge_iter = (UvEdge *)BLI_ghash_lookup(state->edgeHash, &tmp_edge);
-
-				if(edge_iter && (edge_iter->flag & STITCH_BOUNDARY) && !(edge_iter->flag & STITCH_STITCHABLE)){
-					if(state->use_limit){
-						MTFace *mtface_orig1 = CustomData_em_get(&state->em->fdata, element1->face->data, CD_MTFACE);
-						MTFace *mtface_iter1 = CustomData_em_get(&state->em->fdata, element_iter1->face->data, CD_MTFACE);
-
-						MTFace *mtface_orig2 = CustomData_em_get(&state->em->fdata, element2->face->data, CD_MTFACE);
-						MTFace *mtface_iter2 = CustomData_em_get(&state->em->fdata, element_iter2->face->data, CD_MTFACE);
-
-						if(fabs(mtface_orig1->uv[element1->tfindex][0] - mtface_iter1->uv[element_iter1->tfindex][0]) < state->limitDist
-								&& fabs(mtface_orig1->uv[element1->tfindex][1] - mtface_iter1->uv[element_iter1->tfindex][1]) < state->limitDist
-								&& fabs(mtface_orig2->uv[element2->tfindex][0] - mtface_iter2->uv[element_iter2->tfindex][0]) < state->limitDist
-								&& fabs(mtface_orig2->uv[element2->tfindex][1] - mtface_iter2->uv[element_iter2->tfindex][1]) < state->limitDist){
-							UvElement *element = state->uvs[tmp_edge.uv1];
-
-							island_stitch_data[element1->island].stitchableCandidate = 1;
-							island_stitch_data[element->island].stitchableCandidate = 1;
-							edge->flag |= STITCH_STITCHABLE_CANDIDATE;
-						}
-					}else{
-						UvElement *element = state->uvs[tmp_edge.uv1];
-
-						island_stitch_data[element1->island].stitchableCandidate = 1;
-						island_stitch_data[element->island].stitchableCandidate = 1;
-						edge->flag |= STITCH_STITCHABLE_CANDIDATE;
-					}
-				}
-			}
-		}
-	}
-}
-
 /* Set preview buffer position of UV face in editface->tmp.l */
 static void stitch_set_face_preview_buffer_position(EditFace *efa, StitchPreviewer *preview)
 {
@@ -618,127 +554,6 @@
 				preview->numOfUnstitchable++;
 			}
 		}
-	}else{
-		/****** Uv Edge case *******************/
-		for(i = 0; i < state->selection_size; i++){
-			UvEdge *edge = (UvEdge *)state->selection_stack[i];
-			determine_edge_stitchability(edge, state, island_stitch_data);
-		}
-
-		/* Set static island to one that is added for preview */
-		state->static_island %= state->elementMap->totalIslands;
-		while(!(island_stitch_data[state->static_island].stitchableCandidate)){
-			state->static_island++;
-			state->static_island %= state->elementMap->totalIslands;
-			/* This is entirely possible if for example limit stitching with no stitchable verts or no selection */
-			if(state->static_island == previousIsland)
-				break;
-		}
-
-		for(i = 0; i < state->selection_size; i++){
-			UvEdge *edge = (UvEdge *)state->selection_stack[i];
-
-			if(edge->flag & STITCH_STITCHABLE_CANDIDATE){
-				UvElement *element1 = state->uvs[edge->uv1];
-				UvElement *element2 = state->uvs[edge->uv2];
-
-				UvElement *element_iter1 = state->elementMap->vert[(*(&element1->face->v1 + element1->tfindex))->tmp.l];
-
-				edge->flag &= ~STITCH_STITCHABLE_CANDIDATE;
-
-				for(;element_iter1; element_iter1 = element_iter1->next){
-					UvElement *element_iter2 = state->elementMap->vert[(*(&element2->face->v1 + element2->tfindex))->tmp.l];
-
-					for(;element_iter2; element_iter2 = element_iter2->next){
-						int uniqueIndex1;
-						int uniqueIndex2;
-						UvEdge tmp_edge, *edge_iter;
-
-						uniqueIndex1 = state->map[element_iter1 - state->elementMap->buf];
-						uniqueIndex2 = state->map[element_iter2 - state->elementMap->buf];
-
-						if(uniqueIndex2 > uniqueIndex1){
-							tmp_edge.uv1 = uniqueIndex1;
-							tmp_edge.uv2 = uniqueIndex2;
-						}else{
-							tmp_edge.uv1 = uniqueIndex2;
-							tmp_edge.uv2 = uniqueIndex1;
-						}
-
-						/* Same edge. If we don't use this, internal edges will always be stitchable */
-						if(tmp_edge.uv1 == edge->uv1 && tmp_edge.uv2 == edge->uv2){
-							continue;
-						}
-
-						edge_iter = (UvEdge *)BLI_ghash_lookup(state->edgeHash, &tmp_edge);
-
-						if(edge_iter && (edge_iter->flag & STITCH_BOUNDARY) && !(edge_iter->flag & STITCH_STITCHABLE)){
-							if(state->use_limit){
-								MTFace *mtface_orig1 = CustomData_em_get(&state->em->fdata, element1->face->data, CD_MTFACE);
-								MTFace *mtface_iter1 = CustomData_em_get(&state->em->fdata, element_iter1->face->data, CD_MTFACE);
-
-								MTFace *mtface_orig2 = CustomData_em_get(&state->em->fdata, element2->face->data, CD_MTFACE);
-								MTFace *mtface_iter2 = CustomData_em_get(&state->em->fdata, element_iter2->face->data, CD_MTFACE);
-
-								if(fabs(mtface_orig1->uv[element1->tfindex][0] - mtface_iter1->uv[element_iter1->tfindex][0]) < state->limitDist
-										&& fabs(mtface_orig1->uv[element1->tfindex][1] - mtface_iter1->uv[element_iter1->tfindex][1]) < state->limitDist
-										&& fabs(mtface_orig2->uv[element2->tfindex][0] - mtface_iter2->uv[element_iter2->tfindex][0]) < state->limitDist
-										&& fabs(mtface_orig2->uv[element2->tfindex][1] - mtface_iter2->uv[element_iter2->tfindex][1]) < state->limitDist){
-									UvElement *element_prev1 = state->uvs[tmp_edge.uv1];
-									UvElement *element_prev2 = state->uvs[tmp_edge.uv2];
-
-									if(element_prev1->island == state->static_island || element1->island == state->static_island){
-										stitch_setup_face_preview_for_uv_group(element1, state, island_stitch_data);
-										stitch_setup_face_preview_for_uv_group(element2, state, island_stitch_data);
-										stitch_setup_face_preview_for_uv_group(element_prev1, state, island_stitch_data);
-										stitch_setup_face_preview_for_uv_group(element_prev2, state, island_stitch_data);
-
-										edge->flag |= STITCH_STITCHABLE;
-										edge_iter->flag |= STITCH_STITCHABLE;
-
-										element1->flag |= STITCH_STITCHABLE;
-										element2->flag |= STITCH_STITCHABLE;
-										element_prev1->flag |= STITCH_STITCHABLE;
-										element_prev2->flag |= STITCH_STITCHABLE;
-										preview->numOfStitchable++;
-									}
-								}
-							}else{
-								UvElement *element_prev1 = state->uvs[tmp_edge.uv1];
-								UvElement *element_prev2 = state->uvs[tmp_edge.uv2];
-
-								if(element_prev1->island == state->static_island || element1->island == state->static_island){
-									stitch_setup_face_preview_for_uv_group(element1, state, island_stitch_data);
-									stitch_setup_face_preview_for_uv_group(element2, state, island_stitch_data);
-									stitch_setup_face_preview_for_uv_group(element_prev1, state, island_stitch_data);
-									stitch_setup_face_preview_for_uv_group(element_prev2, state, island_stitch_data);
-
-									edge->flag |= STITCH_STITCHABLE;
-									edge_iter->flag |= STITCH_STITCHABLE;
-
-									element1->flag |= STITCH_STITCHABLE;
-									element2->flag |= STITCH_STITCHABLE;
-									element_prev1->flag |= STITCH_STITCHABLE;
-									element_prev2->flag |= STITCH_STITCHABLE;
-									preview->numOfStitchable++;
-								}
-							}
-						}
-					}
-				}
-				/* Caution here, this is valid only if each group of edges with common verts is traversed once */
-				if(edge->flag & STITCH_STITCHABLE){
-					/* Add to preview */
-					preview->numOfStitchable++;
-				}
-				else{
-					preview->numOfUnstitchable++;
-				}
-			}else{
-				/* Add to preview */
-				preview->numOfUnstitchable++;
-			}
-		}
 	}
 
 //	printf("st %d, ust %d\n",preview->numOfStitchable, preview->numOfUnstitchable);
@@ -849,6 +664,23 @@
 		}
 
 		/* Second pass, propagate changes to stitchable uvs */
+		if(state->snapIslands){
+			for(i = 0; i < state->selection_size; i++){
+				UvElement *element = (UvElement *)state->selection_stack[i];
+				if(element->flag & STITCH_STITCHABLE){
+					MTFace *mt;
+					efa = element->face;
+					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+
+					/* Accumulate each islands' translation from stitchable elements. It is important to do here
+					 * because in final pass MTFaces get modified and result is zero. */
+					island_stitch_data[element->island].translation[0] += averageUvPosition[i].uv[0] - mt->uv[element->tfindex][0];
+					island_stitch_data[element->island].translation[1] += averageUvPosition[i].uv[1] - mt->uv[element->tfindex][1];
+					island_stitch_data[element->island].numOfElements++;
+				}
+			}
+		}
+
 		for(i = 0; i < state->selection_size; i++){
 			UvElement *element = (UvElement *)state->selection_stack[i];
 			if(element->flag & STITCH_STITCHABLE){
@@ -860,13 +692,6 @@
 						efa = element_iter->face;
 						mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-						if(state->snapIslands){
-							/* Accumulate each islands' translation from stitchable elements. It is important to do here

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list