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.
This commit is contained in:
Campbell Barton 2008-03-26 16:06:25 +00:00
parent b46bad83bf
commit 4197e37200
9 changed files with 97 additions and 83 deletions

@ -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

@ -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);

@ -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; S<numVerts; S++) {

@ -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 */

@ -787,13 +787,11 @@ void draw_uvs_sima(void)
}
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]);

@ -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;

@ -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;

@ -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,11 +1516,14 @@ 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;
efa_act = EM_get_actFace();
if (efa_act) {
ret= pupmenu(
"Copy Face Selected%t|"
"Active Material%x1|Active Image%x2|Active UV Coords%x3|"
@ -1524,11 +1533,20 @@ void mesh_copy_menu(void)
"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");
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 == EDITFACE) BIF_undo_push("Copy Face Attribute");
else if ( ese->type == EDITVERT) BIF_undo_push("Copy Vert Attribute");
}
}

@ -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 */