[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45805] trunk/blender/source/blender/ editors/mesh/editmesh_knife.c: knife tool: store color once on initializations, de-select only when cutting selected.

Campbell Barton ideasman42 at gmail.com
Fri Apr 20 14:05:10 CEST 2012


Revision: 45805
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45805
Author:   campbellbarton
Date:     2012-04-20 12:05:08 +0000 (Fri, 20 Apr 2012)
Log Message:
-----------
knife tool: store color once on initializations, de-select only when cutting selected.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/editmesh_knife.c

Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2012-04-20 11:14:16 UTC (rev 45804)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2012-04-20 12:05:08 UTC (rev 45805)
@@ -71,6 +71,15 @@
 
 #define KMAXDIST    10  /* max mouse distance from edge before not detecting it */
 
+typedef struct KnifeColors {
+	unsigned char line[3];
+	unsigned char edge[3];
+	unsigned char curpoint[3];
+	unsigned char curpoint_a[4];
+	unsigned char point[3];
+	unsigned char point_a[4];
+} KnifeColors;
+
 /* knifetool operator */
 typedef struct KnifeVert {
 	BMVert *v; /* non-NULL if this is an original vert */
@@ -158,13 +167,14 @@
 
 	float projmat[4][4];
 
-	short is_ortho;
+	KnifeColors colors;
 
 	/* operatpr options */
 	char  cut_through; /* preference, can be modified at runtime (that feature may go) */
 	char  only_select; /* set on initialization */
 	char  select_result; /* set on initialization */
 
+	short is_ortho;
 	float clipsta, clipend;
 
 	enum {
@@ -876,23 +886,19 @@
 	glEnd();
 }
 
-static void knife_colors(unsigned char c_line[3],
-                         unsigned char c_edge[3],
-                         unsigned char c_curpoint[3],
-                         unsigned char c_curpoint_a[4],
-                         unsigned char c_point[3],
-                         unsigned char c_point_a[4]) {
-          /* possible BMESH_TODO: add explicit themes or calculate these by
-            * figuring out constrasting colors with grid / edges / verts
-            * a la UI_make_axis_color */
-	UI_GetThemeColor3ubv(TH_NURB_VLINE, c_line);
-	UI_GetThemeColor3ubv(TH_NURB_ULINE, c_edge);
-	UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, c_curpoint);
-	UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, c_curpoint_a);
-	c_curpoint_a[3] = 0.4;
-	UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, c_point);
-	UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, c_point_a);
-	c_point_a[3] = 0.4;
+static void knife_init_colors(KnifeColors *colors)
+{
+	/* possible BMESH_TODO: add explicit themes or calculate these by
+	 * figuring out constrasting colors with grid / edges / verts
+	 * a la UI_make_axis_color */
+	UI_GetThemeColor3ubv(TH_NURB_VLINE, colors->line);
+	UI_GetThemeColor3ubv(TH_NURB_ULINE, colors->edge);
+	UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, colors->curpoint);
+	UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, colors->curpoint_a);
+	colors->curpoint_a[3] = 0.4;
+	UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, colors->point);
+	UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, colors->point_a);
+	colors->point_a[3] = 0.4;
 }
 
 /* modal loop selection drawing callback */
@@ -900,8 +906,6 @@
 {
 	View3D *v3d = CTX_wm_view3d(C);
 	knifetool_opdata *kcd = arg;
-	unsigned char c_line[3], c_edge[3], c_curpoint[3], c_point[3];
-	unsigned char c_curpoint_a[4], c_point_a[4];
 
 	if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
 
@@ -910,13 +914,11 @@
 	glPushMatrix();
 	glMultMatrixf(kcd->ob->obmat);
 
-	knife_colors(c_line, c_edge, c_curpoint, c_curpoint_a, c_point, c_point_a);
-
 	if (kcd->mode == MODE_DRAGGING) {
 		if (kcd->angle_snapping != ANGLE_FREE)
 			knifetool_draw_angle_snapping(kcd);
 
-		glColor3ubv(c_line);
+		glColor3ubv(kcd->colors.line);
 		
 		glLineWidth(2.0);
 
@@ -929,7 +931,7 @@
 	}
 
 	if (kcd->cur.edge) {
-		glColor3ubv(c_edge);
+		glColor3ubv(kcd->colors.edge);
 		glLineWidth(2.0);
 
 		glBegin(GL_LINES);
@@ -940,7 +942,7 @@
 		glLineWidth(1.0);
 	}
 	else if (kcd->cur.vert) {
-		glColor3ubv(c_point);
+		glColor3ubv(kcd->colors.point);
 		glPointSize(11);
 
 		glBegin(GL_POINTS);
@@ -949,7 +951,7 @@
 	}
 
 	if (kcd->cur.bmface) {
-		glColor3ubv(c_curpoint);
+		glColor3ubv(kcd->colors.curpoint);
 		glPointSize(9);
 
 		glBegin(GL_POINTS);
@@ -965,7 +967,7 @@
 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
 		/* draw any snapped verts first */
-		glColor4ubv(c_point_a);
+		glColor4ubv(kcd->colors.point_a);
 		glPointSize(11);
 		glBegin(GL_POINTS);
 		lh = kcd->linehits;
@@ -990,7 +992,7 @@
 		glEnd();
 
 		/* now draw the rest */
-		glColor4ubv(c_curpoint_a);
+		glColor4ubv(kcd->colors.curpoint_a);
 		glPointSize(7);
 		glBegin(GL_POINTS);
 		lh = kcd->linehits;
@@ -1013,7 +1015,7 @@
 			if (!kfe->draw)
 				continue;
 
-			glColor3ubv(c_line);
+			glColor3ubv(kcd->colors.line);
 
 			glVertex3fv(kfe->v1->cageco);
 			glVertex3fv(kfe->v2->cageco);
@@ -1035,7 +1037,7 @@
 			if (!kfv->draw)
 				continue;
 
-			glColor3ubv(c_point);
+			glColor3ubv(kcd->colors.point);
 
 			glVertex3fv(kfv->cageco);
 		}
@@ -2655,7 +2657,7 @@
 		}
 	}
 
-	if (kcd->select_result) {
+	if (kcd->only_select) {
 		EDBM_flag_disable_all(kcd->em, BM_ELEM_SELECT);
 	}
 
@@ -2845,6 +2847,8 @@
 	knife_pos_data_clear(&kcd->cur);
 	knife_pos_data_clear(&kcd->prev);
 
+	knife_init_colors(&kcd->colors);
+
 	return 1;
 }
 




More information about the Bf-blender-cvs mailing list