[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43172] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit/uvedit_smart_stitch.c: smart stitch

Antony Riakiotakis kalast at gmail.com
Thu Jan 5 17:47:40 CET 2012


Revision: 43172
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43172
Author:   psy-fi
Date:     2012-01-05 16:47:39 +0000 (Thu, 05 Jan 2012)
Log Message:
-----------
smart stitch
==============
-rotation did not take total stitchable uvs into account, having been written to work for edges.
-substitute sprintf with BLI_snprintf

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

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-05 16:21:15 UTC (rev 43171)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_smart_stitch.c	2012-01-05 16:47:39 UTC (rev 43172)
@@ -40,9 +40,10 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_scene_types.h"
 
-#include "BLI_math.h"
 #include "BLI_editVert.h"
 #include "BLI_ghash.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
 
 #include "BKE_context.h"
 #include "BKE_customdata.h"
@@ -216,17 +217,18 @@
 	return _stitch_preview;
 }
 
+#define HEADER_LENGTH 256
 
 /* 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[] = "(S)nap %s, (M)idpoints %s, (L)imit %.2f (Ctrl Wheel adjust) %s, Switch (I)sland, shift select vertices";
 
-	char msg[256];
+	char msg[HEADER_LENGTH];
 	ScrArea *sa= CTX_wm_area(C);
 
 	if(sa) {
-		sprintf(msg, str,
+		BLI_snprintf(msg, HEADER_LENGTH, str,
 				stitch_state->snap_islands? "On" : "Off",
 				stitch_state->midpoints? "On": "Off",
 				stitch_state->limit_dist,
@@ -272,8 +274,8 @@
 
 			if( island_stitch_data[i].numOfEdges>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;
+				island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfElements;
+				island_stitch_data[i].medianPoint[1] /= island_stitch_data[i].numOfElements;
 			}
 			island_stitch_data[i].translation[0] /= island_stitch_data[i].numOfElements;
 			island_stitch_data[i].translation[1] /= island_stitch_data[i].numOfElements;
@@ -351,8 +353,6 @@
 
 	island_stitch_data[element->island].numOfEdges++;
 	island_stitch_data[element->island].rotation += (edgesin > 0)? acos(edgecos): -acos(edgecos);
-	island_stitch_data[element->island].medianPoint[0] += (mt->uv[(element->tfindex + 1)%nverts][0] + mt->uv[element->tfindex][0]) / 2.0;
-	island_stitch_data[element->island].medianPoint[1] += (mt->uv[(element->tfindex + 1)%nverts][1] + mt->uv[element->tfindex][1]) / 2.0;
 }
 /*
 static void stitch_island_calculate_vert_rotation(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data)
@@ -726,6 +726,8 @@
 				 * because in final pass MTFaces get modified and result is zero. */
 				island_stitch_data[element->island].translation[0] += final_position[i].uv[0] - mt->uv[element->tfindex][0];
 				island_stitch_data[element->island].translation[1] += final_position[i].uv[1] - mt->uv[element->tfindex][1];
+				island_stitch_data[element->island].medianPoint[0] += mt->uv[element->tfindex][0];
+				island_stitch_data[element->island].medianPoint[1] += mt->uv[element->tfindex][1];
 				island_stitch_data[element->island].numOfElements++;
 			}
 		}




More information about the Bf-blender-cvs mailing list