Index: source/blender/editors/mesh/mesh_intern.h =================================================================== --- source/blender/editors/mesh/mesh_intern.h (revision 18493) +++ source/blender/editors/mesh/mesh_intern.h (working copy) @@ -94,6 +94,7 @@ void em_setup_viewcontext(struct bContext *C, ViewContext *vc); /* ******************* editmesh_add.c */ +void MESH_OT_add_primitiveMesh_plane(struct wmOperatorType *ot); /* ******************* editmesh_lib.c */ @@ -172,8 +173,6 @@ void MESH_OT_select_sharp_edges(struct wmOperatorType *ot); - - extern EditEdge *findnearestedge(ViewContext *vc, int *dist); extern void EM_automerge(int update); void editmesh_select_by_material(EditMesh *em, int index); Index: source/blender/editors/mesh/editmesh_add.c =================================================================== --- source/blender/editors/mesh/editmesh_add.c (revision 18493) +++ source/blender/editors/mesh/editmesh_add.c (working copy) @@ -43,11 +43,13 @@ #include "DNA_screen_types.h" #include "DNA_userdef_types.h" #include "DNA_view3d_types.h" +#include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_editVert.h" +#include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_library.h" @@ -59,6 +61,7 @@ #include "ED_mesh.h" #include "ED_view3d.h" +#include "ED_screen.h" #include "mesh_intern.h" @@ -225,7 +228,7 @@ eve->f= SELECT; } - retopo_do_all(); + //retopo_do_all(); BIF_undo_push("Add vertex/edge/face"); // XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); @@ -1399,3 +1402,111 @@ BIF_undo_push(undostr); } +void add_primitiveMesh_plane(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em) +{ + 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 Plane"; + 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 */ + + /* plane */ + tot= 4; + ext= 0; + fill= 1; + newob = confirm_objectExists(scene, obedit, &me, mat ); + if(newob) name = "Plane"; + + + + 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); + + + /* plane (diameter of 1.41 makes it unit size) */ + dia *= sqrt(2.0); + + phid= 2*M_PI/tot; + phi= .25*M_PI; + + make_prim(obedit, em, 0, imat, tot, seg, subdiv, dia, d, ext, fill, cent); + + tot = totoud; + + /* simple selection flush OK, based on fact it's a single model */ + EM_select_flush(em); // flushes vertex -> edge -> face selection + +// 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); +} + +static int add_primitiveMesh_plane_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = (View3D *)CTX_wm_space_data(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + + add_primitiveMesh_plane(scene,v3d,obedit,em); + + // WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + return OPERATOR_FINISHED; +} + +void MESH_OT_add_primitiveMesh_plane(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Plane"; + ot->idname= "MESH_OT_add_primitiveMesh_plane"; + + /* api callbacks */ + ot->exec= add_primitiveMesh_plane_exec; + ot->poll= ED_operator_editmesh; +} \ No newline at end of file Index: source/blender/editors/mesh/mesh_ops.c =================================================================== --- source/blender/editors/mesh/mesh_ops.c (revision 18493) +++ source/blender/editors/mesh/mesh_ops.c (working copy) @@ -87,6 +87,8 @@ WM_operatortype_append(MESH_OT_select_linked_flat_faces); WM_operatortype_append(MESH_OT_select_sharp_edges); + + WM_operatortype_append(MESH_OT_add_primitiveMesh_plane); } @@ -122,9 +124,8 @@ RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_linked_flat_faces", FKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"fsharpness",135.0); RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_sharp_edges", SKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"fsharpness",135.0); - - - + + WM_keymap_add_item(keymap, "MESH_OT_add_primitiveMesh_plane", ZEROKEY, KM_PRESS, KM_CTRL, 0); // RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_viewzoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); }