[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40246] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit: fix issue with theme colours not loading correctly in stitch preview during UV synch mode due to theme context switching .

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


Revision: 40246
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40246
Author:   psy-fi
Date:     2011-09-15 19:50:21 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
fix issue with theme colours not loading correctly in stitch preview during UV synch mode due to theme context switching. This was easier than I thought and strangely it is cleaner too. Makes me think why haven't I used this initially?

Modified Paths:
--------------
    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_ops.c

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	2011-09-15 19:40:38 UTC (rev 40245)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c	2011-09-15 19:50:21 UTC (rev 40246)
@@ -894,19 +894,28 @@
 
 			glDisable(GL_BLEND);
 		}
-		glEnableClientState(GL_COLOR_ARRAY);
 
-		glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewOrig);
-		glColorPointer(4, GL_UNSIGNED_BYTE, 0, stitch_preview->previewOrigColors);
 		if(stitch_preview->mode == VERT_STITCH){
 			/* draw vert preview */
 			glPointSize(5.0);
-			glDrawArrays(GL_POINTS, 0, stitch_preview->numOfOrig);
+			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);
 		}
 		else
 		{
 			/* draw edge preview */
-			glDrawArrays(GL_LINES, 0, 2*stitch_preview->numOfOrig);
+			UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewStitchable);
+			glDrawArrays(GL_POINTS, 0, 2*stitch_preview->numOfStitchable);
+
+			UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewUnstitchable);
+			glDrawArrays(GL_POINTS, 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	2011-09-15 19:40:38 UTC (rev 40245)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h	2011-09-15 19:50:21 UTC (rev 40246)
@@ -56,14 +56,13 @@
 	/* ...and here we'll store the triangles*/
 	float *previewTris;
 	/* Preview data.These will be either the previewed vertices or edges depending on tool settings */
-	float *previewOrig;
-	/* Colors for selected vertices */
-	unsigned int *previewOrigColors;
-
+	float *previewStitchable;
+	float *previewUnstitchable;
 	/* here we'll store the number of triangles and quads to be drawn */
 	unsigned int numOfTris;
 	unsigned int numOfQuads;
-	unsigned int numOfOrig;
+	unsigned int numOfStitchable;
+	unsigned int numOfUnstitchable;
 	/* 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 */

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:40:38 UTC (rev 40245)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c	2011-09-15 19:50:21 UTC (rev 40246)
@@ -1338,12 +1338,13 @@
 	_stitch_preview = MEM_mallocN(sizeof(StitchPreviewer), "stitch_previewer");
 	_stitch_preview->previewQuads = NULL;
 	_stitch_preview->previewTris = NULL;
-	_stitch_preview->previewOrig = NULL;
-	_stitch_preview->previewOrigColors = NULL;
+	_stitch_preview->previewStitchable = NULL;
+	_stitch_preview->previewUnstitchable = NULL;
 
 	_stitch_preview->numOfQuads = 0;
 	_stitch_preview->numOfTris = 0;
-	_stitch_preview->numOfOrig = 0;
+	_stitch_preview->numOfStitchable = 0;
+	_stitch_preview->numOfUnstitchable = 0;
 	_stitch_preview->mode = 0;
 
 	_stitch_preview->enabled = 1;
@@ -1365,15 +1366,15 @@
 			MEM_freeN(_stitch_preview->previewTris);
 			_stitch_preview->previewTris = NULL;
 		}
-		if(_stitch_preview->previewOrig)
+		if(_stitch_preview->previewStitchable)
 		{
-			MEM_freeN(_stitch_preview->previewOrig);
-			_stitch_preview->previewOrig = NULL;
+			MEM_freeN(_stitch_preview->previewStitchable);
+			_stitch_preview->previewStitchable = NULL;
 		}
-		if(_stitch_preview->previewOrigColors)
+		if(_stitch_preview->previewUnstitchable)
 		{
-			MEM_freeN(_stitch_preview->previewOrigColors);
-			_stitch_preview->previewOrigColors = NULL;
+			MEM_freeN(_stitch_preview->previewUnstitchable);
+			_stitch_preview->previewUnstitchable = NULL;
 		}
 		MEM_freeN(_stitch_preview);
 		_stitch_preview = NULL;
@@ -1626,7 +1627,7 @@
 
 					/* Add preview only if it hasn't been added already */
 					if(!(element->flag & (STITCH_STITCHABLE | STITCH_PROCESSED))){
-						preview->numOfOrig++;
+						preview->numOfStitchable++;
 					}
 
 					uv_average[averageIndex].count ++;
@@ -1682,7 +1683,7 @@
 							averageIndex2 = el_iter - elementMap->buf;
 							/* Add preview only if it hasn't been added already */
 							if(!(el_iter->flag & (STITCH_STITCHABLE | STITCH_PROCESSED))){
-								preview->numOfOrig++;
+								preview->numOfStitchable++;
 							}
 							el_iter->flag |= STITCH_STITCHABLE;
 							//el_iter->flag |= STITCH_PROCESSED;
@@ -1749,7 +1750,7 @@
 
 					element->flag |= STITCH_PROCESSED;
 					element->flag |= STITCH_EDGE_PREVIEW;
-					preview->numOfOrig++;
+					preview->numOfStitchable++;
 
 					uv_average_tmp[0].count++;
 					uv_average_tmp[1].count++;
@@ -1854,7 +1855,7 @@
 									el_iter2->flag |= STITCH_EDGE_PREVIEW;
 									el_iter2->flag |= STITCH_EDGE_STITCHABLE;
 								}
-								preview->numOfOrig++;
+								preview->numOfStitchable++;
 							}
 						}
 					}
@@ -1943,11 +1944,11 @@
 		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->previewOrig = (float *)MEM_mallocN(preview->numOfOrig*sizeof(float)*2, "stitch_preview_orig_data");
-			preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfOrig*sizeof(unsigned int), "stitch_preview_colors");
+			preview->previewStitchable = (float *)MEM_mallocN(preview->numOfStitchable*sizeof(float)*2, "stitch_preview_orig_data");
+			preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfStitchable*sizeof(unsigned int), "stitch_preview_colors");
 		} else {
-			preview->previewOrig = (float *)MEM_mallocN(preview->numOfOrig*sizeof(float)*4, "stitch_preview_orig_data");
-			preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfOrig*sizeof(unsigned int)*2, "stitch_preview_colors");
+			preview->previewStitchable = (float *)MEM_mallocN(preview->numOfStitchable*sizeof(float)*4, "stitch_preview_orig_data");
+			preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfStitchable*sizeof(unsigned int)*2, "stitch_preview_colors");
 		}
 		/* Copy data from MTFaces to the preview display buffers */
 		for(editFace = state->em->faces.first; editFace; editFace = editFace->next){
@@ -1978,8 +1979,8 @@
 						island_stitch_data[element->island].translation[1] += uv[1] - mt->uv[element->tfindex][1];
 						island_stitch_data[element->island].numOfElements++;
 					}
-					preview->previewOrig[bufferIterator*2] = mt->uv[element->tfindex][0];
-					preview->previewOrig[bufferIterator*2 + 1] = mt->uv[element->tfindex][1];
+					preview->previewStitchable[bufferIterator*2] = mt->uv[element->tfindex][0];
+					preview->previewStitchable[bufferIterator*2 + 1] = mt->uv[element->tfindex][1];
 					/* stitchable uv's will be green, non-stitchable red */
 					UI_GetThemeColor4ubv(TH_STITCH_PREVIEW_STITCHABLE, (unsigned char *)&preview->previewOrigColors[bufferIterator]);
 					bufferIterator++;
@@ -1996,8 +1997,8 @@
 					efa = element->face;
 					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-					preview->previewOrig[bufferIterator*2] = mt->uv[element->tfindex][0];
-					preview->previewOrig[bufferIterator*2 + 1] = mt->uv[element->tfindex][1];
+					preview->previewStitchable[bufferIterator*2] = mt->uv[element->tfindex][0];
+					preview->previewStitchable[bufferIterator*2 + 1] = mt->uv[element->tfindex][1];
 					UI_GetThemeColor4ubv(TH_STITCH_PREVIEW_UNSTITCHABLE, (unsigned char *)&preview->previewOrigColors[bufferIterator]);
 					bufferIterator++;
 				}
@@ -2034,10 +2035,10 @@
 					nverts = (efa->v4)? 4 : 3;
 					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-					preview->previewOrig[bufferIterator*4] = mt->uv[element->tfindex][0];
-					preview->previewOrig[bufferIterator*4 + 1] = mt->uv[element->tfindex][1];
-					preview->previewOrig[bufferIterator*4 + 2] = mt->uv[(element->tfindex + 1)%nverts][0];
-					preview->previewOrig[bufferIterator*4 + 3] = mt->uv[(element->tfindex + 1)%nverts][1];
+					preview->previewStitchable[bufferIterator*4] = mt->uv[element->tfindex][0];
+					preview->previewStitchable[bufferIterator*4 + 1] = mt->uv[element->tfindex][1];
+					preview->previewStitchable[bufferIterator*4 + 2] = mt->uv[(element->tfindex + 1)%nverts][0];
+					preview->previewStitchable[bufferIterator*4 + 3] = mt->uv[(element->tfindex + 1)%nverts][1];
 
 					if(element->flag & STITCH_EDGE_STITCHABLE){
 						UI_GetThemeColor4ubv(TH_STITCH_PREVIEW_STITCHABLE, (unsigned char *)&preview->previewOrigColors[bufferIterator*2]);
@@ -2228,7 +2229,7 @@
 					if(state->snapIslands){
 						island_stitch_data[element_iter->island].addedForPreview = 1;
 					}
-					preview->numOfOrig++;
+					preview->numOfStitchable++;
 				}
 			}
 		}else{
@@ -2241,7 +2242,7 @@
 				if(state->snapIslands){
 					island_stitch_data[element_iter->island].addedForPreview = 1;
 				}
-				preview->numOfOrig++;
+				preview->numOfStitchable++;
 			}
 		}
 	}
@@ -2289,23 +2290,23 @@
 				stitch_setup_preview_for_uv_group(element, state, island_stitch_data);
 			}else{
 				/* Add to preview */
-				preview->numOfOrig++;
+				preview->numOfUnstitchable++;
 			}
 		}
 	}
 
 
 	if(!final){
-		int origBufferIndex = 0;
+		int stitchBufferIndex = 0, unstitchBufferIndex = 0;
 		/* 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");

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list