[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17685] branches/animsys2/source/blender: AnimSys2: IPO Transform Tweaks

Joshua Leung aligorith at gmail.com
Wed Dec 3 03:49:09 CET 2008


Revision: 17685
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17685
Author:   aligorith
Date:     2008-12-03 03:49:06 +0100 (Wed, 03 Dec 2008)

Log Message:
-----------
AnimSys2: IPO Transform Tweaks

* Added pivot-point option for rotation/scaling. Care needs to be taken with the 'mouse cursor' option, which currently uses a fixed constant scale factor (Theeth: if you have time, could you see if there's a better alternative ;)) as the scaling would be 'way' too sensitive (as starting mouse position = transform center/pivot). 

* Excluded IPO-handles from autosnap

Modified Paths:
--------------
    branches/animsys2/source/blender/include/transform.h
    branches/animsys2/source/blender/src/editipo.c
    branches/animsys2/source/blender/src/header_ipo.c
    branches/animsys2/source/blender/src/transform.c
    branches/animsys2/source/blender/src/transform_conversions.c
    branches/animsys2/source/blender/src/transform_generics.c

Modified: branches/animsys2/source/blender/include/transform.h
===================================================================
--- branches/animsys2/source/blender/include/transform.h	2008-12-03 02:03:51 UTC (rev 17684)
+++ branches/animsys2/source/blender/include/transform.h	2008-12-03 02:49:06 UTC (rev 17685)
@@ -297,6 +297,7 @@
 #define TD_NO_EXT			(1 << 10)	/* ext abused for particle key timing */
 #define TD_SKIP				(1 << 11)	/* don't transform this data */
 #define TD_BEZTRIPLE		(1 << 12)	/* if this is a bez triple, we need to restore the handles, if this is set transdata->misc.hdata needs freeing */
+#define TD_NOTIMESNAP		(1 << 13)	/* for IPO-autosnap, indicates that point should not undergo autosnapping */
 
 /* transsnap->status */
 #define SNAP_ON			1

Modified: branches/animsys2/source/blender/src/editipo.c
===================================================================
--- branches/animsys2/source/blender/src/editipo.c	2008-12-03 02:03:51 UTC (rev 17684)
+++ branches/animsys2/source/blender/src/editipo.c	2008-12-03 02:49:06 UTC (rev 17685)
@@ -3835,7 +3835,7 @@
 /* Helper function for make_ipo_transdata, which is reponsible for associating
  * source data with transform data
  */
-static void bezt_to_transdata (TransData *td, TransData2D *td2d, float *loc, float *cent, short selected, short onlytime)
+static void bezt_to_transdata (TransData *td, TransData2D *td2d, float *loc, float *cent, short selected, short ishandle, short onlytime)
 {
 	/* New location from td gets dumped onto the old-location of td2d, which then
 	 * gets copied to the actual data at td2d->loc2d (bezt->vec[n])
@@ -3884,6 +3884,9 @@
 	
 	if (onlytime)
 		td->flag |= TD_TIMEONLY;
+		
+	if (ishandle)	
+		td->flag |= TD_NOTIMESNAP;
 	
 	Mat3One(td->mtx);
 	Mat3One(td->smtx);
@@ -3911,7 +3914,29 @@
 		/* count data first */
 		if (totipo_vertsel) {
 			/* we're probably in editmode, so only selected verts */
-			count= totipo_vertsel;
+			if (G.v2d->around == V3D_LOCAL) {
+				/* we're in editmode, but we need to count the number of selected handles only */
+				ei= G.sipo->editipo;
+				for (a=0; a<G.sipo->totipo; a++, ei++) {
+					if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu)) {
+						IpoCurve *icu= ei->icu;
+						
+						if (icu->bezt) { 
+							bezt= icu->bezt;
+							for (b=0; b < icu->totvert; b++, bezt++) {
+								if (bezt->ipo == IPO_BEZ) {
+									if (bezt->f1 & SELECT) count++;
+									if (bezt->f2 & SELECT) count++;
+								}
+								else if (bezt->f2 & SELECT) count++;
+							}
+						}
+					}
+				}
+				if (count==0) return;
+			}
+			else
+				count= totipo_vertsel; 
 		}
 		else if (totipo_edit==0 && totipo_sel!=0) {
 			/* we're not in editmode, so entire curves get moved */
@@ -3924,7 +3949,7 @@
 						if (icu->ipo == IPO_MIXED) {
 							bezt= icu->bezt;
 							for (b=0; b < icu->totvert; b++, bezt++) {
-								if (bezt->ipo == IPO_BEZ) count += 3; // err...
+								if (bezt->ipo == IPO_BEZ) count += 3;
 								else count++;
 							}
 						}
@@ -3979,7 +4004,7 @@
 							if ( (!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) ) {
 								if (bezt->f1 & SELECT) {
 									hdata = initTransDataCurveHandes(td, bezt);
-									bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, onlytime);
+									bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, 1, onlytime);
 								}
 								else
 									h1= 0;
@@ -3988,7 +4013,7 @@
 								if (bezt->f3 & SELECT) {
 									if (hdata==NULL)
 										hdata = initTransDataCurveHandes(td, bezt);
-									bezt_to_transdata(td++, td2d++, bezt->vec[2], bezt->vec[1], 1, onlytime);
+									bezt_to_transdata(td++, td2d++, bezt->vec[2], bezt->vec[1], 1, 1, onlytime);
 								}
 								else
 									h2= 0;
@@ -3996,14 +4021,17 @@
 							
 							/* only include main vert if selected */
 							if (bezt->f2 & SELECT) {
-								/* if handles were not selected, store their selection status */
-								if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) {
-									if (hdata == NULL)
-										hdata = initTransDataCurveHandes(td, bezt);
+								/* if scaling around individuals centers, do no include keyframes */
+								if (G.v2d->around != V3D_LOCAL) {
+									/* if handles were not selected, store their selection status */
+									if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) {
+										if (hdata == NULL)
+											hdata = initTransDataCurveHandes(td, bezt);
+									}
+									
+									bezt_to_transdata(td++, td2d++, bezt->vec[1], bezt->vec[1], 1, 0, onlytime);
 								}
 								
-								bezt_to_transdata(td++, td2d++, bezt->vec[1], bezt->vec[1], 1, onlytime);
-								
 								/* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...): 
 								 *	- Check if we've got entire BezTriple selected and we're scaling/rotating that point, 
 								 *	  then check if we're using auto-handles. 
@@ -4042,12 +4070,12 @@
 					for (b=0; b < icu->totvert; b++, prevbezt=bezt, bezt++) {
 						/* only include handles if interpolation mode is bezier is relevant */
 						if ( (!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) )
-							bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, onlytime);
+							bezt_to_transdata(td++, td2d++, bezt->vec[0], bezt->vec[1], 1, 1,onlytime);
 						if (bezt->ipo==IPO_BEZ)
-							bezt_to_transdata(td++, td2d++, bezt->vec[2], bezt->vec[1], 1, onlytime);
+							bezt_to_transdata(td++, td2d++, bezt->vec[2], bezt->vec[1], 1, 1, onlytime);
 						
 						/* always include the main handle */
-						bezt_to_transdata(td++, td2d++, bezt->vec[1], bezt->vec[1], 1, onlytime);
+						bezt_to_transdata(td++, td2d++, bezt->vec[1], bezt->vec[1], 1, 0, onlytime);
 					}
 				}
 			}

Modified: branches/animsys2/source/blender/src/header_ipo.c
===================================================================
--- branches/animsys2/source/blender/src/header_ipo.c	2008-12-03 02:03:51 UTC (rev 17684)
+++ branches/animsys2/source/blender/src/header_ipo.c	2008-12-03 02:49:06 UTC (rev 17685)
@@ -979,6 +979,19 @@
 	return (string);
 }
 
+static char *ipo_around_pup(void)
+{
+	static char string[512];
+	char *str = string;
+
+	str += sprintf(str, "%s", "Pivot: %t"); 
+	str += sprintf(str, "%s", "|Bounding Box Center %x0"); 
+	str += sprintf(str, "%s", "|Median Point %x3");
+	str += sprintf(str, "%s", "|Mouse Cursor %x1");
+	str += sprintf(str, "%s", "|Individual Centers %x2");
+	return string;
+}
+
 void do_ipo_buttons(short event)
 {
 	EditIpo *ei;
@@ -1397,6 +1410,10 @@
 	
 	uiClearButLock();
 	
+	/* TRANSFORM AROUND */
+	uiDefIconTextButS(block, ICONTEXTROW,B_AROUND, ICON_ROTATE, ipo_around_pup(), xco,0,XIC+10,YIC, &(G.v2d->around), 0, 3.0, 0, 0, "Rotation/Scaling Pivot");
+	xco+=(2*XIC);
+	
 	/* AUTOSNAP */
 	if (G.sipo->flag & SIPO_DRAWTIME) {
 		uiDefButS(block, MENU, B_REDR,

Modified: branches/animsys2/source/blender/src/transform.c
===================================================================
--- branches/animsys2/source/blender/src/transform.c	2008-12-03 02:03:51 UTC (rev 17684)
+++ branches/animsys2/source/blender/src/transform.c	2008-12-03 02:49:06 UTC (rev 17685)
@@ -2050,13 +2050,19 @@
 	t->snap[1] = 0.1f;
 	t->snap[2] = t->snap[1] * 0.1f;
 
+	if ((t->spacetype == SPACE_IPO) && (t->around == V3D_CURSOR)) {
+		/* HACK: special factor here, as it's too "reactive" otherwise (as imval is used as center!) */
+		t->fac= 90.0f;
+	}
+	else {
 	t->fac = (float)sqrt(
 		(
 			((float)(t->center2d[1] - t->imval[1]))*((float)(t->center2d[1] - t->imval[1]))
 		+
 			((float)(t->center2d[0] - t->imval[0]))*((float)(t->center2d[0] - t->imval[0]))
 		) );
-
+	}
+	
 	if(t->fac==0.0f) t->fac= 1.0f;	// prevent Inf
 }
 

Modified: branches/animsys2/source/blender/src/transform_conversions.c
===================================================================
--- branches/animsys2/source/blender/src/transform_conversions.c	2008-12-03 02:03:51 UTC (rev 17684)
+++ branches/animsys2/source/blender/src/transform_conversions.c	2008-12-03 02:49:06 UTC (rev 17685)
@@ -2503,31 +2503,37 @@
  */
 void flushTransIpoData(TransInfo *t)
 {
-	TransData2D *td;
+	TransData *td;
+	TransData2D *td2d;
 	int a;
 	
 	/* flush to 2d vector from internally used 3d vector */
-	for (a=0, td= t->data2d; a<t->total; a++, td++) {
-		/* handle snapping for time values - we should still be in NLA-scaled timespace */
-		switch (G.sipo->autosnap) {
-			case SACTSNAP_FRAME: /* snap to nearest frame */
-				td->loc[0]= (float)( floor(td->loc[0]+0.5f) );
-				break;
-				
-			case SACTSNAP_MARKER: /* snap to nearest marker */
-				td->loc[0]= (float)find_nearest_marker_time(td->loc[0]);
-				break;
+	for (a=0, td= t->data, td2d=t->data2d; a<t->total; a++, td++, td2d++) {
+		/* handle snapping for time values 
+		 *	- we should still be in NLA-scaled timespace 
+		 *	- only apply to keyframes (but never to handles)
+		 */
+		if ((td->flag & TD_NOTIMESNAP)==0) {
+			switch (G.sipo->autosnap) {
+				case SACTSNAP_FRAME: /* snap to nearest frame */
+					td2d->loc[0]= (float)( floor(td2d->loc[0]+0.5f) );
+					break;
+					
+				case SACTSNAP_MARKER: /* snap to nearest marker */
+					td2d->loc[0]= (float)find_nearest_marker_time(td2d->loc[0]);
+					break;
+			}
 		}
 		
 		/* we need to unapply the nla-scaling from the time in some situations */
 		if (NLA_IPO_SCALED)
-			td->loc2d[0]= get_action_frame(OBACT, td->loc[0]);
+			td2d->loc2d[0]= get_action_frame(OBACT, td2d->loc[0]);
 		else
-			td->loc2d[0]= td->loc[0];
+			td2d->loc2d[0]= td2d->loc[0];
 		
 		/* when the icu that point comes from is a bitflag holder, don't allow adjusting values */
-		if ((t->data[a].flag & TD_TIMEONLY)==0)
-			td->loc2d[1]= td->loc[1];
+		if ((td->flag & TD_TIMEONLY)==0)
+			td2d->loc2d[1]= td2d->loc[1];
 	}
 }
 

Modified: branches/animsys2/source/blender/src/transform_generics.c
===================================================================
--- branches/animsys2/source/blender/src/transform_generics.c	2008-12-03 02:03:51 UTC (rev 17684)
+++ branches/animsys2/source/blender/src/transform_generics.c	2008-12-03 02:49:06 UTC (rev 17685)
@@ -64,6 +64,7 @@
 #include "BIF_meshtools.h"
 #include "BIF_retopo.h"
 
+#include "BSE_drawipo.h"
 #include "BSE_editipo.h"
 #include "BSE_editipo_types.h"
 
@@ -671,7 +672,8 @@
 	if(t->spacetype==SPACE_VIEW3D) {
 		if(G.vd->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list