[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43473] branches/soc-2011-onion-uv-tools/ source/blender: Smart Stitching

Antony Riakiotakis kalast at gmail.com
Tue Jan 17 19:33:09 CET 2012


Revision: 43473
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43473
Author:   psy-fi
Date:     2012-01-17 18:33:08 +0000 (Tue, 17 Jan 2012)
Log Message:
-----------
Smart Stitching
================
*preliminary support for edge stitching.

There are still issues to resolve. This commit reverts to the old behavior of V select Ctrl-V deselect that will be fixed later.

Modified Paths:
--------------
    branches/soc-2011-onion-uv-tools/source/blender/blenkernel/BKE_mesh.h
    branches/soc-2011-onion-uv-tools/source/blender/editors/mesh/editmesh_lib.c
    branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
    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/blenkernel/BKE_mesh.h
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/blenkernel/BKE_mesh.h	2012-01-17 18:32:14 UTC (rev 43472)
+++ branches/soc-2011-onion-uv-tools/source/blender/blenkernel/BKE_mesh.h	2012-01-17 18:33:08 UTC (rev 43473)
@@ -135,11 +135,11 @@
 	/* UvElement Store */
 	struct UvElement *buf;
 	/* Total number of UVs in the layer. Useful to know */
-	int totalUVs;
+	int total_uvs;
 	/* Number of Islands in the mesh */
-	int totalIslands;
+	int total_islands;
 	/* Stores the starting index in buf where each island begins */
-	int *islandIndices;
+	int *island_indices;
 } UvElementMap;
 
 typedef struct UvElement {

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/mesh/editmesh_lib.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/mesh/editmesh_lib.c	2012-01-17 18:32:14 UTC (rev 43472)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/mesh/editmesh_lib.c	2012-01-17 18:33:08 UTC (rev 43473)
@@ -2408,7 +2408,7 @@
 		return NULL;
 	}
 
-	vmap->totalUVs = totuv;
+	vmap->total_uvs = totuv;
 
 	for(efa = em->faces.first; efa; a++, efa = efa->next) {
 		if(!selected || ((!efa->h) && (efa->f & SELECT))) {
@@ -2535,8 +2535,8 @@
 				vmap->vert[i] = &islandbuf[map[vmap->vert[i] - vmap->buf]];
 		}
 
-		vmap->islandIndices = MEM_callocN(sizeof(*vmap->islandIndices)*nislands,"UvVertMap2_island_indices");
-		if(!vmap->islandIndices) {
+		vmap->island_indices = MEM_callocN(sizeof(*vmap->island_indices)*nislands,"UvVertMap2_island_indices");
+		if(!vmap->island_indices) {
 			MEM_freeN(islandbuf);
 			MEM_freeN(stack);
 			MEM_freeN(map);
@@ -2553,14 +2553,14 @@
 
 			if(islandbuf[i].island != j) {
 				j++;
-				vmap->islandIndices[j] = i;
+				vmap->island_indices[j] = i;
 			}
 		}
 
 		MEM_freeN(vmap->buf);
 
 		vmap->buf = islandbuf;
-		vmap->totalIslands = nislands;
+		vmap->total_islands = nislands;
 		MEM_freeN(stack);
 		MEM_freeN(map);
 	}
@@ -2588,7 +2588,7 @@
 	if (vmap) {
 		if (vmap->vert) MEM_freeN(vmap->vert);
 		if (vmap->buf) MEM_freeN(vmap->buf);
-		if (vmap->islandIndices) MEM_freeN(vmap->islandIndices);
+		if (vmap->island_indices) MEM_freeN(vmap->island_indices);
 		MEM_freeN(vmap);
 	}
 }

Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c	2012-01-17 18:32:14 UTC (rev 43472)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c	2012-01-17 18:33:08 UTC (rev 43473)
@@ -502,7 +502,7 @@
 
 
 		/* Count 'unique' uvs */
-		for(i = 0; i < data->elementMap->totalUVs; i++){
+		for(i = 0; i < data->elementMap->total_uvs; i++){
 			if(data->elementMap->buf[i].separate
 			&& (!do_island_optimization || data->elementMap->buf[i].island == island_index)){
 				counter++;
@@ -511,10 +511,10 @@
 
 		/* Allocate the unique uv buffers */
 		data->uv = MEM_mallocN(sizeof(*data->uv)*counter, "uv_brush_unique_uvs");
-		uniqueUv = MEM_mallocN(sizeof(*uniqueUv)*data->elementMap->totalUVs, "uv_brush_unique_uv_map");
+		uniqueUv = MEM_mallocN(sizeof(*uniqueUv)*data->elementMap->total_uvs, "uv_brush_unique_uv_map");
 		edgeHash = BLI_ghash_new(uv_edge_hash, uv_edge_compare, "uv_brush_edge_hash");
 		/* we have at most totalUVs edges */
-		edges = MEM_mallocN(sizeof(*edges)*data->elementMap->totalUVs, "uv_brush_all_edges");
+		edges = MEM_mallocN(sizeof(*edges)*data->elementMap->total_uvs, "uv_brush_all_edges");
 		if(!data->uv || !uniqueUv || !edgeHash || !edges){
 			if(edges){
 				MEM_freeN(edges);

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-17 18:32:14 UTC (rev 43472)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c	2012-01-17 18:33:08 UTC (rev 43473)
@@ -899,16 +899,29 @@
 
 		glDisable(GL_BLEND);
 
-		/* draw vert preview */
-		glPointSize(pointsize*2.0);
-		UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
-		glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_stitchable);
-		glDrawArrays(GL_POINTS, 0, stitch_preview->num_stitchable);
+		if(stitch_preview->mode == STITCH_MODE_VERT){
+			/* draw vert preview */
+			glPointSize(5.0);
+			UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_stitchable);
+			glDrawArrays(GL_POINTS, 0, stitch_preview->num_stitchable);
 
-		UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
-		glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_unstitchable);
-		glDrawArrays(GL_POINTS, 0, stitch_preview->num_unstitchable);
+			UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_unstitchable);
+			glDrawArrays(GL_POINTS, 0, stitch_preview->num_unstitchable);
+		}
+		else
+		{
+			/* draw edge preview */
+			UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_stitchable);
+			glDrawArrays(GL_LINES, 0, 2*stitch_preview->num_stitchable);
 
+			UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
+			glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_unstitchable);
+			glDrawArrays(GL_LINES, 0, 2*stitch_preview->num_unstitchable);
+		}
+
 		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-17 18:32:14 UTC (rev 43472)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h	2012-01-17 18:33:08 UTC (rev 43473)
@@ -72,6 +72,10 @@
 
 /* smart stitch */
 
+#define STITCH_MODE_VERT 0
+#define STITCH_MODE_EDGE 1
+#define STITCH_MODE_UNINITIALISED 2
+
 /* object that stores display data for previewing before accepting stitching */
 typedef struct StitchPreviewer {
 	/* OpenGL requires different calls for Triangles and Quads.
@@ -94,6 +98,8 @@
 	float *static_tris;
 	unsigned int num_static_tris;
 	unsigned int num_static_quads;
+	/* edge or vert mode */
+	char mode;
 } StitchPreviewer;
 
 StitchPreviewer *uv_get_stitch_previewer(void);

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-17 18:32:14 UTC (rev 43472)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_smart_stitch.c	2012-01-17 18:33:08 UTC (rev 43473)
@@ -1,3 +1,4 @@
+
 /*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
@@ -8,7 +9,7 @@
  *
  * 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
+ * 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
@@ -26,7 +27,7 @@
  */
 
 /** \file blender/editors/uvedit/uvedit_stitch.c
- *  \ingroup eduv
+ * \ingroup eduv
  */
 
 
@@ -37,23 +38,36 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_object_types.h"
+#include "DNA_material_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_node_types.h"
 #include "DNA_scene_types.h"
 
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
 #include "BLI_editVert.h"
+#include "BLI_utildefines.h"
 #include "BLI_ghash.h"
-#include "BLI_math.h"
-#include "BLI_math_vector.h"
-#include "BLI_string.h"
 
 #include "BKE_context.h"
 #include "BKE_customdata.h"
 #include "BKE_depsgraph.h"
+#include "BKE_image.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
 #include "BKE_mesh.h"
+#include "BKE_node.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
 
+#include "ED_image.h"
 #include "ED_mesh.h"
+#include "ED_node.h"
 #include "ED_uvedit.h"
+#include "ED_object.h"
 #include "ED_screen.h"
+#include "ED_transform.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -62,6 +76,7 @@
 #include "WM_types.h"
 
 #include "UI_view2d.h"
+#include "UI_resources.h"
 
 #include "uvedit_intern.h"
 
@@ -83,7 +98,9 @@
 	/* Flag to remember if island has been added for preview */
 	char addedForPreview;
 	/* Flag an island to be considered for determining static island */
-	char stitchableCandidate;
+	char candidate;
+	/* remember if edge rotation has been used to skip doing vertex rotation */
+	char used_edge_rotation;
 }IslandStitchData;
 
 /* just for averaging UVs */
@@ -102,9 +119,12 @@
 	UvElement *element;
 }UvEdge;
 
+#define STITCHNEW
 
 /* stitch state object */
 typedef struct StitchState {
+	/* edge or vertex stitch mode */
+	char mode;
 	/* use limit flag */
 	char use_limit;
 	/* limit to operator, same as original operator */
@@ -117,25 +137,27 @@
 	EditMesh *em;
 	/* element map for getting info about uv connectivity */
 	UvElementMap *element_map;
-	/* edge container */
+	/* Edge container */
 	UvEdge *uvedges;
 	/* container of first of a group of coincident uvs, these will be operated upon */
 	UvElement **uvs;
+	int total_separate_uvs;
 	/* maps uvelements to their first coincident uv */
 	int *map;
-	/* 2D normals per uv to calculate rotation for snapping */
-	float *normals;
-	/* edge storage */
-	UvEdge *edges;
-
-	/* count of separate uvs and edges */
-	int total_boundary_edges;
-	int total_separate_uvs;
 	/* hold selection related information */
-	UvElement **selection_stack;
+	void **selection_stack;
 	int selection_size;
 	/* island that stays in place */
 	int static_island;
+	/* For fast edge lookup... */
+	GHash *edgeHash;
+	/* ...And actual edge storage */
+	UvEdge *edges;
+	int total_edges;
+	/* 2D normals per uv to calculate rotation for snapping */
+	float *normals;
+
+
 	/* store number of primitives per face so that we can allocate the active island buffer later */
 	unsigned int *quads_per_island;
 	unsigned int *tris_per_island;
@@ -153,12 +175,12 @@
 
 #define STITCH_NO_PREVIEW -1
 

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list