[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40284] trunk/blender/source/blender: more mini optimizations - don' t call UI_ThemeColor 4 times per curve handle, instead get all colors at the start and index them when drawing curves in editmode .

Campbell Barton ideasman42 at gmail.com
Sat Sep 17 09:14:39 CEST 2011


Revision: 40284
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40284
Author:   campbellbarton
Date:     2011-09-17 07:14:39 +0000 (Sat, 17 Sep 2011)
Log Message:
-----------
more mini optimizations - don't call UI_ThemeColor 4 times per curve handle, instead get all colors at the start and index them when drawing curves in editmode.

also remove redundant NULL check.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/screen.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/source/blender/blenkernel/intern/screen.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/screen.c	2011-09-17 07:01:17 UTC (rev 40283)
+++ trunk/blender/source/blender/blenkernel/intern/screen.c	2011-09-17 07:14:39 UTC (rev 40284)
@@ -277,8 +277,7 @@
 		ar->v2d.tab_offset= NULL;
 	}
 
-	if(ar)
-		BLI_freelistN(&ar->panels);
+	BLI_freelistN(&ar->panels);
 }
 
 /* not area itself */

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-09-17 07:01:17 UTC (rev 40283)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-09-17 07:14:39 UTC (rev 40284)
@@ -717,7 +717,7 @@
  *  1	: occluded
 	2	: occluded with w[3] weights set (need to know in some cases) */
 
-static int project_paint_occlude_ptv(float pt[3], float v1[3], float v2[3], float v3[3], float w[3], int is_ortho)
+static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho)
 {
 	/* if all are behind us, return false */
 	if(v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2])

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-09-17 07:01:17 UTC (rev 40283)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-09-17 07:14:39 UTC (rev 40284)
@@ -4538,17 +4538,23 @@
 {
 	BezTriple *bezt;
 	float *fp;
-	int basecol;
 	int a;
-	
+
 	if(nu->hide || hide_handles) return;
 
 	glBegin(GL_LINES); 
-	
+
 	if(nu->type == CU_BEZIER) {
-		if(sel) basecol= TH_HANDLE_SEL_FREE;
-		else basecol= TH_HANDLE_FREE;
 
+#define TH_HANDLE_COL_TOT ((TH_HANDLE_SEL_FREE - TH_HANDLE_FREE) + 1)
+		/* use MIN2 when indexing to ensure newer files dont read outside the array */
+		unsigned char handle_cols[TH_HANDLE_COL_TOT][3];
+		const int basecol= sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
+
+		for (a=0; a < TH_HANDLE_COL_TOT; a++) {
+			UI_GetThemeColor3ubv(basecol + a, handle_cols[a]);
+		}
+
 		bezt= nu->bezt;
 		a= nu->pntsu;
 		while(a--) {
@@ -4556,31 +4562,34 @@
 				if( (bezt->f2 & SELECT)==sel) {
 					fp= bezt->vec[0];
 
-					UI_ThemeColor(basecol + bezt->h1);
+					glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]);
 					glVertex3fv(fp);
 					glVertex3fv(fp+3); 
 
-					UI_ThemeColor(basecol + bezt->h2);
+					glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]);
 					glVertex3fv(fp+3); 
 					glVertex3fv(fp+6); 
 				}
 				else if( (bezt->f1 & SELECT)==sel) {
 					fp= bezt->vec[0];
 
-					UI_ThemeColor(basecol + bezt->h1);
+					glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]);
 					glVertex3fv(fp); 
 					glVertex3fv(fp+3); 
 				}
 				else if( (bezt->f3 & SELECT)==sel) {
 					fp= bezt->vec[1];
 
-					UI_ThemeColor(basecol + bezt->h2);
+					glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]);
 					glVertex3fv(fp); 
 					glVertex3fv(fp+3); 
 				}
 			}
 			bezt++;
 		}
+
+#undef TH_HANDLE_COL_TOT
+
 	}
 	glEnd();
 }




More information about the Bf-blender-cvs mailing list