diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-29 21:54:22 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-29 21:54:22 +0300 |
commit | 5f9ee2cbfe3770838482e7c8f37194f127e8a8c5 (patch) | |
tree | 8ec3a82dec1df1cac6e7bfae5a7309ecc0da329e | |
parent | 2869ce6cfab3aa4ff471bef6e49ac6fe15426247 (diff) |
2.5
- Made WM_cursor_wait() work without context or pointers,
like old waitcursor(). Only use when operations entirely
block UI. It will set waitcursor for all open windows.
- Cleanup in mesh tools, removing old cruft, and prepare
for more goodies for shul to work on!
-rw-r--r-- | source/blender/editors/mesh/editmesh.c | 30 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 260 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_mods.c | 72 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 10 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_windowmanager_types.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 35 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_cursors.h | 4 |
9 files changed, 92 insertions, 327 deletions
diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index adb45db40f2..f61d340808a 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -77,6 +77,7 @@ #include "BIF_retopo.h" #include "ED_mesh.h" +#include "ED_object.h" #include "ED_util.h" #include "ED_view3d.h" @@ -92,11 +93,8 @@ editmesh.c: /* XXX */ static void BIF_undo_push() {} -static void waitcursor() {} static void error() {} static int pupmenu() {return 0;} -static void key_to_mesh() {} -static void adduplicate() {} /* ***************** HASH ********************* */ @@ -851,8 +849,6 @@ void make_editMesh(Scene *scene, Object *ob) actkey = ob_get_keyblock(ob); if(actkey) { - // XXX strcpy(G.editModeTitleExtra, "(Key) "); - key_to_mesh(actkey, me); tot= actkey->totelem; /* undo-ing in past for previous editmode sessions gives corrupt 'keyindex' values */ undo_editmode_clear(); @@ -1424,8 +1420,6 @@ void load_editMesh(Scene *scene, Object *ob) void remake_editMesh(Scene *scene, Object *ob) { make_editMesh(scene, ob); -// allqueue(REDRAWVIEW3D, 0); -// allqueue(REDRAWBUTSOBJECT, 0); /* needed to have nice cloth panels */ DAG_object_flush_update(scene, ob, OB_RECALC_DATA); BIF_undo_push("Undo all changes"); } @@ -1448,8 +1442,6 @@ void separate_mesh(Scene *scene, Object *obedit) if(obedit==NULL) return; - waitcursor(1); - me= obedit->data; em= me->edit_mesh; if(me->key) { @@ -1527,7 +1519,7 @@ void separate_mesh(Scene *scene, Object *obedit) oldob= obedit; oldbase= BASACT; - adduplicate(1, 0); /* notrans and a linked duplicate */ +// XXX adduplicate(1, 0); /* notrans and a linked duplicate */ obedit= BASACT->object; /* basact was set in adduplicate() */ @@ -1562,9 +1554,6 @@ void separate_mesh(Scene *scene, Object *obedit) BASACT= oldbase; BASACT->flag |= SELECT; - waitcursor(0); - -// allqueue(REDRAWVIEW3D, 0); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); } @@ -1595,7 +1584,6 @@ void separate_material(Scene *scene, Object *obedit) } } - // allqueue(REDRAWVIEW3D, 0); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); } @@ -1621,8 +1609,6 @@ void separate_mesh_loose(Scene *scene, Object *obedit) return; } - waitcursor(1); - /* we are going to abuse the system as follows: * 1. add a duplicate object: this will be the new one, we remember old pointer * 2: then do a split if needed. @@ -1637,7 +1623,7 @@ void separate_mesh_loose(Scene *scene, Object *obedit) /* make only obedit selected */ base= FIRSTBASE; while(base) { -// XXX if(base->lay & G.vd->lay) { +// if(base->lay & G.vd->lay) { if(base->object==obedit) base->flag |= SELECT; else base->flag &= ~SELECT; // } @@ -1720,7 +1706,7 @@ void separate_mesh_loose(Scene *scene, Object *obedit) oldob= obedit; oldbase= BASACT; - adduplicate(1, 0); /* notrans and a linked duplicate*/ +// XXX adduplicate(1, 0); /* notrans and a linked duplicate*/ obedit= BASACT->object; /* basact was set in adduplicate() */ @@ -1760,8 +1746,6 @@ void separate_mesh_loose(Scene *scene, Object *obedit) /* unselect the vertices that we (ab)used for the separation*/ EM_clear_flag_all(em, SELECT); - waitcursor(0); -// allqueue(REDRAWVIEW3D, 0); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); } @@ -1775,7 +1759,6 @@ void separatemenu(Scene *scene, Object *obedit) event = pupmenu("Separate %t|Selected%x1|All Loose Parts%x2|By Material%x3"); if (event==0) return; - waitcursor(1); switch (event) { case 1: @@ -1788,7 +1771,6 @@ void separatemenu(Scene *scene, Object *obedit) separate_material(scene, obedit); break; } - waitcursor(0); } @@ -1848,9 +1830,6 @@ static void free_undoMesh(void *umv) { UndoMesh *um= umv; - if (um == NULL) - return; /* XXX FIX ME, THIS SHOULD NEVER BE TRUE YET IT HAPPENS DURING TRANSFORM */ - if(um->verts) MEM_freeN(um->verts); if(um->edges) MEM_freeN(um->edges); if(um->faces) MEM_freeN(um->faces); @@ -1865,7 +1844,6 @@ static void free_undoMesh(void *umv) static void *editMesh_to_undoMesh(void *emv) { EditMesh *em= (EditMesh *)emv; -// Scene *scene= NULL; UndoMesh *um; EditVert *eve; EditEdge *eed; diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index e0712290081..54445f87150 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -76,7 +76,6 @@ /* XXX */ static void BIF_undo_push() {} -static void waitcursor() {} static void error() {} static int pupmenu() {return 0;} #define add_numbut(a, b, c, d, e, f, g) {} @@ -119,34 +118,36 @@ static short icoface[20][3] = { {10,9,11} }; -static void get_view_aligned_coordinate(float *fp, short mval[2]) +static void get_view_aligned_coordinate(ViewContext *vc, float *fp, short mval[2]) { -// float dvec[3]; -// short mx, my; + float dvec[3]; + short mx, my; -// mx= mval[0]; -// my= mval[1]; + mx= mval[0]; + my= mval[1]; -// XXX project_short_noclip(ar, v3d, fp, mval); + project_short_noclip(vc->ar, fp, mval); -// XXX initgrabz(fp[0], fp[1], fp[2]); + initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); -// if(mval[0]!=IS_CLIPPED) { -// window_to_3d_delta(dvec, mval[0]-mx, mval[1]-my); -// VecSubf(fp, fp, dvec); -// } + if(mval[0]!=IS_CLIPPED) { + window_to_3d_delta(vc->ar, dvec, mval[0]-mx, mval[1]-my); + VecSubf(fp, fp, dvec); + } } -void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em) +void add_click_mesh(bContext *C) { - View3D *v3d= NULL; // XXX + ViewContext vc; EditVert *eve, *v1; float min[3], max[3]; int done= 0; + em_setup_viewcontext(C, &vc); + INIT_MINMAX(min, max); - for(v1= em->verts.first;v1; v1=v1->next) { + for(v1= vc.em->verts.first;v1; v1=v1->next) { if(v1->f & SELECT) { DO_MINMAX(v1->co, min, max); done= 1; @@ -162,7 +163,7 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em) /* check for edges that are half selected, use for rotation */ done= 0; - for(eed= em->edges.first; eed; eed= eed->next) { + for(eed= vc.em->edges.first; eed; eed= eed->next) { if( (eed->v1->f & SELECT)+(eed->v2->f & SELECT) == SELECT ) { if(eed->v1->f & SELECT) VecSubf(vec, eed->v1->co, eed->v2->co); else VecSubf(vec, eed->v2->co, eed->v1->co); @@ -177,10 +178,10 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em) VecMulf(cent, 0.5f); VECCOPY(min, cent); - Mat4MulVecfl(obedit->obmat, min); // view space - get_view_aligned_coordinate(min, mval); - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, min); // back in object space + Mat4MulVecfl(vc.obedit->obmat, min); // view space + get_view_aligned_coordinate(&vc, min, mval); + Mat4Invert(vc.obedit->imat, vc.obedit->obmat); + Mat4MulVecfl(vc.obedit->imat, min); // back in object space VecSubf(min, min, cent); @@ -209,23 +210,23 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em) } } - extrudeflag(obedit, em, SELECT, nor); - rotateflag(em, SELECT, cent, mat); - translateflag(em, SELECT, min); + extrudeflag(vc.obedit, vc.em, SELECT, nor); + rotateflag(vc.em, SELECT, cent, mat); + translateflag(vc.em, SELECT, min); - recalc_editnormals(em); + recalc_editnormals(vc.em); } else { float mat[3][3],imat[3][3]; - float *curs= give_cursor(scene, v3d); + float *curs= give_cursor(vc.scene, vc.v3d); - eve= addvertlist(em, 0, NULL); + eve= addvertlist(vc.em, 0, NULL); - Mat3CpyMat4(mat, obedit->obmat); + Mat3CpyMat4(mat, vc.obedit->obmat); Mat3Inv(imat, mat); VECCOPY(eve->co, curs); - VecSubf(eve->co, eve->co, obedit->obmat[3]); + VecSubf(eve->co, eve->co, vc.obedit->obmat[3]); Mat3MulVecfl(imat, eve->co); @@ -235,9 +236,8 @@ void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em) //retopo_do_all(); BIF_undo_push("Add vertex/edge/face"); -// XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + DAG_object_flush_update(vc.scene, vc.obedit, OB_RECALC_DATA); - while(0); // XXX get_mbut()&R_MOUSE); } @@ -560,6 +560,7 @@ static void fix_new_face(EditMesh *em, EditFace *eface) } } +/* only adds quads or trias when there's edges already */ void addfaces_from_edgenet(EditMesh *em) { EditVert *eve1, *eve2, *eve3, *eve4; @@ -740,30 +741,6 @@ void addedgeface_mesh(EditMesh *em) } -void adduplicate_mesh(Scene *scene, Object *obedit, EditMesh *em) -{ - - waitcursor(1); - - adduplicateflag(em, SELECT); - - waitcursor(0); - - /* We need to force immediate calculation here because - * transform may use derived objects (which are now stale). - * - * This shouldn't be necessary, derived queries should be - * automatically building this data if invalid. Or something. - */ - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - object_handle_update(scene, obedit); - -// XXX BIF_TransformSetUndo("Add Duplicate"); -// initTransform(TFM_TRANSLATION, CTX_NO_PET); -// Transform(); -} - - // HACK: these can also be found in cmoview.tga.c, but are here so that they can be found by linker // this hack is only used so that scons+mingw + split-sources hack works // ------------------------------- start copied code @@ -1214,181 +1191,6 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se righthandfaces(em, 1); /* otherwise monkey has eyes in wrong direction */ } -#if 0 -void add_primitiveMesh(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em, int type) -{ - Mesh *me; - float *curs, d, dia, phi, phid, cent[3], imat[3][3], mat[3][3]; - float cmat[3][3]; - static int tot=32, seg=32, subdiv=2, - /* so each type remembers its fill setting */ - fill_circle=0, fill_cone=1, fill_cylinder=1; - - int ext=0, fill=0, totoud, newob=0; - char *undostr="Add Primitive"; - char *name=NULL; - -// if(scene->id.lib) return; - - /* this function also comes from an info window */ -// XXX if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return; - - /* if editmode exists for other type, it exits */ - check_editmode(OB_MESH); - - if(G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) { - G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT); - } - - totoud= tot; /* store, and restore when cube/plane */ - - dia= v3d->grid; - d= v3d->grid; - - /* ext==extrudeflag, tot==amount of vertices in basis */ - switch(type) { - case 0: /* plane */ - tot= 4; - ext= 0; - fill= 1; - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Plane"; - undostr="Add Plane"; - break; - case 1: /* cube */ - tot= 4; - ext= 1; - fill= 1; - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Cube"; - undostr="Add Cube"; - break; - case 4: /* circle */ - add_numbut(0, NUM|INT, "Vertices:", 3, 500, &tot, NULL); - add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL); - add_numbut(2, TOG|INT, "Fill", 0, 0, &(fill_circle), NULL); - if (!(do_clever_numbuts("Add Circle", 3, 0))) return; - ext= 0; - fill = fill_circle; - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Circle"; - undostr="Add Circle"; - break; - case 5: /* cylinder */ - d*=2; - add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL); - add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL); - add_numbut(2, NUM|FLO, "Depth:", 0.001*v3d->grid, 100*v3d->grid, &d, NULL); - add_numbut(3, TOG|INT, "Cap Ends", 0, 0, &(fill_cylinder), NULL); - if (!(do_clever_numbuts("Add Cylinder", 4, 0))) return; - ext= 1; - fill = fill_cylinder; - d/=2; - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) { - if (fill) name = "Cylinder"; - else name = "Tube"; - } - undostr="Add Cylinder"; - break; - case 7: /* cone */ - d*=2; - add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL); - add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL); - add_numbut(2, NUM|FLO, "Depth:", 0.001*v3d->grid, 100*v3d->grid, &d, NULL); - add_numbut(3, TOG|INT, "Cap End", 0, 0, &(fill_cone), NULL); - if (!(do_clever_numbuts("Add Cone", 4, 0))) return; - d/=2; - ext= 0; - fill = fill_cone; - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Cone"; - undostr="Add Cone"; - break; - case 10: /* grid */ - add_numbut(0, NUM|INT, "X res:", 3, 1000, &tot, NULL); - add_numbut(1, NUM|INT, "Y res:", 3, 1000, &seg, NULL); - if (!(do_clever_numbuts("Add Grid", 2, 0))) return; - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Grid"; - undostr="Add Grid"; - break; - case 11: /* UVsphere */ - add_numbut(0, NUM|INT, "Segments:", 3, 500, &seg, NULL); - add_numbut(1, NUM|INT, "Rings:", 3, 500, &tot, NULL); - add_numbut(2, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL); - - if (!(do_clever_numbuts("Add UV Sphere", 3, 0))) return; - - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Sphere"; - undostr="Add UV Sphere"; - break; - case 12: /* Icosphere */ - add_numbut(0, NUM|INT, "Subdivision:", 1, 8, &subdiv, NULL); - add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL); - if (!(do_clever_numbuts("Add Ico Sphere", 2, 0))) return; - - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Sphere"; - undostr="Add Ico Sphere"; - break; - case 13: /* Monkey */ - newob = confirm_objectExists(scene, obedit, &me, mat ); - if(newob) name = "Suzanne"; - undostr="Add Monkey"; - break; - default: - newob = confirm_objectExists(scene, obedit, &me, mat ); - break; - } - - if( name!=NULL ) { - rename_id((ID *)obedit, name ); - rename_id((ID *)me, name ); - } - - d = -d; - curs= give_cursor(scene, v3d); - VECCOPY(cent, curs); - cent[0]-= obedit->obmat[3][0]; - cent[1]-= obedit->obmat[3][1]; - cent[2]-= obedit->obmat[3][2]; - - if ( !(newob) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, v3d->viewmat); - else Mat3One(imat); - Mat3MulVecfl(imat, cent); - Mat3MulMat3(cmat, imat, mat); - Mat3Inv(imat,cmat); - - - if(type == 0 || type == 1) /* plane, cube (diameter of 1.41 makes it unit size) */ - dia *= sqrt(2.0); - - phid= 2*M_PI/tot; - phi= .25*M_PI; - - make_prim(obedit, type, imat, tot, seg, subdiv, dia, d, ext, fill, cent); - - if(type<2) tot = totoud; - - /* simple selection flush OK, based on fact it's a single model */ - EM_select_flush(em); // flushes vertex -> edge -> face selection - - if(type!=0 && type!=13) righthandfaces(em, 1); /* otherwise monkey has eyes in wrong direction... */ - -// XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - - /* if a new object was created, it stores it in Mesh, for reload original data and undo */ - if ( !(newob) || U.flag & USER_ADD_EDITMODE) { - if(newob) load_editMesh(scene, obedit); - } else { - exit_editmode(2); - } - - BIF_undo_push(undostr); -} -#endif /* uses context to figure out transform for primitive */ /* returns standard diameter */ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 200c6a173ea..a49d1217946 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -255,12 +255,8 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s dr = buf->rect; /* draw the mask */ -#ifdef __APPLE__ - glDrawBuffer(GL_AUX0); -#endif glDisable(GL_DEPTH_TEST); -// XXX persp(PERSP_WIN); glColor3ub(0, 0, 0); /* yah, opengl doesn't do concave... tsk! */ @@ -270,11 +266,8 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s for(a=0; a<tot; a++) glVertex2s(mcords[a][0], mcords[a][1]); glEnd(); -// XXX persp(PERSP_VIEW); glFinish(); /* to be sure readpixels sees mask */ - glDrawBuffer(GL_BACK); - /* grab mask */ bufmask= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); drm = bufmask->rect; @@ -1475,9 +1468,6 @@ void EM_mesh_copy_face(EditMesh *em, short type) if (change) { // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - if (type==3) { -// XXX allqueue(REDRAWIMAGE, 0); - } BIF_undo_push("Copy Face Attribute"); } @@ -2831,31 +2821,31 @@ void select_faces_by_numverts(EditMesh *em, int numverts) BIF_undo_push("Select non-Triangles/Quads"); } -void select_sharp_edges(EditMesh *em, float fsharpness) +static int select_sharp_edges_exec(bContext *C, wmOperator *op) { /* Find edges that have exactly two neighboring faces, - * check the angle between those faces, and if angle is - * small enough, select the edge - */ + * check the angle between those faces, and if angle is + * small enough, select the edge + */ + Object *obedit= CTX_data_edit_object(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; EditEdge *eed; EditFace *efa; EditFace **efa1; EditFace **efa2; - intptr_t edgecount = 0, i; - static short sharpness = 135; - + intptr_t edgecount = 0, i = 0; + float sharpness, fsharpness; + + /* 'standard' behaviour - check if selected, then apply relevant selection */ + if(em->selectmode==SCE_SELECT_FACE) { error("Doesn't work in face selection mode"); - return; + return OPERATOR_CANCELLED; } -// XXX if(button(&sharpness,0, 180,"Max Angle:")==0) return; - /* if faces are at angle 'sharpness', then the face normals - * are at angle 180.0 - 'sharpness' (convert to radians too) - */ + sharpness= RNA_float_get(op->ptr, "sharpness"); fsharpness = ((180.0 - sharpness) * M_PI) / 180.0; - i=0; /* count edges, use tmp.l */ eed= em->edges.first; while(eed) { @@ -2928,18 +2918,6 @@ void select_sharp_edges(EditMesh *em, float fsharpness) // if (EM_texFaceCheck()) BIF_undo_push("Select Sharp Edges"); -} - -static int select_sharp_edges_exec(bContext *C, wmOperator *op) -{ - Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; - - /* 'standard' behaviour - check if selected, then apply relevant selection */ - - // XXX we need a message here - for 1 its recalculate normals inside, for 2 its outside - righthandfaces(em, RNA_float_get(op->ptr, "sharpness")); - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ? return OPERATOR_FINISHED; } @@ -2957,13 +2935,12 @@ void MESH_OT_select_sharp_edges(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; - /* props XXX figure out? */ + /* props */ RNA_def_float(ot->srna, "sharpness", 0.01f, 0.0f, FLT_MAX, "sharpness", "", 0.0f, 180.0f); } -// XXX looks like more work is needed in order for this to work (see in function) -void select_linked_flat_faces(EditMesh *em, float fsharpness) +static void select_linked_flat_faces(EditMesh *em, float sharpness) { /* Find faces that are linked to selected faces that are * relatively flat (angle between faces is higher than @@ -2974,18 +2951,13 @@ void select_linked_flat_faces(EditMesh *em, float fsharpness) EditFace **efa1; EditFace **efa2; intptr_t edgecount = 0, i, faceselcount=0, faceselcountold=0; - static short sharpness = 135; + float fsharpness; - if(em->selectmode!=SCE_SELECT_FACE) { error("Only works in face selection mode"); return; } -// XXX if(button(&sharpness,0, 180,"Min Angle:")==0) return; - /* if faces are at angle 'sharpness', then the face normals - * are at angle 180.0 - 'sharpness' (convert to radians too) - */ fsharpness = ((180.0 - sharpness) * M_PI) / 180.0; i=0; @@ -3811,6 +3783,7 @@ void Face_Menu(EditMesh *em) /* **************** NORMALS ************** */ +/* XXX value of select is messed up, it means two things */ void righthandfaces(EditMesh *em, int select) /* makes faces righthand turning */ { EditEdge *eed, *ed1, *ed2, *ed3, *ed4; @@ -4029,7 +4002,7 @@ static int righthandfaces_exec(bContext *C, wmOperator *op) /* 'standard' behaviour - check if selected, then apply relevant selection */ - // XXX we need a message here - for 1 its recalculate normals inside, for 2 its outside + // XXX need other args righthandfaces(em, RNA_int_get(op->ptr, "select")); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ? @@ -4049,7 +4022,7 @@ void MESH_OT_righthandfaces(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; - /* props */ + /* XXX make it enum or so */ RNA_def_int(ot->srna, "select", 0, INT_MIN, INT_MAX, "Select", "", INT_MIN, INT_MAX); } @@ -4231,6 +4204,7 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, View3D *v3d, void vertexsmooth(Object *obedit, EditMesh *em) { + Scene *scene= NULL; // XXX EditVert *eve, *eve_mir = NULL; EditEdge *eed; float *adror, *adr, fac; @@ -4315,9 +4289,9 @@ void vertexsmooth(Object *obedit, EditMesh *em) if(eve->f & SELECT) { if(eve->f1) { -// XXX if (scene->toolsettings->editbutflag & B_MESH_X_MIRROR) { -// eve_mir= editmesh_get_x_mirror_vert(obedit, em, eve->co); -// } + if (scene->toolsettings->editbutflag & B_MESH_X_MIRROR) { + eve_mir= editmesh_get_x_mirror_vert(obedit, em, eve->co); + } adr = eve->tmp.p; fac= 0.5/(float)eve->f1; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 04a2d34a08d..c0fb38b8839 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -99,7 +99,6 @@ static int extern_qread() {return 0;} static void waitcursor() {} static void error() {} static int pupmenu() {return 0;} -static int okee() {return 0;} static int qtest() {return 0;} #define add_numbut(a, b, c, d, e, f, g) {} static int do_clever_numbuts() {return 0;} @@ -724,8 +723,6 @@ void MESH_OT_extrude_mesh(wmOperatorType *ot) void split_mesh(EditMesh *em) { - if(okee(" Split ")==0) return; - waitcursor(1); /* make duplicate first */ @@ -777,6 +774,7 @@ void extrude_repeat_mesh(RegionView3D *rv3d, Object *obedit, EditMesh *em, int s void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr, float *dvec, int mode) { + Scene *scene= NULL; // XXX from context! RegionView3D *rv3d= NULL; // XXX from context EditVert *eve,*nextve; float nor[3]= {0.0, 0.0, 0.0}; @@ -798,7 +796,7 @@ void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr, phi= degr*M_PI/360.0; phi/= steps; -// if(scene->toolsettings->editbutflag & B_CLOCKWISE) phi= -phi; + if(scene->toolsettings->editbutflag & B_CLOCKWISE) phi= -phi; if(dvec) { n[0]= rv3d->viewinv[1][0]; @@ -821,7 +819,7 @@ void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr, Mat3MulMat3(tmat,cmat,bmat); Mat3MulMat3(bmat,imat,tmat); -// if(mode==0) if(scene->toolsettings->editbutflag & B_KEEPORIG) adduplicateflag(1); + if(mode==0) if(scene->toolsettings->editbutflag & B_KEEPORIG) adduplicateflag(em, 1); ok= 1; for(a=0;a<steps;a++) { @@ -1184,6 +1182,8 @@ void fill_mesh(EditMesh *em) BLI_end_edgefill(); + // XXX option beautyfill */ + waitcursor(0); EM_select_flush(em); // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 34e87a29d63..80839ea12e2 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -74,7 +74,10 @@ static int mesh_add_duplicate_exec(bContext *C, wmOperator *op) static int mesh_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *event) { + WM_cursor_wait(1); mesh_add_duplicate_exec(C, op); + WM_cursor_wait(0); + RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index b4bf6db542f..5aeaf5d2743 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -94,6 +94,9 @@ typedef struct wmWindow { short monitor; /* multiscreen... no idea how to store yet */ short active; /* set to 1 if an active window, for quick rejects */ short cursor; /* current mouse cursor type */ + short lastcursor; /* for temp waitcursor */ + short pad2; + int pad3; struct wmEvent *eventstate; /* storage for event system */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index cb6d26a1506..940fd762f10 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -64,7 +64,7 @@ void WM_write_autosave (struct bContext *C); void WM_cursor_set (struct wmWindow *win, int curs); void WM_cursor_modal (struct wmWindow *win, int curs); void WM_cursor_restore (struct wmWindow *win); -void WM_cursor_wait (struct wmWindow *win, int val); +void WM_cursor_wait (int val); void WM_timecursor (struct wmWindow *win, int nr); void *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct bContext *C), void (*draw)(struct bContext *C, int, int, void *customdata), void *customdata); diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 3afc9cc884b..d1c268a1189 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -36,6 +36,8 @@ #include "DNA_userdef_types.h" #include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_main.h" #include "WM_api.h" #include "wm_cursors.h" @@ -120,29 +122,32 @@ void WM_cursor_set(wmWindow *win, int curs) } } -static int LastCursor=-1; /* global, assumed we only have one */ - void WM_cursor_modal(wmWindow *win, int val) { - if(LastCursor == -1) - LastCursor = win->cursor; + if(win->lastcursor == 0) + win->lastcursor = win->cursor; WM_cursor_set(win, val); } void WM_cursor_restore(wmWindow *win) { - if(LastCursor != -1) - WM_cursor_set(win, LastCursor); - LastCursor = -1; + if(win->lastcursor) + WM_cursor_set(win, win->lastcursor); + win->lastcursor = 0; } - -void WM_cursor_wait(wmWindow *win, int val) +/* to allow usage all over, we do entire WM */ +void WM_cursor_wait(int val) { - if(val) { - WM_cursor_modal(win, CURSOR_WAIT); - } else { - WM_cursor_restore(win); + wmWindowManager *wm= G.main->wm.first; + wmWindow *win= wm->windows.first; + + for(; win; win= win->next) { + if(val) { + WM_cursor_modal(win, CURSOR_WAIT); + } else { + WM_cursor_restore(win); + } } } @@ -166,8 +171,8 @@ void WM_timecursor(wmWindow *win, int nr) unsigned char bitmap[16][2]; int i, idx; - if(LastCursor != -1) - LastCursor= win->cursor; + if(win->lastcursor != 0) + win->lastcursor= win->cursor; memset(&bitmap, 0x00, sizeof(bitmap)); memset(&mask, 0xFF, sizeof(mask)); diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h index e3f0e846b7a..096e1916fa9 100644 --- a/source/blender/windowmanager/wm_cursors.h +++ b/source/blender/windowmanager/wm_cursors.h @@ -74,9 +74,9 @@ typedef struct BCursor { } BCursor; -#define SYSCURSOR -1 +#define SYSCURSOR 1 enum { - BC_NW_ARROWCURSOR=0, + BC_NW_ARROWCURSOR=2, BC_NS_ARROWCURSOR, BC_EW_ARROWCURSOR, BC_WAITCURSOR, |