[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18961] branches/blender2.5/blender/source /blender/editors: 2.5: Curve edit mode add vertex and add menus now work.
Brecht Van Lommel
brecht at blender.org
Fri Feb 13 18:37:04 CET 2009
Revision: 18961
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18961
Author: blendix
Date: 2009-02-13 18:37:01 +0100 (Fri, 13 Feb 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h
branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c
branches/blender2.5/blender/source/blender/editors/curve/editcurve.c
branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h
branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
branches/blender2.5/blender/source/blender/editors/mesh/editmesh_add.c
branches/blender2.5/blender/source/blender/editors/object/object_edit.c
branches/blender2.5/blender/source/blender/editors/object/object_intern.h
branches/blender2.5/blender/source/blender/editors/object/object_ops.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c
Modified: branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h 2009-02-13 16:05:42 UTC (rev 18960)
+++ branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h 2009-02-13 17:37:01 UTC (rev 18961)
@@ -71,12 +71,8 @@
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 */
Modified: branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c 2009-02-13 16:05:42 UTC (rev 18960)
+++ branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c 2009-02-13 17:37:01 UTC (rev 18961)
@@ -91,32 +91,6 @@
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 @@
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)
Modified: branches/blender2.5/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/curve/editcurve.c 2009-02-13 16:05:42 UTC (rev 18960)
+++ branches/blender2.5/blender/source/blender/editors/curve/editcurve.c 2009-02-13 17:37:01 UTC (rev 18961)
@@ -3258,16 +3258,15 @@
/***************** 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 @@
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 @@
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 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 @@
/* 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 @@
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 @@
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 @@
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 @@
}
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 @@
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)
Modified: branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h 2009-02-13 16:05:42 UTC (rev 18960)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h 2009-02-13 17:37:01 UTC (rev 18961)
@@ -116,6 +116,7 @@
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);
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c 2009-02-13 16:05:42 UTC (rev 18960)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c 2009-02-13 17:37:01 UTC (rev 18961)
@@ -1729,22 +1729,28 @@
return "";
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list