[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17284] branches/animsys2/source/blender: AnimSys2: Hide all handles (IPO Editor)

Joshua Leung aligorith at gmail.com
Sun Nov 2 11:04:58 CET 2008


Revision: 17284
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17284
Author:   aligorith
Date:     2008-11-02 11:04:57 +0100 (Sun, 02 Nov 2008)

Log Message:
-----------
AnimSys2: Hide all handles (IPO Editor)

Added a new option to the View menu of the IPO Editor - 'Show Handles'. This is turned on by default, but when disabled, all handles on BezTriples will be hidden, making it easier to see the keyframes.

Modified Paths:
--------------
    branches/animsys2/source/blender/makesdna/DNA_space_types.h
    branches/animsys2/source/blender/src/drawipo.c
    branches/animsys2/source/blender/src/editipo.c
    branches/animsys2/source/blender/src/header_ipo.c

Modified: branches/animsys2/source/blender/makesdna/DNA_space_types.h
===================================================================
--- branches/animsys2/source/blender/makesdna/DNA_space_types.h	2008-11-02 03:02:58 UTC (rev 17283)
+++ branches/animsys2/source/blender/makesdna/DNA_space_types.h	2008-11-02 10:04:57 UTC (rev 17284)
@@ -541,8 +541,9 @@
 #define SI_DISPGP		1<<22
 
 /* SpaceIpo->flag */
-#define SIPO_LOCK_VIEW			1<<0
-#define SIPO_NOTRANSKEYCULL		1<<1
+#define SIPO_LOCK_VIEW			(1<<0)
+#define SIPO_NOTRANSKEYCULL		(1<<1)
+#define SIPO_NOHANDLES			(1<<2)
 
 /* SpaceText flags (moved from DNA_text_types.h) */
 

Modified: branches/animsys2/source/blender/src/drawipo.c
===================================================================
--- branches/animsys2/source/blender/src/drawipo.c	2008-11-02 03:02:58 UTC (rev 17283)
+++ branches/animsys2/source/blender/src/drawipo.c	2008-11-02 10:04:57 UTC (rev 17284)
@@ -1294,7 +1294,7 @@
 			 * in the middle of a glBegin/glEnd also the
 			 * bug comment before.
 			 */
-			if (ei->flag & IPO_EDIT)
+			if ((ei->flag & IPO_EDIT) && (G.sipo->flag & SIPO_NOHANDLES)==0)
 				draw_ipovertices_handles(ei->icu, ei->disptype, sel);
 		}
 	}
@@ -1310,6 +1310,10 @@
 	unsigned int *col;
 	int a, b;
 	
+	/* don't draw handle lines if handles are not shown */
+	if (G.sipo->flag & SIPO_NOHANDLES)
+		return;
+	
 	if (sel) col= nurbcol+4;
 	else col= nurbcol;
 	
@@ -1320,12 +1324,11 @@
 				BezTriple *bezt=ei->icu->bezt, *prevbezt=NULL;
 				float *fp;
 				
-				
 				for (b= 0; b < ei->icu->totvert; b++, prevbezt=bezt, bezt++) {
 					if ((bezt->f2 & SELECT)==sel) {
 						fp= bezt->vec[0];
 						
-						/* only draw first handle if previous segment was had handles */
+						/* only draw first handle if previous segment had handles */
 						if ( (!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) ) 
 						{
 							cpack(col[bezt->h1]);

Modified: branches/animsys2/source/blender/src/editipo.c
===================================================================
--- branches/animsys2/source/blender/src/editipo.c	2008-11-02 03:02:58 UTC (rev 17283)
+++ branches/animsys2/source/blender/src/editipo.c	2008-11-02 10:04:57 UTC (rev 17284)
@@ -1411,7 +1411,6 @@
 	/* in icu and (bezt or bp) the nearest is written */
 	/* return 0 1 2: handlepunt */
 	EditIpo *ei;
-	BezTriple *bezt1;
 	int dist= 100, temp, a, b;
 	short mval[2], hpoint=0, sco[3][2];
 
@@ -1423,50 +1422,58 @@
 	ei= G.sipo->editipo;
 	for(a=0; a<G.sipo->totipo; a++, ei++) {
 		if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu)) {
-			
-			if(ei->icu->bezt) {
-				bezt1= ei->icu->bezt;
-				b= ei->icu->totvert;
-				while(b--) {
-
+			/* try to progressively get closer to the right point... */
+			if (ei->icu->bezt) {
+				BezTriple *bezt1=ei->icu->bezt, *prevbezt=NULL;
+				
+				for (b= 0; b < ei->icu->totvert; b++, prevbezt=bezt1, bezt1++) {
+					/* convert beztriple points to screen-space */
 					ipoco_to_areaco_noclip(G.v2d, bezt1->vec[0], sco[0]);
 					ipoco_to_areaco_noclip(G.v2d, bezt1->vec[1], sco[1]);
 					ipoco_to_areaco_noclip(G.v2d, bezt1->vec[2], sco[2]);
-										
-					if(ei->disptype==IPO_DISPBITS) {
+					
+					/* keyframe - do select? */
+					if (ei->disptype==IPO_DISPBITS)
 						temp= abs(mval[0]- sco[1][0]);
-					}
-					else temp= abs(mval[0]- sco[1][0])+ abs(mval[1]- sco[1][1]);
-
-					if( bezt1->f2 & SELECT) temp+=5;
-					if(temp<dist) { 
+					else
+						temp= abs(mval[0]- sco[1][0])+ abs(mval[1]- sco[1][1]);
+					
+					if (bezt1->f2 & SELECT) temp+=5;
+					if (temp < dist) { 
 						hpoint= 1; 
 						*bezt= bezt1; 
 						dist= temp; 
 						*icu= ei->icu; 
 					}
 					
-					if(ei->disptype!=IPO_DISPBITS && ei->icu->ipo==IPO_BEZ) {
-						/* middle points get an advantage */
-						temp= -3+abs(mval[0]- sco[0][0])+ abs(mval[1]- sco[0][1]);
-						if( bezt1->f1 & SELECT) temp+=5;
-						if(temp<dist) { 
-							hpoint= 0; 
-							*bezt= bezt1; 
-							dist= temp; 
-							*icu= ei->icu; 
+					/* handles - only do them if they're visible */
+					if ((ei->disptype!=IPO_DISPBITS) && !(G.sipo->flag & SIPO_NOHANDLES)) {
+						/* first handle only visible if previous segment had handles */
+						if ( (!prevbezt && (bezt1->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) )
+						{
+							temp= -3+abs(mval[0]- sco[0][0])+ abs(mval[1]- sco[0][1]);
+							if (bezt1->f1 & SELECT) temp+=5;
+							if (temp < dist) { 
+								hpoint= 0; 
+								*bezt= bezt1; 
+								dist= temp; 
+								*icu= ei->icu; 
+							}
 						}
-		
-						temp= abs(mval[0]- sco[2][0])+ abs(mval[1]- sco[2][1]);
-						if( bezt1->f3 & 1) temp+=5;
-						if(temp<dist) { 
-							hpoint= 2; 
-							*bezt=bezt1; 
-							dist= temp; 
-							*icu= ei->icu; 
+						
+						/* second handle only visible if this segment is bezier */
+						if (bezt1->ipo == IPO_BEZ) 
+						{
+							temp= abs(mval[0]- sco[2][0])+ abs(mval[1]- sco[2][1]);
+							if (bezt1->f3 & SELECT) temp+=5;
+							if (temp < dist) { 
+								hpoint= 2; 
+								*bezt=bezt1; 
+								dist= temp; 
+								*icu= ei->icu; 
+							}
 						}
 					}
-					bezt1++;
 				}
 			}
 		}
@@ -1533,36 +1540,42 @@
 		}
 	}
 	else if(totipo_edit) {
-		
+		/* find the beztriple that we're selecting, and the handle that was clicked on */
 		hand= findnearest_ipovert(&icu, &bezt);
 		
-		if(G.qual & LR_SHIFTKEY) {
-			if(bezt) {
-				if(hand==1) {
-					if(BEZSELECTED(bezt)) {
+		if (G.qual & LR_SHIFTKEY) {
+			/* adding to selection */
+			if (bezt) {
+				/* keyframe - invert select of all */
+				if (hand==1) {
+					if (BEZSELECTED(bezt)) {
 						BEZ_DESEL(bezt);
 					}
 					else {
 						BEZ_SEL(bezt);
 					}
 				}
+				/* handles - toggle selection of relevant handle */
 				else if(hand==0) {
-					if(bezt->f1 & SELECT) bezt->f1 &= ~SELECT;
-					else bezt->f1= SELECT;
+					/* toggle selection */
+					bezt->f1 ^= SELECT;
 				}
 				else {
-					if(bezt->f3 & SELECT) bezt->f3 &= ~SELECT;
-					else bezt->f3= SELECT;
+					/* toggle selection */
+					bezt->f3 ^= SELECT;
 				}
 			}				
 		}
 		else {
+			/* not adding to selection, so deselect all first */
 			deselectall_editipo();
 			
-			if(bezt) {
-				if(hand==1) {
+			if (bezt) {
+				/* if the keyframe was clicked on, select all verts of given beztriple */
+				if (hand==1) {
 					BEZ_SEL(bezt);
 				}
+				/* otherwise, select the handle that applied */
 				else if(hand==0) bezt->f1 |= SELECT;
 				else bezt->f3 |= SELECT;
 			}

Modified: branches/animsys2/source/blender/src/header_ipo.c
===================================================================
--- branches/animsys2/source/blender/src/header_ipo.c	2008-11-02 03:02:58 UTC (rev 17283)
+++ branches/animsys2/source/blender/src/header_ipo.c	2008-11-02 10:04:57 UTC (rev 17284)
@@ -727,6 +727,9 @@
 	case 15: /* AutoMerge Keyframes */
 		G.sipo->flag ^= SIPO_NOTRANSKEYCULL;
 		break;
+	case 16: /* Show/Hide handles */
+		G.sipo->flag ^= SIPO_NOHANDLES;
+		break;
 	}
 }
 
@@ -750,6 +753,8 @@
 	
 	uiDefIconTextBut(block, BUTM, 1, (G.sipo->flag & SIPO_NOTRANSKEYCULL)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
 					 "AutoMerge Keyframes|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
+	uiDefIconTextBut(block, BUTM, 1, (G.sipo->flag & SIPO_NOHANDLES)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
+					 "Show Handles|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
 	
 	uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 





More information about the Bf-blender-cvs mailing list