[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45529] trunk/blender/source/blender: fix [#30897] UVEditor: Snap Cursor to Selected

Campbell Barton ideasman42 at gmail.com
Wed Apr 11 09:47:09 CEST 2012


Revision: 45529
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45529
Author:   campbellbarton
Date:     2012-04-11 07:47:09 +0000 (Wed, 11 Apr 2012)
Log Message:
-----------
fix [#30897] UVEditor: Snap Cursor to Selected
was writing the 3rd component of a 2D vector.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_vector.c
    trunk/blender/source/blender/editors/uvedit/uvedit_ops.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2012-04-11 07:35:04 UTC (rev 45528)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2012-04-11 07:47:09 UTC (rev 45529)
@@ -154,6 +154,7 @@
 void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float v4[4], const float w[4]);
 
 void mid_v3_v3v3(float r[3], const float a[3], const float b[3]);
+void mid_v2_v2v2(float r[2], const float a[2], const float b[2]);
 
 /********************************* Comparison ********************************/
 

Modified: trunk/blender/source/blender/blenlib/intern/math_vector.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector.c	2012-04-11 07:35:04 UTC (rev 45528)
+++ trunk/blender/source/blender/blenlib/intern/math_vector.c	2012-04-11 07:47:09 UTC (rev 45529)
@@ -109,6 +109,12 @@
 	v[2] = 0.5f * (v1[2] + v2[2]);
 }
 
+void mid_v2_v2v2(float v[2], const float v1[2], const float v2[2])
+{
+	v[0] = 0.5f * (v1[0] + v2[0]);
+	v[1] = 0.5f * (v1[1] + v2[1]);
+}
+
 /********************************** Angles ***********************************/
 
 /* Return the angle in radians between vecs 1-2 and 2-3 in radians

Modified: trunk/blender/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- trunk/blender/source/blender/editors/uvedit/uvedit_ops.c	2012-04-11 07:35:04 UTC (rev 45528)
+++ trunk/blender/source/blender/editors/uvedit/uvedit_ops.c	2012-04-11 07:47:09 UTC (rev 45529)
@@ -614,7 +614,7 @@
 	return sel;
 }
 
-static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3])
+static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[2])
 {
 	BMEditMesh *em = BMEdit_FromObject(obedit);
 	BMFace *efa;
@@ -624,7 +624,7 @@
 	MLoopUV *luv;
 	unsigned int sel= 0;
 
-	zero_v3(co);
+	zero_v2(co);
 	BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
 		tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
 		if (!uvedit_face_visible(scene, ima, efa, tf))
@@ -639,36 +639,29 @@
 		}
 	}
 
-	mul_v3_fl(co, 1.0f/(float)sel);
+	mul_v2_fl(co, 1.0f/(float)sel);
 
 	return (sel != 0);
 }
 
-static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, char mode)
+static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float cent[2], char mode)
 {
-	float min[2], max[2];
-	int change= 0;
+	int change = FALSE;
 	
-	if (mode==V3D_CENTER) { /* bounding box */
+	if (mode == V3D_CENTER) {  /* bounding box */
+		float min[2], max[2];
 		if (ED_uvedit_minmax(scene, ima, obedit, min, max)) {
-			change = 1;
-
-			cent[0]= (min[0]+max[0])/2.0f;
-			cent[1]= (min[1]+max[1])/2.0f;
+			mid_v2_v2v2(cent, min, max);
+			change = TRUE;
 		}
 	}
 	else {
 		if (ED_uvedit_median(scene, ima, obedit, cent)) {
-			change = 1;
+			change = TRUE;
 		}
-
 	}
 
-	if (change) {
-		return 1;
-	}
-
-	return 0;
+	return change;
 }
 
 /************************** find nearest ****************************/




More information about the Bf-blender-cvs mailing list