[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37964] branches/soc-2011-onion/source/ blender/editors/uvedit: smart stitch - more edge stuff, and a change in select behavior.

Antony Riakiotakis kalast at gmail.com
Thu Jun 30 01:52:10 CEST 2011


Revision: 37964
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37964
Author:   psy-fi
Date:     2011-06-29 23:52:09 +0000 (Wed, 29 Jun 2011)
Log Message:
-----------
smart stitch - more edge stuff, and a change in select behavior. Now only one common uv can be selected in vertex mode or stitching behavior will be dependent on the order of face processing. This also has a nice side-effect: It is now possible to deselect the non-selected stitchable uv and it clears the selection completely.

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

Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_draw.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_draw.c	2011-06-29 20:22:14 UTC (rev 37963)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_draw.c	2011-06-29 23:52:09 UTC (rev 37964)
@@ -866,11 +866,20 @@
 			glDisable(GL_BLEND);
 		}
 		glEnableClientState(GL_COLOR_ARRAY);
-		glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewPoints);
-		glColorPointer(4, GL_UNSIGNED_BYTE, 0, stitch_preview->previewPointColors);
-		glPointSize(5.0);
-		glDrawArrays(GL_POINTS, 0, stitch_preview->numOfPoints);
-
+		if(stitch_preview->mode == VERT_STITCH){
+			/* draw vert preview */
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewOrig);
+			glColorPointer(4, GL_UNSIGNED_BYTE, 0, stitch_preview->previewOrigColors);
+			glPointSize(5.0);
+			glDrawArrays(GL_POINTS, 0, stitch_preview->numOfOrig);
+		}
+		else
+		{
+			/* draw edge preview */
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewOrig);
+			glColorPointer(4, GL_UNSIGNED_BYTE, 0, stitch_preview->previewOrigColors);
+			glDrawArrays(GL_LINES, 0, stitch_preview->numOfOrig);
+		}
 		glPopClientAttrib();
 		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 	}

Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h	2011-06-29 20:22:14 UTC (rev 37963)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h	2011-06-29 23:52:09 UTC (rev 37964)
@@ -42,6 +42,12 @@
 struct Object;
 struct wmOperatorType;
 
+/*
+ * defines for operator stitch modes, usable both for operator and prevewer below
+ */
+#define VERT_STITCH 1
+#define EDGE_STITCH 2
+
 /* Object that stores display data for previewing before accepting stitching */
 typedef struct StitchPreviewer {
 	/* OpenGL requires different calls for Triangles and Quads.
@@ -49,20 +55,19 @@
 	float *previewQuads;
 	/* ...and here we'll store the triangles*/
 	float *previewTris;
-	/* Preview points.These will be the previewed vertices */
-	float *previewPoints;
-	/* Preview edges, for previewed edges */
-	float *previewEdges;
+	/* Preview data.These will be either the previewed vertices or edges depending on tool settings */
+	float *previewOrig;
 	/* Colors for selected vertices */
-	unsigned int *previewPointColors;
+	unsigned int *previewOrigColors;
 
 	/* here we'll store the number of triangles and quads to be drawn */
 	unsigned int numOfTris;
 	unsigned int numOfQuads;
-	unsigned int numOfPoints;
-	unsigned int numOfEdges;
+	unsigned int numOfOrig;
 	/* stores whether user desires preview display */
 	char enabled;
+	/* vertex or edge preview. Store it here too because operator will not be available in draw code */
+	char mode;
 } StitchPreviewer;
 
 /* id can be from 0 to 3 */

Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c	2011-06-29 20:22:14 UTC (rev 37963)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c	2011-06-29 23:52:09 UTC (rev 37964)
@@ -1140,48 +1140,32 @@
 	UvVertMap2 *vmap;
 } StitchState;
 
-/*
- * defines for operator
- */
-#define VERT_STITCH 1
-#define EDGE_STITCH 2
 
 /*
  * defines for UvMapVert flags
  */
 #define STITCH_PROCESSED 1
 #define STITCH_STITCHABLE 2
-#define STITCH_SELECTED	4
-#define STITCH_EDGE_PLUS 8
-#define STITCH_UV_SELECTED 16
+#define STITCH_EDGE_PREVIEW 4
+#define STITCH_FOR_STITCHING 8
 
+
 /* Previewer stuff (see uvedit_intern.h for more info) */
 static StitchPreviewer *_stitch_preview;
 
-typedef struct EdgeStitchData {
-	/* each edge corresponds to a UVVertMap, This is a hack I know, but essentially the same data
-	 * will be used anyway */
-	int vmapPosition;
-	/* indices to uvVertmap for fast access */
-	int uvVertMap1Index, uvVertMap2Index;
-	/* */
-
-}EdgeStitchData;
-
 /* constructor */
 static StitchPreviewer * stitch_preview_init(void)
 {
 	_stitch_preview = MEM_mallocN(sizeof(StitchPreviewer), "stitch_previewer");
 	_stitch_preview->previewQuads = NULL;
 	_stitch_preview->previewTris = NULL;
-	_stitch_preview->previewEdges = NULL;
-	_stitch_preview->previewPoints = NULL;
-	_stitch_preview->previewPointColors = NULL;
+	_stitch_preview->previewOrig = NULL;
+	_stitch_preview->previewOrigColors = NULL;
 
 	_stitch_preview->numOfQuads = 0;
 	_stitch_preview->numOfTris = 0;
-	_stitch_preview->numOfPoints = 0;
-	_stitch_preview->numOfEdges = 0;
+	_stitch_preview->numOfOrig = 0;
+	_stitch_preview->mode = 0;
 
 	_stitch_preview->enabled = 1;
 	return _stitch_preview;
@@ -1202,21 +1186,16 @@
 			MEM_freeN(_stitch_preview->previewTris);
 			_stitch_preview->previewTris = NULL;
 		}
-		if(_stitch_preview->previewPoints)
+		if(_stitch_preview->previewOrig)
 		{
-			MEM_freeN(_stitch_preview->previewPoints);
-			_stitch_preview->previewPoints = NULL;
+			MEM_freeN(_stitch_preview->previewOrig);
+			_stitch_preview->previewOrig = NULL;
 		}
-		if(_stitch_preview->previewPointColors)
+		if(_stitch_preview->previewOrigColors)
 		{
-			MEM_freeN(_stitch_preview->previewPointColors);
-			_stitch_preview->previewPointColors = NULL;
+			MEM_freeN(_stitch_preview->previewOrigColors);
+			_stitch_preview->previewOrigColors = NULL;
 		}
-		if(_stitch_preview->previewEdges)
-		{
-			MEM_freeN(_stitch_preview->previewEdges);
-			_stitch_preview->previewEdges = NULL;
-		}
 		MEM_freeN(_stitch_preview);
 		_stitch_preview = NULL;
 	}
@@ -1255,13 +1234,16 @@
 	StitchPreviewer *preview = uv_get_stitch_previewer();
 	UVVertAverage *uv_average;
 	UvVertMap2 *vmap = state->vmap;
-	UvElement *element = vmap->buf;
+	UvElement *element;
 	int i;
-	int numOfEdges = 0;
 	int bufferIterator = 0;
-	EditFace *editFace, *efa, **faceArray;
+	EditFace *editFace, *efa;
+	//**faceArray;
 	EditVert *editVert;
 	EditEdge *editEdge;
+	/* This holds uv's that must be updated if the initial uv is stitchable. */
+	UvElement **commonVertMaps;
+
 	MTFace *mt;
 	short preview_enabled = preview->enabled;
 	const char FACE_UVS_SELECTED = TF_SEL1 | TF_SEL2 | TF_SEL3 | TF_SEL4;
@@ -1272,7 +1254,7 @@
 	if(preview == NULL)
 		return OPERATOR_CANCELLED;
 	preview->enabled = preview_enabled;
-
+	preview->mode = state->mode;
 	/* UV average is stored for every UV since potentially every UV can be stitched with another. Highly unlikely, I know but possible
 	 * nevertheless :p */
 	uv_average = (UVVertAverage *)MEM_callocN(state->vmap->numOfUVs*sizeof(UVVertAverage), "stitch_averages");
@@ -1289,12 +1271,6 @@
 			editFace->tmp.l = -1;
 		}
 
-
-	/* Vertex stitching case */
-	if(state->mode == VERT_STITCH){
-		/* This holds uv's that must be updated if the initial uv is stitchable. */
-		UvElement **commonVertMaps;
-
 		/* The maximum number of faces that a UV can be part of is totfaces. We allocate this here to avoid allocating
 		* this too many times on the fly */
 		commonVertMaps = MEM_mallocN(state->em->totface*sizeof(UvElement *), "commonVertMaps");
@@ -1308,110 +1284,224 @@
 				int vertsPerFace = editFace->v4 ? 4 : 3;
 
 				for(i = 0; i < vertsPerFace; i++){
-					if(mt->flag & TF_SEL_MASK(i))
-					{
-						int averageIndex;
-						int iter = 0;
-						int iter2;
-						UvElement *mv_iter;
-						EditVert *vt = *(&(editFace->v1)+i);
-						/* ...we'll iterate through all shared UV's of the corresponding vertex */
-						mv_iter = vmap->vert[vt->tmp.l];
-						/* Original vertex will be previewed, of course */
-						preview->numOfPoints++;
+					/************ Vert stitching case **********************/
+					if(state->mode == VERT_STITCH){
+						if(mt->flag & TF_SEL_MASK(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];
+							/* Original vertex will be previewed, of course */
+							preview->numOfOrig++;
 
-						/* First we need the UVMapVert that corresponds to our uv */
-						for(;mv_iter; mv_iter =  mv_iter->next)
-						{
-							/* Here we assume face does not use the same vertex twice. */
-							if(mv_iter->face == editFace)
+							/* First we need the UVMapVert that corresponds to our uv */
+							for(;el_iter; el_iter =  el_iter->next)
 							{
-								/* Assign first UV coincident */
-								element = mv_iter;
-								averageIndex = element - vmap->buf;
+								/* 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;
+								}
 							}
-						}
 
-						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(mv_iter = vmap->vert[vt->tmp.l], iter = 0; mv_iter; mv_iter = mv_iter->next){
-							MTFace *tmptface;
+							for(el_iter = vmap->vert[vt->tmp.l], iter = 0; el_iter; el_iter = el_iter->next){
+								MTFace *tmptface;
 
-							if(mv_iter == element){
-								continue;
-							}
+								if(el_iter == element){
+									continue;
+								}
 
-							efa = mv_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[mv_iter->tfindex][0]) < STD_UV_CONNECT_LIMIT) &&
-								(fabs(mt->uv[i][1] - tmptface->uv[mv_iter->tfindex][1]) < 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++] = mv_iter;
-							} else {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list