[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11516] trunk/blender/source/blender/src/ edit.c: == Snap Cursor to Selected -> EditMode Bones ==

Joshua Leung aligorith at gmail.com
Wed Aug 8 09:00:37 CEST 2007


Revision: 11516
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11516
Author:   aligorith
Date:     2007-08-08 09:00:20 +0200 (Wed, 08 Aug 2007)

Log Message:
-----------
== Snap Cursor to Selected -> EditMode Bones ==

After complaints from wavez, Snap Cursor to Selected for Bones in EditMode now results in the cursor being snapped to the midpoint of the selected joint(s) like it did before my no zero-length bones commit.

Modified Paths:
--------------
    trunk/blender/source/blender/src/edit.c

Modified: trunk/blender/source/blender/src/edit.c
===================================================================
--- trunk/blender/source/blender/src/edit.c	2007-08-08 06:36:23 UTC (rev 11515)
+++ trunk/blender/source/blender/src/edit.c	2007-08-08 07:00:20 UTC (rev 11516)
@@ -884,7 +884,7 @@
 }
 
 /* copied from editobject.c, needs to be replaced with new transform code still */
-/* mode: 1 = proportional */
+/* mode: 1 = proportional, 2 = all joints (for bones only) */
 static void make_trans_verts(float *min, float *max, int mode)	
 {
 	extern ListBase editNurb;
@@ -956,7 +956,7 @@
 		}
 		
 		/* proportional edit exception... */
-		if(mode==1 && tottrans) {
+		if((mode & 1) && tottrans) {
 			for(eve= em->verts.first; eve; eve= eve->next) {
 				if(eve->h==0) {
 					eve->f1 |= 2;
@@ -992,8 +992,9 @@
 				short rootok= (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && ebo->parent->flag & BONE_TIPSEL));
 				
 				if ((tipsel && rootsel) || (rootsel)) {
-					/* Only add the root if there is no connection.
-					 * Don't add the tip, otherwise we get zero-length bones.
+					/* Don't add the tip (unless mode & 2, for getting all joints), 
+					 * otherwise we get zero-length bones as tips will snap to the same
+					 * location as heads. 
 					 */
 					if (rootok) {
 						VECCOPY (tv->oldloc, ebo->head);
@@ -1003,6 +1004,15 @@
 						tv++;
 						tottrans++;
 					}	
+					
+					if (mode & 2) {
+						VECCOPY (tv->oldloc, ebo->tail);
+						tv->loc= ebo->tail;
+						tv->nor= NULL;
+						tv->flag= 1;
+						tv++;
+						tottrans++;
+					}					
 				}
 				else if (tipsel) {
 					VECCOPY (tv->oldloc, ebo->tail);
@@ -1023,14 +1033,14 @@
 				bezt= nu->bezt;
 				while(a--) {
 					if(bezt->hide==0) {
-						if(mode==1 || (bezt->f1 & 1)) {
+						if((mode & 1) || (bezt->f1 & 1)) {
 							VECCOPY(tv->oldloc, bezt->vec[0]);
 							tv->loc= bezt->vec[0];
 							tv->flag= bezt->f1 & 1;
 							tv++;
 							tottrans++;
 						}
-						if(mode==1 || (bezt->f2 & 1)) {
+						if((mode & 1) || (bezt->f2 & 1)) {
 							VECCOPY(tv->oldloc, bezt->vec[1]);
 							tv->loc= bezt->vec[1];
 							tv->val= &(bezt->alfa);
@@ -1039,7 +1049,7 @@
 							tv++;
 							tottrans++;
 						}
-						if(mode==1 || (bezt->f3 & 1)) {
+						if((mode & 1) || (bezt->f3 & 1)) {
 							VECCOPY(tv->oldloc, bezt->vec[2]);
 							tv->loc= bezt->vec[2];
 							tv->flag= bezt->f3 & 1;
@@ -1055,7 +1065,7 @@
 				bp= nu->bp;
 				while(a--) {
 					if(bp->hide==0) {
-						if(mode==1 || (bp->f1 & 1)) {
+						if((mode & 1) || (bp->f1 & 1)) {
 							VECCOPY(tv->oldloc, bp->vec);
 							tv->loc= bp->vec;
 							tv->val= &(bp->alfa);
@@ -1093,7 +1103,7 @@
 		a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
 		
 		while(a--) {
-			if(mode==1 || (bp->f1 & 1)) {
+			if((mode & 1) || (bp->f1 & 1)) {
 				if(bp->hide==0) {
 					VECCOPY(tv->oldloc, bp->vec);
 					tv->loc= bp->vec;
@@ -1398,7 +1408,7 @@
 		tottrans=0;
 
 		if ELEM6(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) 
-			make_trans_verts(bmat[0], bmat[1], 0);
+			make_trans_verts(bmat[0], bmat[1], 2);
 		if(tottrans==0) return;
 
 		Mat3CpyMat4(bmat, G.obedit->obmat);





More information about the Bf-blender-cvs mailing list