[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23882] trunk/blender/source/blender/ editors: A few Graph Editor tweaks:

Joshua Leung aligorith at gmail.com
Fri Oct 16 12:01:15 CEST 2009


Revision: 23882
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23882
Author:   aligorith
Date:     2009-10-16 12:01:15 +0200 (Fri, 16 Oct 2009)

Log Message:
-----------
A few Graph Editor tweaks:
* Tiny tweak of GL commands used when drawing F-Curves (single GL_LINES instead of multiple GL_LINE_STRIPS) to hopefully improve the performance with heaps of handles drawn a bit

* Spelling fix for initTransDataCurveHandes -> initTransDataCurveHandles

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_graph/graph_draw.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-10-16 10:00:45 UTC (rev 23881)
+++ trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-10-16 10:01:15 UTC (rev 23882)
@@ -155,7 +155,7 @@
 			glVertex2f(fed->time, fed->max);
 		}
 	}
-	bglEnd();
+	bglEnd(); // GL_POINTS
 	
 	glPointSize(1.0f);
 }
@@ -198,7 +198,7 @@
 		}
 	}
 	
-	bglEnd();
+	bglEnd(); // GL_POINTS
 }
 
 
@@ -333,21 +333,24 @@
 static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
 {
 	extern unsigned int nurbcol[];
-	unsigned int *col;
 	int sel, b;
 	
 	/* don't draw handle lines if handles are not shown */
 	if ((sipo->flag & SIPO_NOHANDLES) || (fcu->flag & FCURVE_PROTECTED) || (fcu->flag & FCURVE_INT_VALUES))
 		return;
 	
+	/* a single call to GL_LINES here around these calls should be sufficient to still
+	 * get separate line segments, but which aren't wrapped with GL_LINE_STRIP everytime we
+	 * want a single line
+	 */
+	glBegin(GL_LINES);
+	
 	/* slightly hacky, but we want to draw unselected points before selected ones */
 	for (sel= 0; sel < 2; sel++) {
 		BezTriple *bezt=fcu->bezt, *prevbezt=NULL;
+		unsigned int *col= (sel)? (nurbcol+4) : (nurbcol);
 		float *fp;
 		
-		if (sel) col= nurbcol+4;
-		else col= nurbcol;
-			
 		for (b= 0; b < fcu->totvert; b++, prevbezt=bezt, bezt++) {
 			if ((bezt->f2 & SELECT)==sel) {
 				fp= bezt->vec[0];
@@ -356,19 +359,15 @@
 				if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) 
 				{
 					cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
-					glBegin(GL_LINE_STRIP); 
-						glVertex2fv(fp); glVertex2fv(fp+3); 
-					glEnd();
 					
+					glVertex2fv(fp); glVertex2fv(fp+3); 
 				}
 				
 				/* only draw second handle if this segment is bezier */
 				if (bezt->ipo == BEZT_IPO_BEZ) 
 				{
 					cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
-					glBegin(GL_LINE_STRIP); 
-						glVertex2fv(fp+3); glVertex2fv(fp+6); 
-					glEnd();
+					glVertex2fv(fp+3); glVertex2fv(fp+6); 
 				}
 			}
 			else {
@@ -379,9 +378,7 @@
 					fp= bezt->vec[0];
 					cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
 					
-					glBegin(GL_LINE_STRIP); 
-						glVertex2fv(fp); glVertex2fv(fp+3); 
-					glEnd();
+					glVertex2fv(fp); glVertex2fv(fp+3); 
 				}
 				
 				/* only draw second handle if this segment is bezier, and selection is ok */
@@ -391,13 +388,13 @@
 					fp= bezt->vec[1];
 					cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
 					
-					glBegin(GL_LINE_STRIP); 
-						glVertex2fv(fp); glVertex2fv(fp+3); 
-					glEnd();
+					glVertex2fv(fp); glVertex2fv(fp+3); 
 				}
 			}
 		}
 	}
+	
+	glEnd(); // GL_LINES
 }
 
 /* Samples ---------------- */

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-10-16 10:00:45 UTC (rev 23881)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-10-16 10:01:15 UTC (rev 23882)
@@ -1334,7 +1334,7 @@
 }
 
 /* Utility function for getting the handle data from bezier's */
-TransDataCurveHandleFlags *initTransDataCurveHandes(TransData *td, struct BezTriple *bezt) {
+TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt) {
 	TransDataCurveHandleFlags *hdata;
 	td->flag |= TD_BEZTRIPLE;
 	hdata = td->hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
@@ -1424,7 +1424,7 @@
 						td->ext = NULL;
 						td->val = NULL;
 
-						hdata = initTransDataCurveHandes(td, bezt);
+						hdata = initTransDataCurveHandles(td, bezt);
 
 						Mat3CpyMat3(td->smtx, smtx);
 						Mat3CpyMat3(td->mtx, mtx);
@@ -1459,7 +1459,7 @@
 						if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0)
 						/* If the middle is selected but the sides arnt, this is needed */
 						if (hdata==NULL) { /* if the handle was not saved by the previous handle */
-							hdata = initTransDataCurveHandes(td, bezt);
+							hdata = initTransDataCurveHandles(td, bezt);
 						}
 
 						td++;
@@ -1484,7 +1484,7 @@
 						td->val = NULL;
 
 						if (hdata==NULL) { /* if the handle was not saved by the previous handle */
-							hdata = initTransDataCurveHandes(td, bezt);
+							hdata = initTransDataCurveHandles(td, bezt);
 						}
 
 						Mat3CpyMat3(td->smtx, smtx);
@@ -1503,7 +1503,7 @@
 			if (propmode && head != tail)
 				calc_distanceCurveVerts(head, tail-1);
 
-			/* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandes
+			/* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
 			 * but for now just dont change handle types */
 			if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0)
 				testhandlesNurb(nu); /* sets the handles based on their selection, do this after the data is copied to the TransData */
@@ -3452,14 +3452,14 @@
 				
 				/* only include handles if selected, irrespective of the interpolation modes */
 				if (bezt->f1 & SELECT) {
-					hdata = initTransDataCurveHandes(td, bezt);
+					hdata = initTransDataCurveHandles(td, bezt);
 					bezt_to_transdata(td++, td2d++, adt, bezt->vec[0], bezt->vec[1], 1, 1, intvals);
 				}
 				else
 					h1= 0;
 				if (bezt->f3 & SELECT) {
 					if (hdata==NULL)
-						hdata = initTransDataCurveHandes(td, bezt);
+						hdata = initTransDataCurveHandles(td, bezt);
 					bezt_to_transdata(td++, td2d++, adt, bezt->vec[2], bezt->vec[1], 1, 1, intvals);
 				}
 				else
@@ -3472,13 +3472,13 @@
 						/* if handles were not selected, store their selection status */
 						if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) {
 							if (hdata == NULL)
-								hdata = initTransDataCurveHandes(td, bezt);
+								hdata = initTransDataCurveHandles(td, bezt);
 						}
 						
 						bezt_to_transdata(td++, td2d++, adt, bezt->vec[1], bezt->vec[1], 1, 0, intvals);
 					}
 					
-					/* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...):
+					/* special hack (must be done after initTransDataCurveHandles(), 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.
 					 *	- If so, change them auto-handles to aligned handles so that handles get affected too





More information about the Bf-blender-cvs mailing list