[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43142] branches/soc-2011-onion-uv-tools/ source/blender/editors: Smart stitch: refactoring, remove edge vs vertex mode of stitching, keep only vertex.

Antony Riakiotakis kalast at gmail.com
Wed Jan 4 21:51:24 CET 2012


Revision: 43142
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43142
Author:   psy-fi
Date:     2012-01-04 20:51:10 +0000 (Wed, 04 Jan 2012)
Log Message:
-----------
Smart stitch: refactoring, remove edge vs vertex mode of stitching, keep only vertex. I will develop code to detect rotation shortly for vert stitch so edge will be redundant. Also, changed header message.

Modified Paths:
--------------
    branches/soc-2011-onion-uv-tools/source/blender/editors/include/ED_uvedit.h
    branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c
    branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h
    branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_smart_stitch.c

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/include/ED_uvedit.h
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/include/ED_uvedit.h	2012-01-04 20:11:08 UTC (rev 43141)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/include/ED_uvedit.h	2012-01-04 20:51:10 UTC (rev 43142)
@@ -87,8 +87,6 @@
 /* uvedit_buttons.c */
 void ED_uvedit_buttons_register(struct ARegionType *art);
 
-/* uvedit_island_manager.c */
-struct UVIslandManager *ED_get_island_manager_handle(void);
 /* get enable state of island manager */
 int ED_uvedit_island_manager_get_enabled(void);
 /* draw the island manager */

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c	2012-01-04 20:11:08 UTC (rev 43141)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c	2012-01-04 20:51:10 UTC (rev 43142)
@@ -893,29 +893,16 @@
 
 		glDisable(GL_BLEND);
 
+		/* draw vert preview */
+		glPointSize(pointsize*2.0);
+		UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
+		glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewStitchable);
+		glDrawArrays(GL_POINTS, 0, stitch_preview->numOfStitchable);
 
-		if(stitch_preview->mode == VERT_STITCH){
-			/* draw vert preview */
-			glPointSize(pointsize*2.0);
-			UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
-			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewStitchable);
-			glDrawArrays(GL_POINTS, 0, stitch_preview->numOfStitchable);
+		UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
+		glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewUnstitchable);
+		glDrawArrays(GL_POINTS, 0, stitch_preview->numOfUnstitchable);
 
-			UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
-			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewUnstitchable);
-			glDrawArrays(GL_POINTS, 0, stitch_preview->numOfUnstitchable);
-		}
-		else
-		{
-			/* draw edge preview */
-			UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
-			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewStitchable);
-			glDrawArrays(GL_LINES, 0, 2*stitch_preview->numOfStitchable);
-
-			UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
-			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewUnstitchable);
-			glDrawArrays(GL_LINES, 0, 2*stitch_preview->numOfUnstitchable);
-		}
 		glPopClientAttrib();
 		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 	}

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h	2012-01-04 20:11:08 UTC (rev 43141)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h	2012-01-04 20:51:10 UTC (rev 43142)
@@ -41,12 +41,6 @@
 struct wmOperatorType;
 struct UvElementMap;
 
-/*
- * defines for operator stitch modes, usable both for operator and prevewer below
- */
-#define VERT_STITCH 0
-#define EDGE_STITCH 1
-
 /* Object that stores display data for previewing before accepting stitching */
 typedef struct StitchPreviewer {
 	/* OpenGL requires different calls for Triangles and Quads.

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 20:11:08 UTC (rev 43141)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_smart_stitch.c	2012-01-04 20:51:10 UTC (rev 43142)
@@ -210,18 +210,18 @@
 /* This function updates the header of the UV editor when the stitch tool updates its settings */
 static void stitch_update_header(StitchState *stitch_state, bContext *C)
 {
-	static char str[] = "Select(V {+Ctrl deselect}) Toggle(T) %c Vertex %c Edge, %c Limit(L), %c Snap(S), %c  Midpoints(M), (Ctrl+Wheel/-+)Limit Adjust: %.2f, Switch Static Island(I) ";
+	static char str[] = "(S)nap %s, (M)idpoints %s, (L)imit %.2f (Ctrl Wheel adjust) %s, Switch (I)sland, shift select vertices";
+
 	char msg[256];
 	ScrArea *sa= CTX_wm_area(C);
-	char mode = (stitch_state->mode == VERT_STITCH);
 
 	if(sa) {
-		sprintf(msg, str, (mode)? '*':' ',
-				(!mode)? '*':' ',
-				stitch_state->use_limit?'*':' ',
-				stitch_state->snapIslands?'*' :' ',
-				stitch_state->midpoints?'*' :' ' ,
-				stitch_state->limitDist);
+		sprintf(msg, str,
+				stitch_state->snapIslands? "On" : "Off",
+				stitch_state->midpoints? "On": "Off",
+				stitch_state->limitDist,
+				stitch_state->use_limit? "On" : "Off");
+
 		ED_area_headerprint(sa, msg);
 	}
 }
@@ -259,7 +259,7 @@
 		if(island_stitch_data[i].addedForPreview){
 			int numOfIslandUVs = 0, j;
 			/* check to avoid divide by 0 */
-			if(state->mode == EDGE_STITCH){
+			if(0){
 				island_stitch_data[i].rotation /= island_stitch_data[i].numOfEdges;
 				island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfEdges;
 				island_stitch_data[i].medianPoint[1] /= island_stitch_data[i].numOfEdges;
@@ -274,7 +274,7 @@
 					efa = element->face;
 					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 					if(final){
-						if(state->mode == EDGE_STITCH){
+						if(0){
 							stitch_uv_rotate(island_stitch_data[i].rotation, island_stitch_data[i].medianPoint, mt->uv[element->tfindex]);
 						}
 						mt->uv[element->tfindex][0] += island_stitch_data[i].translation[0];
@@ -282,14 +282,14 @@
 					}
 					else if(efa->tmp.l != STITCH_NO_PREVIEW){
 						if(efa->v4){
-							if(state->mode == EDGE_STITCH){
+							if(0){
 								stitch_uv_rotate(island_stitch_data[i].rotation, island_stitch_data[i].medianPoint, &preview->previewQuads[efa->tmp.l + 2*element->tfindex]);
 							}
 							preview->previewQuads[efa->tmp.l + 2*element->tfindex] += island_stitch_data[i].translation[0];
 							preview->previewQuads[efa->tmp.l + 2*element->tfindex + 1] += island_stitch_data[i].translation[1];
 						}
 						else {
-							if(state->mode == EDGE_STITCH){
+							if(0){
 								stitch_uv_rotate(island_stitch_data[i].rotation, island_stitch_data[i].medianPoint, &preview->previewTris[efa->tmp.l + 2*element->tfindex]);
 							}
 							preview->previewTris[efa->tmp.l + 2*element->tfindex]  += island_stitch_data[i].translation[0];
@@ -591,7 +591,7 @@
 	/*****************************************
 	 *  First determine stitchability of uvs *
 	 *****************************************/
-	if(state->mode == VERT_STITCH){
+	if(1){
 		/* Uv Vert case */
 		for(i = 0; i < state->selection_size; i++){
 			UvElement *element = (UvElement *)state->selection_stack[i];
@@ -767,14 +767,11 @@
 		/* Initialize the preview buffers */
 		preview->previewQuads = (float *)MEM_mallocN(preview->numOfQuads*sizeof(float)*8, "quad_uv_stitch_prev");
 		preview->previewTris = (float *)MEM_mallocN(preview->numOfTris*sizeof(float)*6, "tri_uv_stitch_prev");
-		if(state->mode == VERT_STITCH){
-			preview->previewStitchable = (float *)MEM_mallocN(preview->numOfStitchable*sizeof(float)*2, "stitch_preview_stichable_data");
-			preview->previewUnstitchable = (float *)MEM_mallocN(preview->numOfUnstitchable*sizeof(float)*2, "stitch_preview_unstichable_data");
-		} else {
-			preview->previewStitchable = (float *)MEM_mallocN(preview->numOfStitchable*sizeof(float)*4, "stitch_preview_stichable_data");
-			preview->previewUnstitchable = (float *)MEM_mallocN(preview->numOfUnstitchable*sizeof(float)*4, "stitch_preview_unstichable_data");
-		}
 
+		preview->previewStitchable = (float *)MEM_mallocN(preview->numOfStitchable*sizeof(float)*2, "stitch_preview_stichable_data");
+		preview->previewUnstitchable = (float *)MEM_mallocN(preview->numOfUnstitchable*sizeof(float)*2, "stitch_preview_unstichable_data");
+
+
 		/* will cause cancel and freeing of all data structures so OK */
 		if(!preview->previewQuads || !preview->previewTris || !preview->previewStitchable || !preview->previewUnstitchable){
 			return 0;
@@ -794,73 +791,25 @@
 			}
 		}
 		/* Fill the appropriate preview buffers */
-		if(state->mode == VERT_STITCH){
-			for(i = 0; i < state->total_separate_uvs; i++){
-				UvElement *element = (UvElement *)state->uvs[i];
-				if(element->flag & STITCH_STITCHABLE){
-					MTFace *mt;
-					efa = element->face;
-					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+		for(i = 0; i < state->total_separate_uvs; i++){
+			UvElement *element = (UvElement *)state->uvs[i];
+			if(element->flag & STITCH_STITCHABLE){
+				MTFace *mt;
+				efa = element->face;
+				mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-					preview->previewStitchable[stitchBufferIndex*2] = mt->uv[element->tfindex][0];
-					preview->previewStitchable[stitchBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
-					stitchBufferIndex++;
-				}
-				else if(element->flag & STITCH_SELECTED){
-					MTFace *mt;
-					efa = element->face;
-					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
-
-					preview->previewUnstitchable[unstitchBufferIndex*2] = mt->uv[element->tfindex][0];
-					preview->previewUnstitchable[unstitchBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
-					unstitchBufferIndex++;
-				}
+				preview->previewStitchable[stitchBufferIndex*2] = mt->uv[element->tfindex][0];
+				preview->previewStitchable[stitchBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
+				stitchBufferIndex++;
 			}
-		}else{
-			/* Fill the preview buffers with stitchable only uvs */
-			for(i = 0; i < state->total_edges; i++){
-				UvEdge edge = state->edges[i];
+			else if(element->flag & STITCH_SELECTED){
+				MTFace *mt;
+				efa = element->face;
+				mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-				if(edge.flag & STITCH_STITCHABLE){
-					MTFace *mt1, *mt2;
-					EditFace *efa2;
-
-					UvElement *element1 = state->uvs[edge.uv1];
-					UvElement *element2 = state->uvs[edge.uv2];
-
-					efa = element1->face;
-					efa2 = element2->face;
-
-					mt1 = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
-					mt2 = CustomData_em_get(&state->em->fdata, efa2->data, CD_MTFACE);
-
-					preview->previewStitchable[stitchBufferIndex*4] = mt1->uv[element1->tfindex][0];

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list