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.
This commit is contained in:
@@ -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 */
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 *************** */
|
||||
|
||||
Reference in New Issue
Block a user