[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14247] trunk/blender/source/blender: made editmode face copy menu appier with when there is no active face ( without options that required an active face)

Campbell Barton ideasman42 at gmail.com
Wed Mar 26 17:06:25 CET 2008


Revision: 14247
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14247
Author:   campbellbarton
Date:     2008-03-26 17:06:25 +0100 (Wed, 26 Mar 2008)

Log Message:
-----------
made editmode face copy menu appier with when there is no active face (without options that required an active face)
active face drawing didnt always work since it used the last selected element for drawing.
moved stipple into glutil.c rather then using 128 bytes in the stack for each stipple draw.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
    trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
    trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
    trunk/blender/source/blender/include/BIF_gl.h
    trunk/blender/source/blender/src/drawimage.c
    trunk/blender/source/blender/src/drawobject.c
    trunk/blender/source/blender/src/drawseq.c
    trunk/blender/source/blender/src/editmesh_mods.c
    trunk/blender/source/blender/src/glutil.c

Modified: trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2008-03-26 16:06:25 UTC (rev 14247)
@@ -440,23 +440,5 @@
 /* determines required DerivedMesh data according to view and edit modes */
 CustomDataMask get_viewedit_datamask();
 
-/*  repeate this pattern
-   X000X000
-   00000000
-   00X000X0
-   00000000 */
-
-#define DM_FACE_STIPPLE \
-{ \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
-	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0 \
-}
-
 #endif
 

Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2008-03-26 16:06:25 UTC (rev 14247)
@@ -636,7 +636,6 @@
 }
 static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors)
 {
-	GLubyte act_face_stipple[32*32/8] = DM_FACE_STIPPLE;
 	EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
 	EditFace *efa;
 	int i, draw;
@@ -653,7 +652,7 @@
 			if(draw) {
 				if (draw==2) { /* enabled with stipple */
 		  			glEnable(GL_POLYGON_STIPPLE);
-		  			glPolygonStipple(act_face_stipple);
+		  			glPolygonStipple(stipple_quarttone);
 				}
 				
 				glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
@@ -690,7 +689,7 @@
 			if(draw) {
 				if (draw==2) { /* enabled with stipple */
 		  			glEnable(GL_POLYGON_STIPPLE);
-		  			glPolygonStipple(act_face_stipple);
+		  			glPolygonStipple(stipple_quarttone);
 				}
 				glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
 

Modified: trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2008-03-26 16:06:25 UTC (rev 14247)
@@ -1910,7 +1910,6 @@
 }
 
 static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors) {
-	GLubyte act_face_stipple[32*32/8] = DM_FACE_STIPPLE;
 	CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
 	CCGSubSurf *ss = ccgdm->ss;
 	CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
@@ -1935,7 +1934,7 @@
 			if (draw) {
 				if (draw==2) {
 		  			glEnable(GL_POLYGON_STIPPLE);
-		  			glPolygonStipple(act_face_stipple);
+		  			glPolygonStipple(stipple_quarttone);
 				}
 				
 				for (S=0; S<numVerts; S++) {

Modified: trunk/blender/source/blender/include/BIF_gl.h
===================================================================
--- trunk/blender/source/blender/include/BIF_gl.h	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/include/BIF_gl.h	2008-03-26 16:06:25 UTC (rev 14247)
@@ -83,5 +83,9 @@
 
 #define lrectwrite(a, b, c, d, rect)	{glRasterPos2i(a,  b);glDrawPixels((c)-(a)+1, (d)-(b)+1, GL_RGBA, GL_UNSIGNED_BYTE,  rect);}
 
+/* glStippleDefines, defined in glutil.c */
+extern GLubyte stipple_halftone[128];
+extern GLubyte stipple_quarttone[128];
+
 #endif /* #ifdef BIF_GL_H */
 

Modified: trunk/blender/source/blender/src/drawimage.c
===================================================================
--- trunk/blender/source/blender/src/drawimage.c	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/src/drawimage.c	2008-03-26 16:06:25 UTC (rev 14247)
@@ -787,13 +787,11 @@
 	}
 	
 	if (activetface) {
-		GLubyte act_face_stipple[32*32/8] = DM_FACE_STIPPLE;
-		
 		glEnable(GL_BLEND);
 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 		BIF_ThemeColor4(TH_EDITMESH_ACTIVE);
 		glEnable(GL_POLYGON_STIPPLE);
-		glPolygonStipple(act_face_stipple);
+		glPolygonStipple(stipple_quarttone);
 		glBegin(efa_act->v4?GL_QUADS:GL_TRIANGLES);
 			glVertex2fv(activetface->uv[0]);
 			glVertex2fv(activetface->uv[1]);

Modified: trunk/blender/source/blender/src/drawobject.c
===================================================================
--- trunk/blender/source/blender/src/drawobject.c	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/src/drawobject.c	2008-03-26 16:06:25 UTC (rev 14247)
@@ -2061,15 +2061,16 @@
 static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt)
 {
 	Mesh *me = ob->data;
-	EditFace *efa_act = NULL;
+	EditFace *efa_act = EM_get_actFace(); /* annoying but active faces is stored differently */
 	EditEdge *eed_act = NULL;
 	EditVert *eve_act = NULL;
 	
 	if (G.editMesh->selected.last) {
 		EditSelection *ese = G.editMesh->selected.last;
-		if ( ese->type == EDITFACE ) {
+		/* face is handeled above */
+		/*if (ese->type == EDITFACE ) {
 			efa_act = (EditFace *)ese->data;
-		} else if ( ese->type == EDITEDGE ) {
+		} else */ if ( ese->type == EDITEDGE ) {
 			eed_act = (EditEdge *)ese->data;
 		} else if ( ese->type == EDITVERT ) {
 			eve_act = (EditVert *)ese->data;

Modified: trunk/blender/source/blender/src/drawseq.c
===================================================================
--- trunk/blender/source/blender/src/drawseq.c	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/src/drawseq.c	2008-03-26 16:06:25 UTC (rev 14247)
@@ -92,24 +92,6 @@
 #define SEQ_STRIP_OFSBOTTOM		0.2
 #define SEQ_STRIP_OFSTOP		0.8
 
-static GLubyte halftone[] = {
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
-			0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55};
-
 /* Note, Dont use WHILE_SEQ while drawing! - it messes up transform, - Campbell */
 
 int no_rightbox=0, no_leftbox= 0;
@@ -240,7 +222,7 @@
 
 	if (seqm->flag & SEQ_MUTE) {
 		glEnable(GL_POLYGON_STIPPLE);
-		glPolygonStipple(halftone);
+		glPolygonStipple(stipple_halftone);
 		
 		glEnable(GL_LINE_STIPPLE);
 		glLineStipple(1, 0x8888);
@@ -636,7 +618,7 @@
 	
 	if (seq->flag & SEQ_MUTE) {
 		glEnable(GL_POLYGON_STIPPLE);
-		glPolygonStipple(halftone);
+		glPolygonStipple(stipple_halftone);
 	}
 	
 	ymid1 = (y2-y1)*0.25 + y1;

Modified: trunk/blender/source/blender/src/editmesh_mods.c
===================================================================
--- trunk/blender/source/blender/src/editmesh_mods.c	2008-03-26 15:59:56 UTC (rev 14246)
+++ trunk/blender/source/blender/src/editmesh_mods.c	2008-03-26 16:06:25 UTC (rev 14247)
@@ -1445,15 +1445,21 @@
 	
 	ese = em->selected.last;
 	
-	if (!ese) return;
+	/* Faces can have a NULL ese, so dont return on a NULL ese here */
 	
-	if(ese->type == EDITVERT) {
+	if(ese && ese->type == EDITVERT) {
+		
+		if (!ese) return;
 		/*EditVert *ev, *ev_act = (EditVert*)ese->data;
 		ret= pupmenu("");*/
-	} else if(ese->type == EDITEDGE) {
-		EditEdge *eed, *eed_act = (EditEdge*)ese->data;
+	} else if(ese && ese->type == EDITEDGE) {
+		EditEdge *eed, *eed_act;
 		float vec[3], vec_mid[3], eed_len, eed_len_act;
 		
+		if (!ese) return;
+		
+		eed_act = (EditEdge*)ese->data;
+		
 		ret= pupmenu("Copy Active Edge to Selected%t|Crease%x1|Length%x2");
 		if (ret<1) return;
 		
@@ -1510,26 +1516,38 @@
 			break;
 		}
 		
-	} else if(ese->type == EDITFACE) {
-		EditFace *efa, *efa_act = (EditFace*)ese->data;
-		MTFace *tf, *tf_act;
-		MCol *mcol, *mcol_act;
+	} else if(ese==NULL || ese->type == EDITFACE) {
+		EditFace *efa, *efa_act;
+		MTFace *tf, *tf_act = NULL;
+		MCol *mcol, *mcol_act = NULL;
 		
-		ret= pupmenu(
-			"Copy Face Selected%t|"
-			"Active Material%x1|Active Image%x2|Active UV Coords%x3|"
-			"Active Mode%x4|Active Transp%x5|Active Vertex Colors%x6|%l|"
-			
-			"TexFace UVs from layer%x7|"
-			"TexFace Images from layer%x8|"
-			"TexFace All from layer%x9|"
-			"Vertex Colors from layer%x10");
+		efa_act = EM_get_actFace();
 		
-		if (ret<1) return;
+		if (efa_act) {
+			ret= pupmenu(
+				"Copy Face Selected%t|"
+				"Active Material%x1|Active Image%x2|Active UV Coords%x3|"
+				"Active Mode%x4|Active Transp%x5|Active Vertex Colors%x6|%l|"
+				
+				"TexFace UVs from layer%x7|"
+				"TexFace Images from layer%x8|"
+				"TexFace All from layer%x9|"
+				"Vertex Colors from layer%x10");
+			if (ret<1) return;
+			tf_act =	CustomData_em_get(&em->fdata, efa_act->data, CD_MTFACE);
+			mcol_act =	CustomData_em_get(&em->fdata, efa_act->data, CD_MCOL);
+		} else {
+			ret= pupmenu(
+				"Copy Face Selected%t|"
+				
+				/* Make sure these are always the same as above */
+				"TexFace UVs from layer%x7|"
+				"TexFace Images from layer%x8|"
+				"TexFace All from layer%x9|"
+				"Vertex Colors from layer%x10");
+			if (ret<1) return;
+		}
 		
-		tf_act =	CustomData_em_get(&em->fdata, efa_act->data, CD_MTFACE);
-		mcol_act =	CustomData_em_get(&em->fdata, efa_act->data, CD_MCOL);
-		
 		switch (ret) {
 		case 1: /* copy material */
 			for(efa=em->faces.first; efa; efa=efa->next) {
@@ -1637,15 +1655,11 @@
 			
 			break;
 		
-		
-		/* copy from layer */
+		/* Copy from layer - Warning! tf_act and mcol_act will be NULL here */
 		case 7:
 		case 8:
 		case 9:
-			if (!tf_act) {
-				error("mesh has no uv/image layers");
-				return;
-			} else if (CustomData_number_of_layers(&em->fdata, CD_MTFACE)<2) {
+			if (CustomData_number_of_layers(&em->fdata, CD_MTFACE)<2) {
 				error("mesh does not have multiple uv/image layers");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list