From 47b9a44063fb3c98b3ca9cf8e5dff6ffa8136934 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Feb 2009 17:37:01 +0000 Subject: 2.5: Curve edit mode add vertex and add menus now work. Also fixed an issue where sublevel menus did not get right operator context. --- source/blender/editors/curve/curve_intern.h | 4 - source/blender/editors/curve/curve_ops.c | 30 ----- source/blender/editors/curve/editcurve.c | 143 +++++---------------- source/blender/editors/include/ED_view3d.h | 1 + .../blender/editors/interface/interface_regions.c | 39 ++++-- source/blender/editors/mesh/editmesh_add.c | 22 +--- source/blender/editors/object/object_edit.c | 74 ++++++++++- source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + .../blender/editors/space_view3d/view3d_select.c | 18 +++ 10 files changed, 154 insertions(+), 179 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index cced4720cec..82e6b39196b 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -71,12 +71,8 @@ void CURVE_OT_duplicate(struct wmOperatorType *ot); void CURVE_OT_delete(struct wmOperatorType *ot); void CURVE_OT_set_smooth(struct wmOperatorType *ot); void CURVE_OT_clear_tilt(struct wmOperatorType *ot); -void CURVE_OT_add_surface_primitive(struct wmOperatorType *ot); -void CURVE_OT_add_curve_primitive(struct wmOperatorType *ot); void CURVE_OT_specials_menu(struct wmOperatorType *ot); -void CURVE_OT_add_menu(struct wmOperatorType *ot); - #endif /* ED_UTIL_INTERN_H */ diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 30ddb226045..c7eed88023f 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -91,32 +91,6 @@ void CURVE_OT_specials_menu(wmOperatorType *ot) ot->poll= ED_operator_editsurfcurve; } -static int add_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Object *obedit= CTX_data_edit_object(C); - uiMenuItem *head; - - head= uiPupMenuBegin("Add", 0); - if(obedit->type == OB_CURVE) - uiMenuItemsEnumO(head, "CURVE_OT_add_curve_primitive", "type"); - else - uiMenuItemsEnumO(head, "CURVE_OT_add_surface_primitive", "type"); - uiPupMenuEnd(C, head); - - return OPERATOR_CANCELLED; -} - -void CURVE_OT_add_menu(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Add Menu"; - ot->idname= "CURVE_OT_add_menu"; - - /* api clastbacks */ - ot->invoke= add_menu_invoke; - ot->poll= ED_operator_editsurfcurve; -} - /************************* registration ****************************/ void ED_operatortypes_curve(void) @@ -161,11 +135,7 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_extrude); WM_operatortype_append(CURVE_OT_toggle_cyclic); - WM_operatortype_append(CURVE_OT_add_menu); WM_operatortype_append(CURVE_OT_specials_menu); - - WM_operatortype_append(CURVE_OT_add_surface_primitive); - WM_operatortype_append(CURVE_OT_add_curve_primitive); } void ED_keymap_curve(wmWindowManager *wm) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 848bec89a39..4ef642381f0 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3258,16 +3258,15 @@ void CURVE_OT_spin(wmOperatorType *ot) /***************** add vertex operator **********************/ -static int addvert_Nurb(bContext *C, short mode) +static int addvert_Nurb(bContext *C, short mode, float location[3]) { Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); - View3D *v3d= CTX_wm_view3d(C); Nurb *nu; BezTriple *bezt, *newbezt = NULL; BPoint *bp, *newbp = NULL; - float *curs, mat[3][3],imat[3][3], temp[3]; + float mat[3][3],imat[3][3], temp[3]; Mat3CpyMat4(mat, obedit->obmat); Mat3Inv(imat,mat); @@ -3315,16 +3314,7 @@ static int addvert_Nurb(bContext *C, short mode) VECCOPY(newbezt->vec[2], bezt->vec[2]); } else { - if(v3d) { - curs= give_cursor(scene, v3d); - VECCOPY(newbezt->vec[1], curs); - } - else { - newbezt->vec[1][0]= 0.0f; - newbezt->vec[1][1]= 0.0f; - newbezt->vec[1][2]= 0.0f; - } - + VECCOPY(newbezt->vec[1], location); VecSubf(newbezt->vec[1],newbezt->vec[1], obedit->obmat[3]); Mat3MulVecfl(imat,newbezt->vec[1]); VecSubf(temp, newbezt->vec[1],temp); @@ -3370,16 +3360,7 @@ static int addvert_Nurb(bContext *C, short mode) VECCOPY(newbp->vec, bp->vec); } else { - if(v3d) { - curs= give_cursor(scene, v3d); - VECCOPY(newbp->vec, curs); - } - else { - newbp->vec[0]= 0.0f; - newbp->vec[1]= 0.0f; - newbp->vec[1]= 0.0f; - } - + VECCOPY(newbp->vec, location); VecSubf(newbp->vec, newbp->vec, obedit->obmat[3]); Mat3MulVecfl(imat,newbp->vec); newbp->vec[3]= 1.0; @@ -3399,14 +3380,30 @@ static int addvert_Nurb(bContext *C, short mode) static int add_vertex_exec(bContext *C, wmOperator *op) { - return addvert_Nurb(C, 0); + float location[3]; + + RNA_float_get_array(op->ptr, "location", location); + return addvert_Nurb(C, 0, location); } static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { - // XXX doesn't work correct, old code was in mouse_cursor - // temporarly setting cursor, adding vertex and restoring cursor - return add_vertex_exec(C, 0); + RegionView3D *rv3d= CTX_wm_region_view3d(C); + ViewContext vc; + float location[3]; + short mval[2]; + + if(rv3d && !RNA_property_is_set(op->ptr, "location")) { + view3d_set_viewcontext(C, &vc); + + mval[0]= event->x - vc.ar->winrct.xmin; + mval[1]= event->y - vc.ar->winrct.ymin; + + view3d_get_view_aligned_coordinate(&vc, location, mval); + RNA_float_set_array(op->ptr, "location", location); + } + + return add_vertex_exec(C, op); } void CURVE_OT_add_vertex(wmOperatorType *ot) @@ -3422,6 +3419,9 @@ void CURVE_OT_add_vertex(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_float_vector(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location to add new vertex at.", -1e4, 1e4); } /***************** extrude operator **********************/ @@ -3439,7 +3439,7 @@ static int extrude_exec(bContext *C, wmOperator *op) break; if(obedit->type==OB_CURVE || nu) { - addvert_Nurb(C, 'e'); + addvert_Nurb(C, 'e', NULL); } else { if(extrudeflagNurb(editnurb, 1)) { /* '1'= flag */ @@ -4722,7 +4722,7 @@ int join_curve(bContext *C, wmOperator *op, int type) return OPERATOR_FINISHED; } -/************ add primitive, internal + external ****************/ +/************ add primitive, used by object/ module ****************/ Nurb *addNurbprim(bContext *C, int type, int newname) { @@ -5022,7 +5022,7 @@ Nurb *addNurbprim(bContext *C, int type, int newname) rename_id((ID *)obedit->data, "SurfTube"); } - nu= addNurbprim(C, CU_NURBS|CU_2D|CU_PRIM_CIRCLE, 0); /* circle */ + nu= addNurbprim(C, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ nu->resolu= 4; nu->flag= CU_SMOOTH; BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ @@ -5101,7 +5101,7 @@ Nurb *addNurbprim(bContext *C, int type, int newname) } xzproj= 1; - nu= addNurbprim(C, CU_NURBS|CU_2D|CU_PRIM_CIRCLE, 0); /* circle */ + nu= addNurbprim(C, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ xzproj= 0; nu->resolu= 4; nu->resolv= 4; @@ -5133,87 +5133,6 @@ Nurb *addNurbprim(bContext *C, int type, int newname) return nu; } -/***************** add curve primitive operator ********************/ - -static int add_curve_primitive_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - - addNurbprim(C, RNA_enum_get(op->ptr, "type"), 0); - - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); - - return OPERATOR_FINISHED; -} - -void CURVE_OT_add_curve_primitive(wmOperatorType *ot) -{ - static EnumPropertyItem type_items[]= { - {CU_PRIM_CURVE|CU_2D|CU_BEZIER, "BEZIER_CURVE", "Bezier Curve", ""}, - {CU_PRIM_CIRCLE|CU_2D|CU_BEZIER, "BEZIER_CIRCLE", "Bezier Circle", ""}, - {CU_PRIM_CURVE|CU_2D|CU_NURBS, "NURBS_CURVE", "NURBS Curve", ""}, - {CU_PRIM_CIRCLE|CU_2D|CU_NURBS, "NURBS_CIRCLE", "NURBS Circle", ""}, - {CU_PRIM_PATH|CU_2D|CU_NURBS, "PATH", "Path", ""}, - {0, NULL, NULL, NULL}}; - - /* identifiers */ - ot->name= "Add Curve Primitive"; - ot->idname= "CURVE_OT_add_curve_primitive"; - - /* api callbacks */ - ot->exec= add_curve_primitive_exec; - ot->poll= ED_operator_editcurve; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* properties */ - RNA_def_enum(ot->srna, "type", type_items, CU_PRIM_CURVE|CU_2D|CU_BEZIER, "Type", "Type of primitive to add."); -} - -/***************** add surface primitive operator ********************/ - -static int add_surface_primitive_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - - addNurbprim(C, RNA_enum_get(op->ptr, "type"), 0); - - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); - - return OPERATOR_FINISHED; -} - -void CURVE_OT_add_surface_primitive(wmOperatorType *ot) -{ - static EnumPropertyItem type_items[]= { - {CU_PRIM_CURVE|CU_NURBS, "NURBS_CURVE", "NURBS Curve", ""}, - {CU_PRIM_CIRCLE|CU_NURBS, "NURBS_CIRCLE", "NURBS Circle", ""}, - {CU_PRIM_PATCH|CU_NURBS, "NURBS_SURFACE", "NURBS Surface", ""}, - {CU_PRIM_TUBE|CU_NURBS, "NURBS_TUBE", "NURBS Tube", ""}, - {CU_PRIM_SPHERE|CU_NURBS, "NURBS_SPHERE", "NURBS Sphere", ""}, - {CU_PRIM_DONUT|CU_NURBS, "NURBS_DONUT", "NURBS Donut", ""}, - {0, NULL, NULL, NULL}}; - - /* identifiers */ - ot->name= "Add Surface Primitive"; - ot->idname= "CURVE_OT_add_surface_primitive"; - - /* api callbacks */ - ot->exec= add_surface_primitive_exec; - ot->poll= ED_operator_editsurf; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* properties */ - RNA_def_enum(ot->srna, "type", type_items, CU_PRIM_CURVE|CU_NURBS, "Type", "Type of primitive to add."); -} - /***************** clear tilt operator ********************/ static int clear_tilt_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 7519bfabf65..6434bcb606a 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -116,6 +116,7 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); void view3d_operator_needs_opengl(const struct bContext *C); +void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float *fp, short mval[2]); /* XXX should move to arithb.c */ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index ad372077351..1294546ab82 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1729,22 +1729,28 @@ const char *ui_menu_enumpropname(char *opname, const char *propname, int retval) return ""; } +typedef struct MenuItemLevel { + int opcontext; + char *opname; + char *propname; + PointerRNA rnapoin; +} MenuItemLevel; + /* make a menu level from enum properties */ static void menu_item_enum_opname_menu(bContext *C, uiMenuItem *head, void *arg) { - uiBut *but= arg; /* parent caller */ - char *opname= but->func_arg1; - char *propname= but->func_arg2; + MenuItemLevel *lvl= (MenuItemLevel*)(((uiBut*)arg)->func_argN); - uiMenuItemsEnumO(head, opname, propname); + head->opcontext= lvl->opcontext; + uiMenuItemsEnumO(head, lvl->opname, lvl->propname); } static void menu_item_enum_rna_menu(bContext *C, uiMenuItem *head, void *arg) { - uiBut *but= arg; /* parent caller */ - char *propname= but->func_arg1; + MenuItemLevel *lvl= (MenuItemLevel*)(((uiBut*)arg)->func_argN); - uiMenuItemsEnumR(head, &but->rnapoin, propname); + head->opcontext= lvl->opcontext; + uiMenuItemsEnumR(head, &lvl->rnapoin, lvl->propname); } static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info) @@ -1753,6 +1759,7 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, uiBut *but; uiMenuInfo *info= arg_info; uiMenuItem *head, *item; + MenuItemLevel *lvl; ScrArea *sa; ARegion *ar; static int counter= 0; @@ -1810,19 +1817,29 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, } else if(item->type==MENU_ITEM_LEVEL_OPNAME_ENUM) { but= uiDefIconTextMenuBut(block, menu_item_enum_opname_menu, NULL, ICON_RIGHTARROW_THIN, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, NULL); + /* XXX warning, abuse of func_arg! */ + lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); + lvl->opname= item->opname; + lvl->propname= item->propname; + lvl->opcontext= item->opcontext; + but->poin= (char*)but; - but->func_arg1= item->opname; - but->func_arg2= item->propname; + but->func_argN= lvl; y1 -= MENU_BUTTON_HEIGHT; } else if(item->type==MENU_ITEM_LEVEL_RNA_ENUM) { but= uiDefIconTextMenuBut(block, menu_item_enum_rna_menu, NULL, ICON_RIGHTARROW_THIN, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, NULL); + /* XXX warning, abuse of func_arg! */ + lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); + lvl->rnapoin= item->rnapoin; + lvl->propname= item->propname; + lvl->opcontext= item->opcontext; + but->poin= (char*)but; - but->rnapoin= item->rnapoin; - but->func_arg1= item->propname; + but->func_argN= lvl; y1 -= MENU_BUTTON_HEIGHT; } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index e16ec867e7c..969fceb41b0 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -118,24 +118,6 @@ static short icoface[20][3] = { /* *************** add-click-mesh (extrude) operator ************** */ -static void get_view_aligned_coordinate(ViewContext *vc, float *fp, short mval[2]) -{ - float dvec[3]; - short mx, my; - - mx= mval[0]; - my= mval[1]; - - project_short_noclip(vc->ar, fp, mval); - - initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); - - if(mval[0]!=IS_CLIPPED) { - window_to_3d_delta(vc->ar, dvec, mval[0]-mx, mval[1]-my); - VecSubf(fp, fp, dvec); - } -} - static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) { ViewContext vc; @@ -182,7 +164,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) VECCOPY(min, cent); Mat4MulVecfl(vc.obedit->obmat, min); // view space - get_view_aligned_coordinate(&vc, min, mval); + view3d_get_view_aligned_coordinate(&vc, min, mval); Mat4Invert(vc.obedit->imat, vc.obedit->obmat); Mat4MulVecfl(vc.obedit->imat, min); // back in object space @@ -224,7 +206,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) float *curs= give_cursor(vc.scene, vc.v3d); VECCOPY(min, curs); - get_view_aligned_coordinate(&vc, min, mval); + view3d_get_view_aligned_coordinate(&vc, min, mval); eve= addvertlist(vc.em, 0, NULL); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index aeddff72539..75c1f9032c1 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -458,6 +458,21 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int object_add_curve_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Object *obedit= CTX_data_edit_object(C); + uiMenuItem *head; + + head= uiPupMenuBegin(op->type->name, 0); + if(!obedit || obedit->type == OB_CURVE) + uiMenuItemsEnumO(head, op->type->idname, "type"); + else + uiMenuItemsEnumO(head, "OBJECT_OT_surface_add", "type"); + uiPupMenuEnd(C, head); + + return OPERATOR_CANCELLED; +} + void OBJECT_OT_curve_add(wmOperatorType *ot) { /* identifiers */ @@ -465,7 +480,7 @@ void OBJECT_OT_curve_add(wmOperatorType *ot) ot->idname= "OBJECT_OT_curve_add"; /* api callbacks */ - ot->invoke= WM_menu_invoke; + ot->invoke= object_add_curve_invoke; ot->exec= object_add_curve_exec; ot->poll= ED_operator_scene_editable; @@ -476,6 +491,61 @@ void OBJECT_OT_curve_add(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", prop_curve_types, 0, "Primitive", ""); } +static EnumPropertyItem prop_surface_types[]= { + {CU_PRIM_CURVE|CU_NURBS, "NURBS_CURVE", "NURBS Curve", ""}, + {CU_PRIM_CIRCLE|CU_NURBS, "NURBS_CIRCLE", "NURBS Circle", ""}, + {CU_PRIM_PATCH|CU_NURBS, "NURBS_SURFACE", "NURBS Surface", ""}, + {CU_PRIM_TUBE|CU_NURBS, "NURBS_TUBE", "NURBS Tube", ""}, + {CU_PRIM_SPHERE|CU_NURBS, "NURBS_SPHERE", "NURBS Sphere", ""}, + {CU_PRIM_DONUT|CU_NURBS, "NURBS_DONUT", "NURBS Donut", ""}, + {0, NULL, NULL, NULL} +}; + +static int object_add_surface_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + ListBase *editnurb; + Nurb *nu; + int newob= 0; + + if(obedit==NULL || obedit->type!=OB_SURF) { + object_add_type(C, OB_SURF); + ED_object_enter_editmode(C, 0); + newob = 1; + } + else DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); + + nu= addNurbprim(C, RNA_enum_get(op->ptr, "type"), newob); + editnurb= curve_get_editcurve(CTX_data_edit_object(C)); + BLI_addtail(editnurb, nu); + + /* userdef */ + if (newob && (U.flag & USER_ADD_EDITMODE)==0) { + ED_object_exit_editmode(C, EM_FREEDATA); + } + + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_surface_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Surface"; + ot->idname= "OBJECT_OT_surface_add"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= object_add_surface_exec; + + ot->poll= ED_operator_scene_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "type", prop_surface_types, 0, "Primitive", ""); +} static int object_add_armature_exec(bContext *C, wmOperator *op) { @@ -524,7 +594,7 @@ static int object_add_primitive_invoke(bContext *C, wmOperator *op, wmEvent *eve uiMenuLevelEnumO(head, "OBJECT_OT_mesh_add", "type"); uiMenuLevelEnumO(head, "OBJECT_OT_curve_add", "type"); - uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_SURF); + uiMenuLevelEnumO(head, "OBJECT_OT_surface_add", "type"); uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_MBALL); uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_CAMERA); uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_LAMP); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index e7d75e85657..f1b1c966803 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -69,6 +69,7 @@ void OBJECT_OT_delete(struct wmOperatorType *ot); void OBJECT_OT_mesh_add(struct wmOperatorType *ot); void OBJECT_OT_curve_add(struct wmOperatorType *ot); +void OBJECT_OT_surface_add(struct wmOperatorType *ot); /* only used as menu */ void OBJECT_OT_primitive_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 89890c10587..15515d8abc4 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -93,6 +93,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_delete); WM_operatortype_append(OBJECT_OT_mesh_add); WM_operatortype_append(OBJECT_OT_curve_add); + WM_operatortype_append(OBJECT_OT_surface_add); WM_operatortype_append(OBJECT_OT_object_add); WM_operatortype_append(OBJECT_OT_primitive_add); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 9a94ca8624c..967fbfd26af 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -103,6 +103,24 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->obedit= CTX_data_edit_object(C); } +void view3d_get_view_aligned_coordinate(ViewContext *vc, float *fp, short mval[2]) +{ + float dvec[3]; + short mx, my; + + mx= mval[0]; + my= mval[1]; + + project_short_noclip(vc->ar, fp, mval); + + initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); + + if(mval[0]!=IS_CLIPPED) { + window_to_3d_delta(vc->ar, dvec, mval[0]-mx, mval[1]-my); + VecSubf(fp, fp, dvec); + } +} + /* ********************** view3d_select: selection manipulations ********************* */ /* XXX to solve *************** */ -- cgit v1.2.3