[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40278] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit: Resurrected snap islands for stitching uv vertices.

Antony Riakiotakis kalast at gmail.com
Sat Sep 17 02:57:02 CEST 2011


Revision: 40278
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40278
Author:   psy-fi
Date:     2011-09-17 00:57:02 +0000 (Sat, 17 Sep 2011)
Log Message:
-----------
Resurrected snap islands for stitching uv vertices. After a thought session it may be possible to add rotation even in this mode but it will have to wait for a while. Also added some placeholder code for different behavior where one islands stays in place. Also added some properties to uvedit/uvedit_island_manager.c file though I don't think I will code through that feature.

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

Property Changed:
----------------
    branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_island_manager.c

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_island_manager.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_island_manager.c	2011-09-16 22:03:46 UTC (rev 40277)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_island_manager.c	2011-09-17 00:57:02 UTC (rev 40278)
@@ -1,63 +1,63 @@
-/*
- * $Id: uvedit_island_manager.c 38360 2011-07-01 12:06:32Z psy-fi $
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- *
- * Contributor(s): Antony Riakiotakis, Blender Foundation, 2002-2009
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/uvedit/uvedit_island_manager.cpp
- *  \ingroup eduv
- */
-
-#include "GL/glew.h"
-#include  "DNA_scene_types.h"
-
-#include "ED_image.h"
-#include "ED_uvedit.h"
-
-
-
-static UVIslandManager _island_manager;
-
-/* get enable state of island manager */
-int ED_uvedit_island_manager_get_enabled(void)
-{
-	/* in uvedit_island_manager */
-	return _island_manager.active;
-}
-
-UVIslandManager *ED_get_island_manager_handle(void)
-{
-	return (&_island_manager);
-}
-
-void ED_uvedit_island_manager_draw(void)
-{
-
-}
-
-static void draw_UV_island_cell(UVIslandComponent *cell)
-{
-
-}
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Antony Riakiotakis, Blender Foundation, 2002-2009
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/uvedit/uvedit_island_manager.cpp
+ *  \ingroup eduv
+ */
+
+#include "GL/glew.h"
+#include  "DNA_scene_types.h"
+
+#include "ED_image.h"
+#include "ED_uvedit.h"
+
+
+
+static UVIslandManager _island_manager;
+
+/* get enable state of island manager */
+int ED_uvedit_island_manager_get_enabled(void)
+{
+	/* in uvedit_island_manager */
+	return _island_manager.active;
+}
+
+UVIslandManager *ED_get_island_manager_handle(void)
+{
+	return (&_island_manager);
+}
+
+void ED_uvedit_island_manager_draw(void)
+{
+
+}
+
+static void draw_UV_island_cell(UVIslandComponent *cell)
+{
+
+}


Property changes on: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_island_manager.c
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

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-16 22:03:46 UTC (rev 40277)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c	2011-09-17 00:57:02 UTC (rev 40278)
@@ -1311,6 +1311,8 @@
 	/* hold selection related information */
 	void **selection_stack;
 	int selection_size;
+	/* island that stays in place */
+	int static_island;
 #endif
 } StitchState;
 
@@ -1328,6 +1330,7 @@
 #else
 #define STITCH_SELECTED 1
 #define STITCH_STITCHABLE 2
+#define STITCH_PROCESSED 4
 #endif
 /* Previewer stuff (see uvedit_intern.h for more info) */
 static StitchPreviewer *_stitch_preview;
@@ -1391,7 +1394,7 @@
 /* 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}) Mode(M): %c Vertex  %c Edge  %c Preview(P)  %c Limit(L)  %c Snap(S)  Ctrl+Wheel(limit adjust): %f";
+	static char str[] = "Select(V {+Ctrl deselect}) Mode(M): %c Vertex  %c Edge  %c Preview(P)  %c Limit(L)  %c Snap(S)  Ctrl+Wheel(limit adjust): %f  Static Island(I): %d";
 	char msg[256];
 	ScrArea *sa= CTX_wm_area(C);
 	char mode = (stitch_state->mode == VERT_STITCH);
@@ -1402,7 +1405,8 @@
 				uv_get_stitch_previewer()->enabled?'*':' ',
 				stitch_state->use_limit?'*':' ',
 				stitch_state->snapIslands?'*' :' ',
-				stitch_state->limitDist);
+				stitch_state->limitDist,
+				stitch_state->static_island + 1);
 		ED_area_headerprint(sa, msg);
 	}
 }
@@ -1423,6 +1427,14 @@
 	}
 }
 
+static int getNumOfIslandUvs(UvElementMap *elementMap, int island){
+	if(island == elementMap->totalIslands-1){
+		return elementMap->totalUVs - elementMap->islandIndices[island];
+	}else{
+		return elementMap->islandIndices[island+1] - elementMap->islandIndices[island];
+	}
+}
+
 static void stitch_uv_rotate(float rotation, float medianPoint[2], float uv[2]){
 	float uv_rotation_result[2];
 
@@ -1446,7 +1458,7 @@
 
 	for(i = 0; i <  state->elementMap->totalIslands; i++){
 		if(island_stitch_data[i].addedForPreview){
-			int previewIslandUVs = 0, j;
+			int numOfIslandUVs = 0, j;
 			/* check to avoid divide by 0 */
 			if(state->mode == EDGE_STITCH){
 				island_stitch_data[i].rotation /= island_stitch_data[i].numOfEdges;
@@ -1455,15 +1467,11 @@
 			}
 			island_stitch_data[i].translation[0] /= island_stitch_data[i].numOfElements;
 			island_stitch_data[i].translation[1] /= island_stitch_data[i].numOfElements;
-			if(i == state->elementMap->totalIslands-1){
-				previewIslandUVs = state->elementMap->totalUVs - state->elementMap->islandIndices[i];
-			}else{
-				previewIslandUVs = state->elementMap->islandIndices[i+1] - state->elementMap->islandIndices[i];
-			}
+			numOfIslandUVs = getNumOfIslandUvs(state->elementMap, i);
 			element = &state->elementMap->buf[state->elementMap->islandIndices[i]];
-			for(j = 0; j < previewIslandUVs; j++, element++){
+			for(j = 0; j < numOfIslandUVs; j++, element++){
 				/* stitchable uvs have already been processed, don't process */
-				if(!(element->flag & STITCH_STITCHABLE)){
+				if(!(element->flag & STITCH_PROCESSED)){
 					efa = element->face;
 					mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 					if(final){
@@ -1490,7 +1498,8 @@
 						}
 					}
 				}
-				element->flag = 0;
+				/* cleanup */
+				element->flag &= STITCH_SELECTED;
 			}
 		}
 	}
@@ -2249,7 +2258,7 @@
 }
 
 /* Main processing function. It calculates preview and final positions. */
-static int stitch_process_data(StitchState *state, int final, int doIndexInit)
+static int stitch_process_data(StitchState *state, Scene *scene, int final, int doIndexInit)
 {
 	int i;
 	StitchPreviewer *preview = uv_get_stitch_previewer();
@@ -2299,6 +2308,22 @@
 			}
 		}
 	}
+	/*****************************************
+	 *  Setup preview for stitchable islands *
+	 *****************************************/
+	if(state->snapIslands){
+		for(i = 0; i <  state->elementMap->totalIslands; i++){
+			if(island_stitch_data[i].addedForPreview){
+				int numOfIslandUVs = 0, j;
+				UvElement *element;
+				numOfIslandUVs = getNumOfIslandUvs(state->elementMap, i);
+				element = &state->elementMap->buf[state->elementMap->islandIndices[i]];
+				for(j = 0; j < numOfIslandUVs; j++, element++){
+					stitch_set_face_preview_buffer_position(element->face, preview);
+				}
+			}
+		}
+	}
 
 	/*********************************************************************
 	 * Setup the preview buffers and fill them with the appropriate data *
@@ -2320,38 +2345,31 @@
 			return 0;
 		}
 
+		/* Copy data from MTFaces to the preview display buffers */
+		for(efa = state->em->faces.first; efa; efa = efa->next){
+			if(efa->tmp.l != -1)
+			{
+				MTFace *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(state->mode == VERT_STITCH){
-			/* Fill the preview buffers with stitchable only faces */
+			/* Fill the preview buffers with stitchable only uvs */
 			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->previewStitchable[stitchBufferIndex*2] = mt->uv[element->tfindex][0];
 					preview->previewStitchable[stitchBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
 					stitchBufferIndex++;
-
-					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);
-
-							if(efa->v4) {
-								memcpy(preview->previewQuads+efa->tmp.l, &mt->uv[0][0], 8*sizeof(float));
-							} else {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list