[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30891] trunk/blender/source/blender/ editors: bugfix [#20038] Vertex path selection not working in Vertex/ Face mode

Campbell Barton ideasman42 at gmail.com
Fri Jul 30 10:44:13 CEST 2010


Revision: 30891
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30891
Author:   campbellbarton
Date:     2010-07-30 10:43:22 +0200 (Fri, 30 Jul 2010)

Log Message:
-----------
bugfix [#20038] Vertex path selection not working in Vertex/Face mode
- disable this tool if edge mode isnt enabled using its poll function. Also fixed a bug where it would de-select the last active edge.
- made view3d grid drawing use GL_LINES's for less context switching.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/editmesh_mods.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c

Modified: trunk/blender/source/blender/editors/mesh/editmesh_mods.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_mods.c	2010-07-30 06:48:18 UTC (rev 30890)
+++ trunk/blender/source/blender/editors/mesh/editmesh_mods.c	2010-07-30 08:43:22 UTC (rev 30891)
@@ -2150,7 +2150,7 @@
 			if(ese && ese->type == EDITEDGE) {
 				eed_act = (EditEdge*)ese->data;
 				if (eed_act != eed) {
-					if (edgetag_shortest_path(vc.scene, em, eed_act, eed)) {
+					if (edgetag_shortest_path(vc.scene, em, eed_act, eed)) { /* <- this is where the magic happens */
 						EM_remove_selection(em, eed_act, EDITEDGE);
 						path = 1;
 					}
@@ -2163,13 +2163,19 @@
 		}
 
 		/* even if this is selected it may not be in the selection list */
-		if(edgetag_context_check(vc.scene, eed)==EDGE_MODE_SELECT)
+		if(edgetag_context_check(vc.scene, eed)==0) {
 			EM_remove_selection(em, eed, EDITEDGE);
+		}
 		else {
 			/* other modes need to keep the last edge tagged */
-			if(eed_act)
-				EM_select_edge(eed_act, 0);
+			if(eed_act) {
+				if(vc.scene->toolsettings->edge_mode!=EDGE_MODE_SELECT) {
+					/* for non-select modes, always de-select the previous active edge */
+					EM_select_edge(eed_act, 0);
+				}
+			}
 
+			/* set the new edge active */
 			EM_select_edge(eed, 1);
 			EM_store_selection(em, eed, EDITEDGE);
 		}
@@ -2208,6 +2214,16 @@
 	
 	return OPERATOR_FINISHED;
 }
+
+static int mesh_shortest_path_select_poll(bContext *C)
+{
+	if(ED_operator_editmesh_view3d(C)) {
+		Object *obedit= CTX_data_edit_object(C);
+		EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
+		return (em->selectmode & SCE_SELECT_EDGE);
+	}
+	return 0;
+}
 	
 void MESH_OT_select_shortest_path(wmOperatorType *ot)
 {
@@ -2218,7 +2234,7 @@
 	
 	/* api callbacks */
 	ot->invoke= mesh_shortest_path_select_invoke;
-	ot->poll= ED_operator_editmesh_view3d;
+	ot->poll= mesh_shortest_path_select_poll;
 	
 	/* flags */
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2010-07-30 06:48:18 UTC (rev 30890)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2010-07-30 08:43:22 UTC (rev 30891)
@@ -211,28 +211,37 @@
 
 
 static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, float dx)
-{
-	float fx, fy;
-	
+{	
+	float v1[2], v2[2];
+
 	x+= (wx); 
 	y+= (wy);
-	fx= x/dx;
-	fx= x-dx*floor(fx);
+
+	v1[1]= 0.0f;
+	v2[1]= (float)ar->winy;
+
+	v1[0] = v2[0] = x-dx*floor(x/dx);
 	
-	while(fx< ar->winx) {
-		fdrawline(fx,  0.0,  fx,  (float)ar->winy); 
-		fx+= dx; 
+	glBegin(GL_LINES);
+	
+	while(v1[0] < ar->winx) {
+		glVertex2fv(v1);
+		glVertex2fv(v2);
+		v1[0] = v2[0] = v1[0] + dx;
 	}
 
-	fy= y/dx;
-	fy= y-dx*floor(fy);
-	
+	v1[0]= 0.0f;
+	v2[0]= (float)ar->winx;
 
-	while(fy< ar->winy) {
-		fdrawline(0.0,  fy,  (float)ar->winx,  fy); 
-		fy+= dx;
+	v1[1]= v2[1]= y-dx*floor(y/dx);
+
+	while(v1[1] < ar->winy) {
+		glVertex2fv(v1);
+		glVertex2fv(v2);
+		v1[1] = v2[1] = v1[1] + dx;
 	}
 
+	glEnd();
 }
 
 #define GRID_MIN_PX 6.0f





More information about the Bf-blender-cvs mailing list