diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_add.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index abbbb5aea3d..942ad657992 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -61,15 +61,15 @@ #include "BKE_utildefines.h" #include "BKE_report.h" -#include "BIF_retopo.h" - #include "WM_api.h" #include "WM_types.h" #include "ED_mesh.h" +#include "ED_retopo.h" +#include "ED_screen.h" +#include "ED_transform.h" #include "ED_util.h" #include "ED_view3d.h" -#include "ED_screen.h" #include "mesh_intern.h" @@ -1659,3 +1659,50 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) RNA_def_float(ot->srna, "size", 1.0f, 0.0f, FLT_MAX, "Size", "", 0.001f, 100.00); } +/****************** add duplicate operator ***************/ + +static int mesh_add_duplicate_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_edit_object(C); + EditMesh *em= BKE_mesh_get_editmesh(ob->data); + + adduplicateflag(em, SELECT); + + BKE_mesh_end_editmesh(ob->data, em); + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob); + + return OPERATOR_FINISHED; +} + +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); + + return OPERATOR_FINISHED; +} + +void MESH_OT_duplicate_add(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Add Duplicate"; + ot->idname= "MESH_OT_duplicate_add"; + + /* api callbacks */ + ot->invoke= mesh_add_duplicate_invoke; + ot->exec= mesh_add_duplicate_exec; + + ot->poll= ED_operator_editmesh; + + /* to give to transform */ + RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); +} + |