From 4197e37200518e18d251a2f43cb9e5e39b6f2d02 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 26 Mar 2008 16:06:25 +0000 Subject: [PATCH] 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. --- source/blender/blenkernel/BKE_DerivedMesh.h | 18 ----- .../blender/blenkernel/intern/DerivedMesh.c | 5 +- .../blender/blenkernel/intern/subsurf_ccg.c | 3 +- source/blender/include/BIF_gl.h | 4 + source/blender/src/drawimage.c | 4 +- source/blender/src/drawobject.c | 7 +- source/blender/src/drawseq.c | 22 +---- source/blender/src/editmesh_mods.c | 80 +++++++++++-------- source/blender/src/glutil.c | 37 +++++++++ 9 files changed, 97 insertions(+), 83 deletions(-) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 29fc1438c47..5f3c1ea4a0a 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -440,23 +440,5 @@ void weight_to_rgb(float input, float *fr, float *fg, float *fb); /* 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 diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c263b4aae8c..faadb8b2f5f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -636,7 +636,6 @@ static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *use } 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 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us 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 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us 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); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 7a0c47237e7..1edd4eeedca 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1910,7 +1910,6 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm) } 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 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u if (draw) { if (draw==2) { glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(act_face_stipple); + glPolygonStipple(stipple_quarttone); } for (S=0; Sv4?GL_QUADS:GL_TRIANGLES); glVertex2fv(activetface->uv[0]); glVertex2fv(activetface->uv[1]); diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 9ddf5e405dd..e3c11c80468 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2061,15 +2061,16 @@ static int draw_em_fancy__setFaceOpts(void *userData, int index, int *drawSmooth 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; diff --git a/source/blender/src/drawseq.c b/source/blender/src/drawseq.c index 6efd109358b..f132e4531e1 100644 --- a/source/blender/src/drawseq.c +++ b/source/blender/src/drawseq.c @@ -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 @@ static void drawmeta_contents(Sequence *seqm, float x1, float y1, float x2, floa 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 @@ static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float if (seq->flag & SEQ_MUTE) { glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(halftone); + glPolygonStipple(stipple_halftone); } ymid1 = (y2-y1)*0.25 + y1; diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index 9c8b6597ff1..6cf7d914d42 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -1445,15 +1445,21 @@ void mesh_copy_menu(void) 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,25 +1516,37 @@ void mesh_copy_menu(void) 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; - - tf_act = CustomData_em_get(&em->fdata, efa_act->data, CD_MTFACE); - mcol_act = CustomData_em_get(&em->fdata, efa_act->data, CD_MCOL); + 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; + } switch (ret) { case 1: /* copy material */ @@ -1637,15 +1655,11 @@ void mesh_copy_menu(void) 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"); return; } else { @@ -1672,10 +1686,7 @@ void mesh_copy_menu(void) break; case 10: /* select vcol layers - make sure this stays in sync with above code */ - if (!mcol_act) { - error("mesh has no color layers"); - return; - } else if (CustomData_number_of_layers(&em->fdata, CD_MCOL)<2) { + if (CustomData_number_of_layers(&em->fdata, CD_MCOL)<2) { error("mesh does not have multiple color layers"); return; } else { @@ -1764,9 +1775,10 @@ void mesh_copy_menu(void) allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWBUTSEDIT, 0); - if(ese->type == EDITVERT) BIF_undo_push("Copy Vert Attribute"); - else if (ese->type == EDITEDGE) BIF_undo_push("Copy Edge Attribute"); - else if (ese->type == EDITFACE) BIF_undo_push("Copy Face Attribute"); + if (ese==NULL || ese->type == EDITFACE) BIF_undo_push("Copy Face Attribute"); + else if ( ese->type == EDITEDGE) BIF_undo_push("Copy Edge Attribute"); + else if ( ese->type == EDITVERT) BIF_undo_push("Copy Vert Attribute"); + } } diff --git a/source/blender/src/glutil.c b/source/blender/src/glutil.c index 13922bb7eef..a11127a5496 100644 --- a/source/blender/src/glutil.c +++ b/source/blender/src/glutil.c @@ -54,6 +54,43 @@ #define GL_CLAMP_TO_EDGE 0x812F #endif +/* defined in BIF_gl.h */ +GLubyte stipple_halftone[128] = { + 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}; + + +/* repeate this pattern + X000X000 + 00000000 + 00X000X0 + 00000000 */ + + +GLubyte stipple_quarttone[128] = { + 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}; + /* Invert line handling */