diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:39:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:39:04 +0300 |
commit | 95011f6d484b369db92ae13c674a6522d664ea8f (patch) | |
tree | 91ba2719c9f3096fad0f1f768aa7b1c4d79aa32a /source/blender/editors/curve | |
parent | 0911acb5cf49c5ba05b1df045b41697704aa288a (diff) | |
parent | 44505b38df557a5711703613685a1dec9fc2c3d9 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r-- | source/blender/editors/curve/curve_ops.c | 18 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 216 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve_paint.c | 2 | ||||
-rw-r--r-- | source/blender/editors/curve/editfont.c | 132 |
4 files changed, 184 insertions, 184 deletions
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 85b561f3a9f..5d27e13ed17 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -73,10 +73,10 @@ void ED_operatortypes_curve(void) WM_operatortype_append(FONT_OT_change_character); WM_operatortype_append(FONT_OT_change_spacing); - + WM_operatortype_append(FONT_OT_open); WM_operatortype_append(FONT_OT_unlink); - + WM_operatortype_append(FONT_OT_textbox_add); WM_operatortype_append(FONT_OT_textbox_remove); @@ -98,20 +98,20 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_shade_smooth); WM_operatortype_append(CURVE_OT_shade_flat); WM_operatortype_append(CURVE_OT_tilt_clear); - + WM_operatortype_append(CURVE_OT_primitive_bezier_curve_add); WM_operatortype_append(CURVE_OT_primitive_bezier_circle_add); WM_operatortype_append(CURVE_OT_primitive_nurbs_curve_add); WM_operatortype_append(CURVE_OT_primitive_nurbs_circle_add); WM_operatortype_append(CURVE_OT_primitive_nurbs_path_add); - + WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_curve_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_circle_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_surface_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_cylinder_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_sphere_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_torus_add); - + WM_operatortype_append(CURVE_OT_smooth); WM_operatortype_append(CURVE_OT_smooth_weight); WM_operatortype_append(CURVE_OT_smooth_radius); @@ -168,10 +168,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + keymap = WM_keymap_find(keyconf, "Font", 0, 0); keymap->poll = ED_operator_editfont; - + /* only set in editmode font, by space_view3d listener */ RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_BOLD); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_ITALIC); @@ -233,7 +233,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) keymap->poll = ED_operator_editsurfcurve; WM_keymap_add_menu(keymap, "INFO_MT_edit_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); @@ -289,7 +289,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CURVE_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_specials", WKEY, KM_PRESS, 0, 0); /* menus */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 1987fe56bdb..ab6586d2ab6 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1346,12 +1346,12 @@ void CURVE_OT_separate(wmOperatorType *ot) ot->name = "Separate"; ot->idname = "CURVE_OT_separate"; ot->description = "Separate selected points from connected unselected points into a new object"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = separate_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1856,7 +1856,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const short flag) while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); select_bpoint(newbp, DESELECT, flag, HIDDEN); - bp++; + bp++; newbp++; } @@ -2336,7 +2336,7 @@ void CURVE_OT_switch_direction(wmOperatorType *ot) ot->name = "Switch Direction"; ot->description = "Switch direction of selected splines"; ot->idname = "CURVE_OT_switch_direction"; - + /* api callbacks */ ot->exec = switch_direction_exec; ot->poll = ED_operator_editsurfcurve; @@ -2356,7 +2356,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op) BPoint *bp; float weight = RNA_float_get(op->ptr, "weight"); int a; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { @@ -2384,7 +2384,7 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot) ot->name = "Set Goal Weight"; ot->description = "Set softbody goal weight for selected points"; ot->idname = "CURVE_OT_spline_weight_set"; - + /* api callbacks */ ot->exec = set_goal_weight_exec; ot->invoke = WM_operator_props_popup; @@ -2408,7 +2408,7 @@ static int set_radius_exec(bContext *C, wmOperator *op) BPoint *bp; float radius = RNA_float_get(op->ptr, "radius"); int a; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { @@ -2436,7 +2436,7 @@ void CURVE_OT_radius_set(wmOperatorType *ot) ot->name = "Set Curve Radius"; ot->description = "Set per-point radius which is used for bevel tapering"; ot->idname = "CURVE_OT_radius_set"; - + /* api callbacks */ ot->exec = set_radius_exec; ot->invoke = WM_operator_props_popup; @@ -2588,7 +2588,7 @@ void CURVE_OT_smooth(wmOperatorType *ot) ot->name = "Smooth"; ot->description = "Flatten angles of selected points"; ot->idname = "CURVE_OT_smooth"; - + /* api callbacks */ ot->exec = smooth_exec; ot->poll = ED_operator_editsurfcurve; @@ -2792,7 +2792,7 @@ static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); ListBase *editnurb = object_editcurve_get(obedit); - + curve_smooth_value(editnurb, offsetof(BezTriple, radius), offsetof(BPoint, radius)); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -2807,11 +2807,11 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot) ot->name = "Smooth Curve Radius"; ot->description = "Interpolate radii of selected points"; ot->idname = "CURVE_OT_smooth_radius"; - + /* api clastbacks */ ot->exec = curve_smooth_radius_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2909,14 +2909,14 @@ void CURVE_OT_hide(wmOperatorType *ot) ot->name = "Hide Selected"; ot->idname = "CURVE_OT_hide"; ot->description = "Hide (un)selected control points"; - + /* api callbacks */ ot->exec = hide_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); } @@ -2971,11 +2971,11 @@ void CURVE_OT_reveal(wmOperatorType *ot) ot->name = "Reveal Hidden"; ot->idname = "CURVE_OT_reveal"; ot->description = "Reveal hidden control points"; - + /* api callbacks */ ot->exec = reveal_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3231,7 +3231,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for (b = 0; b < nu->pntsu; b++) { *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); - bpn++; + bpn++; bp++; if (b < nu->pntsu - 1) { prevbp = bp - 1; @@ -3259,7 +3259,7 @@ static void subdividenurb(Object *obedit, int number_cuts) interp_v4_v4v4(tmp->vec, prevbp->vec, bp->vec, factor); tmp += countu; } - bp++; + bp++; prevbp++; bpn++; } @@ -3335,7 +3335,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for (b = 0; b < nu->pntsu; b++) { *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); - bpn++; + bpn++; bp++; if ( (b < nu->pntsu - 1) && usel[b] == nu->pntsv && usel[b + 1] == nu->pntsv) { /* @@ -3362,7 +3362,7 @@ static void subdividenurb(Object *obedit, int number_cuts) } } } - MEM_freeN(usel); + MEM_freeN(usel); MEM_freeN(vsel); } /* End of 'if (nu->type == CU_NURBS)' */ @@ -3406,11 +3406,11 @@ void CURVE_OT_subdivide(wmOperatorType *ot) ot->name = "Subdivide"; ot->description = "Subdivide selected segments"; ot->idname = "CURVE_OT_subdivide"; - + /* api callbacks */ ot->exec = subdivide_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3568,7 +3568,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Not yet implemented"); return OPERATOR_CANCELLED; } - + for (nu = editnurb->first; nu; nu = nu->next) { if (ED_curve_nurb_select_check(obedit->data, nu)) { const int pntsu_prev = nu->pntsu; @@ -3618,12 +3618,12 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) ot->name = "Set Spline Type"; ot->description = "Set type of active spline"; ot->idname = "CURVE_OT_spline_type_set"; - + /* api callbacks */ ot->exec = set_spline_type_exec; ot->invoke = WM_menu_invoke; ot->poll = ED_operator_editcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3663,12 +3663,12 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot) ot->name = "Set Handle Type"; ot->description = "Set type of handles for selected control points"; ot->idname = "CURVE_OT_handle_type_set"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = set_handle_type_exec; ot->poll = ED_operator_editcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3718,9 +3718,9 @@ static void switchdirection_knots(float *base, int tot) { float *fp1, *fp2, *tempf; int a; - + if (base == NULL || tot == 0) return; - + /* reverse knots */ a = tot; fp1 = base; @@ -3729,7 +3729,7 @@ static void switchdirection_knots(float *base, int tot) while (fp1 != fp2 && a > 0) { SWAP(float, *fp1, *fp2); a--; - fp1++; + fp1++; fp2--; } @@ -3761,15 +3761,15 @@ static void rotate_direction_nurb(Nurb *nu) { BPoint *bp1, *bp2, *temp; int u, v; - + SWAP(int, nu->pntsu, nu->pntsv); SWAP(short, nu->orderu, nu->orderv); SWAP(short, nu->resolu, nu->resolv); SWAP(short, nu->flagu, nu->flagv); - + SWAP(float *, nu->knotsu, nu->knotsv); switchdirection_knots(nu->knotsv, KNOTSV(nu)); - + temp = MEM_dupallocN(nu->bp); bp1 = nu->bp; for (v = 0; v < nu->pntsv; v++) { @@ -3786,7 +3786,7 @@ static bool is_u_selected(Nurb *nu, int u) { BPoint *bp; int v; - + /* what about resolu == 2? */ bp = &nu->bp[u]; for (v = 0; v < nu->pntsv - 1; v++, bp += nu->pntsu) { @@ -3794,7 +3794,7 @@ static bool is_u_selected(Nurb *nu, int u) return true; } } - + return false; } @@ -3815,14 +3815,14 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) BPoint *bp; float dist, headdist, taildist; int a; - + for (nu = editnurb->first; nu; nu = nu->next) { if (ED_curve_nurb_select_check(cu, nu)) { - + nus = (NurbSort *)MEM_callocN(sizeof(NurbSort), "sort"); BLI_addhead(&nbase, nus); nus->nu = nu; - + bp = nu->bp; a = nu->pntsu; while (a--) { @@ -3830,8 +3830,8 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) bp++; } mul_v3_fl(nus->vec, 1.0f / (float)nu->pntsu); - - + + } } @@ -3839,10 +3839,10 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) nus = nbase.first; BLI_remlink(&nbase, nus); BLI_addtail(&nsortbase, nus); - + /* now add, either at head or tail, the closest one */ while (nbase.first) { - + headdist = taildist = 1.0e30; headdo = taildo = NULL; @@ -3862,7 +3862,7 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) } nustest = nustest->next; } - + if (headdist < taildist) { BLI_remlink(&nbase, headdo); BLI_addhead(&nsortbase, headdo); @@ -3879,12 +3879,12 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu BPoint *bp, *bp1, *bp2, *temp; float len1, len2; int origu, u, v; - + /* first nurbs will be changed to make u = resolu-1 selected */ /* 2nd nurbs will be changed to make u = 0 selected */ /* first nurbs: u = resolu-1 selected */ - + if (is_u_selected(nu1, nu1->pntsu - 1)) { /* pass */ } @@ -3915,7 +3915,7 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu } } } - + /* 2nd nurbs: u = 0 selected */ if (is_u_selected(nu2, 0)) { /* pass */ @@ -3945,19 +3945,19 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu } } } - + if (nu1->pntsv != nu2->pntsv) { BKE_report(op->reports, RPT_ERROR, "Resolution does not match"); return; } - + /* ok, now nu1 has the rightmost column and nu2 the leftmost column selected */ /* maybe we need a 'v' flip of nu2? */ - + bp1 = &nu1->bp[nu1->pntsu - 1]; bp2 = nu2->bp; len1 = 0.0; - + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 += nu2->pntsu) { len1 += len_v3v3(bp1->vec, bp2->vec); } @@ -3965,7 +3965,7 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu bp1 = &nu1->bp[nu1->pntsu - 1]; bp2 = &nu2->bp[nu2->pntsu * (nu2->pntsv - 1)]; len2 = 0.0; - + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 -= nu2->pntsu) { len2 += len_v3v3(bp1->vec, bp2->vec); } @@ -3977,12 +3977,12 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) nu1->orderv++; temp = nu1->bp; nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP"); - + bp = nu1->bp; bp1 = temp; - + for (v = 0; v < nu1->pntsv; v++) { - + /* switch direction? */ if (len1 < len2) bp2 = &nu2->bp[v * nu2->pntsu]; else bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu]; @@ -4003,11 +4003,11 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu if (nu1->type == CU_NURBS) { /* merge knots */ BKE_nurb_knot_calc_u(nu1); - + /* make knots, for merged curved for example */ BKE_nurb_knot_calc_v(nu1); } - + MEM_freeN(temp); BLI_remlink(editnurb, nu2); BKE_nurb_free(nu2); @@ -4020,15 +4020,15 @@ static int merge_nurb(bContext *C, wmOperator *op) ListBase *editnurb = object_editcurve_get(obedit); NurbSort *nus1, *nus2; bool ok = true; - + make_selection_list_nurb(cu, editnurb); - + if (nsortbase.first == nsortbase.last) { BLI_freelistN(&nsortbase); BKE_report(op->reports, RPT_ERROR, "Too few selections to merge"); return OPERATOR_CANCELLED; } - + nus1 = nsortbase.first; nus2 = nus1->next; @@ -4058,7 +4058,7 @@ static int merge_nurb(bContext *C, wmOperator *op) else { ok = 0; } - + if (ok == 0) { BKE_report(op->reports, RPT_ERROR, "Resolution does not match"); BLI_freelistN(&nsortbase); @@ -4069,14 +4069,14 @@ static int merge_nurb(bContext *C, wmOperator *op) merge_2_nurb(op, cu, editnurb, nus1->nu, nus2->nu); nus2 = nus2->next; } - + BLI_freelistN(&nsortbase); - + BKE_curve_nurb_active_set(obedit->data, NULL); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DEG_id_tag_update(obedit->data, 0); - + return OPERATOR_FINISHED; } @@ -4094,7 +4094,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) /* first decide if this is a surface merge! */ if (obedit->type == OB_SURF) nu = nubase->first; else nu = NULL; - + while (nu) { const int nu_select_num = ED_curve_nurb_select_count(cu, nu); if (nu_select_num) { @@ -4123,7 +4123,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) if (nu) return merge_nurb(C, op); - + /* find both nurbs and points, nu1 will be put behind nu2 */ for (nu = nubase->first; nu; nu = nu->next) { if (nu->pntsu == 1) @@ -4293,7 +4293,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) ot->name = "Make Segment"; ot->idname = "CURVE_OT_make_segment"; ot->description = "Join two curves by their selected ends"; - + /* api callbacks */ ot->exec = make_segment_exec; ot->poll = ED_operator_editsurfcurve; @@ -4316,10 +4316,10 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend, const void *vert = BKE_curve_vert_active_get(cu); int location[2]; short hand; - + view3d_operator_needs_opengl(C); ED_view3d_viewcontext_init(C, &vc); - + location[0] = mval[0]; location[1] = mval[1]; @@ -4417,7 +4417,7 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend, return true; } - + return false; } @@ -4442,7 +4442,7 @@ bool ed_editnurb_spin(float viewmat[4][4], Object *obedit, const float axis[3], /* imat and center and size */ copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - + axis_angle_to_mat3(cmat, axis, M_PI / 4.0); mul_m3_m3m3(tmat, cmat, bmat); mul_m3_m3m3(rotmat, imat, tmat); @@ -4505,18 +4505,18 @@ static int spin_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); float cent[3], axis[3], viewmat[4][4]; - + RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); - + invert_m4_m4(obedit->imat, obedit->obmat); mul_m4_v3(obedit->imat, cent); - + if (rv3d) copy_m4_m4(viewmat, rv3d->viewmat); else unit_m4(viewmat); - + if (!ed_editnurb_spin(viewmat, obedit, axis, cent)) { BKE_report(op->reports, RPT_ERROR, "Cannot spin"); return OPERATOR_CANCELLED; @@ -4537,13 +4537,13 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); float axis[3] = {0.0f, 0.0f, 1.0f}; - + if (rv3d) copy_v3_v3(axis, rv3d->viewinv[2]); - + RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)->location); RNA_float_set_array(op->ptr, "axis", axis); - + return spin_exec(C, op); } @@ -4553,7 +4553,7 @@ void CURVE_OT_spin(wmOperatorType *ot) ot->name = "Spin"; ot->idname = "CURVE_OT_spin"; ot->description = "Extrude selected boundary row around pivot point and current view axis"; - + /* api callbacks */ ot->exec = spin_exec; ot->invoke = spin_invoke; @@ -4561,7 +4561,7 @@ void CURVE_OT_spin(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -OBJECT_ADD_SIZE_MAXF, OBJECT_ADD_SIZE_MAXF, "Center", "Center in global view space", -1000.0f, 1000.0f); RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); @@ -5085,7 +5085,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) ot->name = "Add Vertex"; ot->idname = "CURVE_OT_vertex_add"; ot->description = "Add a new control point (linked to only selected end-curve one, if any)"; - + /* api callbacks */ ot->exec = add_vertex_exec; ot->invoke = add_vertex_invoke; @@ -5108,7 +5108,7 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op)) EditNurb *editnurb = cu->editnurb; bool changed = false; bool as_curve = false; - + /* first test: curve? */ if (obedit->type != OB_CURVE) { Nurb *nu; @@ -5147,7 +5147,7 @@ void CURVE_OT_extrude(wmOperatorType *ot) ot->name = "Extrude"; ot->description = "Extrude selected control point(s)"; ot->idname = "CURVE_OT_extrude"; - + /* api callbacks */ ot->exec = curve_extrude_exec; ot->poll = ED_operator_editsurfcurve; @@ -5214,7 +5214,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) a = nu->pntsu * nu->pntsv; bp = nu->bp; while (a--) { - + if (bp->f1 & SELECT) { if (direction == 0 && nu->pntsu > 1) { nu->flagu ^= CU_NURB_CYCLIC; @@ -5228,7 +5228,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } bp++; } - + } } } @@ -5276,7 +5276,7 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) ot->name = "Toggle Cyclic"; ot->description = "Make active spline closed/opened loop"; ot->idname = "CURVE_OT_cyclic_toggle"; - + /* api callbacks */ ot->exec = toggle_cyclic_exec; ot->invoke = toggle_cyclic_invoke; @@ -5316,11 +5316,11 @@ void CURVE_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Curve"; ot->description = "Duplicate selected control points"; ot->idname = "CURVE_OT_duplicate"; - + /* api callbacks */ ot->exec = duplicate_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5791,12 +5791,12 @@ void CURVE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete selected control points or segments"; ot->idname = "CURVE_OT_delete"; - + /* api callbacks */ ot->exec = curve_delete_exec; ot->invoke = WM_menu_invoke; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6005,17 +6005,17 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; int clear = (STREQ(op->idname, "CURVE_OT_shade_flat")); - + if (obedit->type != OB_CURVE) return OPERATOR_CANCELLED; - + for (nu = editnurb->first; nu; nu = nu->next) { if (ED_curve_nurb_select_check(obedit->data, nu)) { if (!clear) nu->flag |= CU_SMOOTH; else nu->flag &= ~CU_SMOOTH; } } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DEG_id_tag_update(obedit->data, 0); @@ -6028,11 +6028,11 @@ void CURVE_OT_shade_smooth(wmOperatorType *ot) ot->name = "Shade Smooth"; ot->idname = "CURVE_OT_shade_smooth"; ot->description = "Set shading to smooth"; - + /* api callbacks */ ot->exec = shade_smooth_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -6043,11 +6043,11 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) ot->name = "Shade Flat"; ot->idname = "CURVE_OT_shade_flat"; ot->description = "Set shading to flat"; - + /* api callbacks */ ot->exec = shade_smooth_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -6084,21 +6084,21 @@ int join_curve_exec(bContext *C, wmOperator *op) } BLI_listbase_clear(&tempbase); - + /* trasnform all selected curves inverse in obact */ invert_m4_m4(imat, ob->obmat); - + CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases) { if (base->object->type == ob->type) { if (base->object != ob) { - + cu = base->object->data; - + if (cu->nurb.first) { /* watch it: switch order here really goes wrong */ mul_m4_m4m4(cmat, imat, base->object->obmat); - + nu = cu->nurb.first; while (nu) { newnu = BKE_nurb_duplicate(nu); @@ -6109,7 +6109,7 @@ int join_curve_exec(bContext *C, wmOperator *op) newnu->mat_nr = 0; } BLI_addtail(&tempbase, newnu); - + if ((bezt = newnu->bezt)) { a = newnu->pntsu; while (a--) { @@ -6130,16 +6130,16 @@ int join_curve_exec(bContext *C, wmOperator *op) nu = nu->next; } } - + ED_object_base_free_and_unlink(bmain, scene, base->object); } } } CTX_DATA_END; - + cu = ob->data; BLI_movelisttolist(&cu->nurb, &tempbase); - + if (ob->type == OB_CURVE) { /* Account for mixed 2D/3D curves when joining */ BKE_curve_curve_dimension_update(cu); @@ -6198,11 +6198,11 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) ot->name = "Clear Tilt"; ot->idname = "CURVE_OT_tilt_clear"; ot->description = "Clear the tilt of selected control points"; - + /* api callbacks */ ot->exec = clear_tilt_exec; ot->poll = ED_operator_editcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index bbe88bd1446..e6f5f82f96a 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -1016,7 +1016,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) nu->resolv = 1; nu->orderu = 4; nu->orderv = 1; - + BPoint *bp = nu->bp; BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index a9a8901acc6..7cdfafdad43 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -82,7 +82,7 @@ static int kill_selection(Object *obedit, int ins); static char findaccent(char char1, unsigned int code) { char new = 0; - + if (char1 == 'a') { if (code == '`') new = 224; else if (code == 39) new = 225; @@ -214,7 +214,7 @@ static char findaccent(char char1, unsigned int code) else if (char1 == '+') { if (code == '-') new = 177; } - + if (new) return new; else return char1; } @@ -223,7 +223,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) { Curve *cu = obedit->data; EditFont *ef = cu->editfont; - + if (ef->len < MAXTEXT - 1) { int x; @@ -233,7 +233,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) ef->textbufinfo[ef->pos] = cu->curinfo; ef->textbufinfo[ef->pos].kern = 0; ef->textbufinfo[ef->pos].mat_nr = obedit->actcol; - + ef->pos++; ef->len++; ef->textbuf[ef->len] = '\0'; @@ -378,7 +378,7 @@ static int paste_from_file_exec(bContext *C, wmOperator *op) { char *path; int retval; - + path = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); retval = paste_from_file(C, op->reports, path); MEM_freeN(path); @@ -391,7 +391,7 @@ static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UN if (RNA_struct_property_is_set(op->ptr, "filepath")) return paste_from_file_exec(C, op); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -402,12 +402,12 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot) ot->name = "Paste File"; ot->description = "Paste contents from file"; ot->idname = "FONT_OT_text_paste_from_file"; - + /* api callbacks */ ot->exec = paste_from_file_exec; ot->invoke = paste_from_file_invoke; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -433,7 +433,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const char *s; int a; float rot[3] = {0.f, 0.f, 0.f}; - + obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL); base = view_layer->basact; @@ -506,12 +506,12 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines) linenum++; continue; } - + /* do the translation */ offset[0] = 0; offset[1] = -linenum; offset[2] = 0; - + if (rv3d) mul_mat3_m4_v3(rv3d->viewinv, offset); @@ -607,11 +607,11 @@ void FONT_OT_style_set(wmOperatorType *ot) ot->name = "Set Style"; ot->description = "Set font style"; ot->idname = "FONT_OT_style_set"; - + /* api callbacks */ ot->exec = set_style_exec; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -630,7 +630,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op) if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; - + style = RNA_enum_get(op->ptr, "style"); cu->curinfo.flag ^= style; @@ -645,11 +645,11 @@ void FONT_OT_style_toggle(wmOperatorType *ot) ot->name = "Toggle Style"; ot->description = "Toggle font style"; ot->idname = "FONT_OT_style_toggle"; - + /* api callbacks */ ot->exec = toggle_style_exec; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -703,7 +703,7 @@ void FONT_OT_select_all(wmOperatorType *ot) static void copy_selection(Object *obedit) { int selstart, selend; - + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { Curve *cu = obedit->data; EditFont *ef = cu->editfont; @@ -740,7 +740,7 @@ void FONT_OT_text_copy(wmOperatorType *ot) ot->name = "Copy Text"; ot->description = "Copy selected text to clipboard"; ot->idname = "FONT_OT_text_copy"; - + /* api callbacks */ ot->exec = copy_text_exec; ot->poll = ED_operator_editfont; @@ -770,7 +770,7 @@ void FONT_OT_text_cut(wmOperatorType *ot) ot->name = "Cut Text"; ot->description = "Cut selected text to clipboard"; ot->idname = "FONT_OT_text_cut"; - + /* api callbacks */ ot->exec = cut_text_exec; ot->poll = ED_operator_editfont; @@ -871,7 +871,7 @@ void FONT_OT_text_paste(wmOperatorType *ot) ot->name = "Paste Text"; ot->description = "Paste text from clipboard"; ot->idname = "FONT_OT_text_paste"; - + /* api callbacks */ ot->exec = paste_text_exec; ot->poll = ED_operator_editfont; @@ -915,7 +915,7 @@ static int move_cursor(bContext *C, int type, const bool select) } cursmove = FO_CURS; break; - + case LINE_END: while (ef->pos < ef->len) { if (ef->textbuf[ef->pos] == 0) break; @@ -958,7 +958,7 @@ static int move_cursor(bContext *C, int type, const bool select) case PREV_LINE: cursmove = FO_CURSUP; break; - + case NEXT_LINE: cursmove = FO_CURSDOWN; break; @@ -971,7 +971,7 @@ static int move_cursor(bContext *C, int type, const bool select) cursmove = FO_PAGEDOWN; break; } - + if (cursmove == -1) return OPERATOR_CANCELLED; @@ -1016,7 +1016,7 @@ void FONT_OT_move(wmOperatorType *ot) ot->name = "Move Cursor"; ot->description = "Move cursor to position type"; ot->idname = "FONT_OT_move"; - + /* api callbacks */ ot->exec = move_exec; ot->poll = ED_operator_editfont; @@ -1043,7 +1043,7 @@ void FONT_OT_move_select(wmOperatorType *ot) ot->name = "Move Select"; ot->description = "Move the cursor while selecting"; ot->idname = "FONT_OT_move_select"; - + /* api callbacks */ ot->exec = move_select_exec; ot->poll = ED_operator_editfont; @@ -1084,7 +1084,7 @@ void FONT_OT_change_spacing(wmOperatorType *ot) ot->name = "Change Spacing"; ot->description = "Change font spacing"; ot->idname = "FONT_OT_change_spacing"; - + /* api callbacks */ ot->exec = change_spacing_exec; ot->poll = ED_operator_editfont; @@ -1128,7 +1128,7 @@ void FONT_OT_change_character(wmOperatorType *ot) ot->name = "Change Character"; ot->description = "Change font character code"; ot->idname = "FONT_OT_change_character"; - + /* api callbacks */ ot->exec = change_character_exec; ot->poll = ED_operator_editfont; @@ -1163,7 +1163,7 @@ void FONT_OT_line_break(wmOperatorType *ot) ot->name = "Line Break"; ot->description = "Insert line break at cursor position"; ot->idname = "FONT_OT_line_break"; - + /* api callbacks */ ot->exec = line_break_exec; ot->poll = ED_operator_editfont; @@ -1289,7 +1289,7 @@ void FONT_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete text by cursor position"; ot->idname = "FONT_OT_delete"; - + /* api callbacks */ ot->exec = delete_exec; ot->poll = ED_operator_editfont; @@ -1312,7 +1312,7 @@ static int insert_text_exec(bContext *C, wmOperator *op) if (!RNA_struct_property_is_set(op->ptr, "text")) return OPERATOR_CANCELLED; - + inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0); len = BLI_strlen_utf8(inserted_utf8); @@ -1350,7 +1350,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) accentcode = 1; return OPERATOR_FINISHED; } - + /* tab should exit editmode, but we allow it to be typed using modifier keys */ if (event_type == TABKEY) { if ((alt || ctrl || shift) == 0) @@ -1358,7 +1358,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) else ascii = 9; } - + if (event_type == BACKSPACEKEY) { if (alt && ef->len != 0 && ef->pos > 0) accentcode = 1; @@ -1394,7 +1394,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) else { BLI_assert(0); } - + kill_selection(obedit, 1); text_update_edited(C, obedit, FO_EDIT); } @@ -1418,7 +1418,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* reset property? */ if (event_val == 0) accentcode = 0; - + return OPERATOR_FINISHED; } @@ -1428,12 +1428,12 @@ void FONT_OT_text_insert(wmOperatorType *ot) ot->name = "Insert Text"; ot->description = "Insert text at cursor position"; ot->idname = "FONT_OT_text_insert"; - + /* api callbacks */ ot->exec = insert_text_exec; ot->invoke = insert_text_invoke; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1449,14 +1449,14 @@ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_active_object(C); Curve *cu = obedit->data; int i; - + if (cu->totbox < 256) { for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1]; cu->tb[cu->actbox] = cu->tb[cu->actbox - 1]; cu->actbox++; cu->totbox++; } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -1467,15 +1467,15 @@ void FONT_OT_textbox_add(wmOperatorType *ot) ot->name = "Add Textbox"; ot->description = "Add a new text box"; ot->idname = "FONT_OT_textbox_add"; - + /* api callbacks */ ot->exec = textbox_add_exec; ot->poll = ED_operator_object_active_editable_font; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - + + } @@ -1490,17 +1490,17 @@ static int textbox_remove_exec(bContext *C, wmOperator *op) Curve *cu = obedit->data; int i; int index = RNA_int_get(op->ptr, "index"); - - + + if (cu->totbox > 1) { for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1]; cu->totbox--; if (cu->actbox >= index) cu->actbox--; } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - + return OPERATOR_FINISHED; } @@ -1510,14 +1510,14 @@ void FONT_OT_textbox_remove(wmOperatorType *ot) ot->name = "Remove Textbox"; ot->description = "Remove the textbox"; ot->idname = "FONT_OT_textbox_remove"; - + /* api callbacks */ ot->exec = textbox_remove_exec; ot->poll = ED_operator_object_active_editable_font; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX); } @@ -1530,14 +1530,14 @@ void ED_curve_editfont_make(Object *obedit) Curve *cu = obedit->data; EditFont *ef = cu->editfont; int len_wchar; - + if (ef == NULL) { ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont"); - + ef->textbuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditbuf"); ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo"); } - + /* Convert the original text to wchar_t */ len_wchar = BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); BLI_assert(len_wchar == cu->len_wchar); @@ -1576,7 +1576,7 @@ void ED_curve_editfont_load(Object *obedit) /* Copy the wchar to UTF-8 */ BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, cu->len + 1); - + if (cu->strinfo) MEM_freeN(cu->strinfo); cu->strinfo = MEM_callocN((cu->len_wchar + 4) * sizeof(CharInfo), "texteditinfo"); @@ -1608,7 +1608,7 @@ static int set_case(bContext *C, int ccase) wchar_t *str; int len; int selstart, selend; - + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { len = (selend - selstart) + 1; str = &ef->textbuf[selstart]; @@ -1648,7 +1648,7 @@ void FONT_OT_case_set(wmOperatorType *ot) ot->name = "Set Case"; ot->description = "Set font case"; ot->idname = "FONT_OT_case_set"; - + /* api callbacks */ ot->exec = set_case_exec; ot->poll = ED_operator_editfont; @@ -1669,7 +1669,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op)) EditFont *ef = cu->editfont; wchar_t *str; int len, ccase = CASE_UPPER; - + len = wcslen(ef->textbuf); str = ef->textbuf; while (len) { @@ -1681,7 +1681,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op)) len--; str++; } - + return set_case(C, ccase); } @@ -1691,7 +1691,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot) ot->name = "Toggle Case"; ot->description = "Toggle font case"; ot->idname = "FONT_OT_case_toggle"; - + /* api callbacks */ ot->exec = toggle_case_exec; ot->poll = ED_operator_editfont; @@ -1705,7 +1705,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot) static void font_ui_template_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; - + op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop); } @@ -1734,7 +1734,7 @@ static int font_open_exec(bContext *C, wmOperator *op) if (!op->customdata) font_ui_template_init(C, op); - + /* hook into UI */ pprop = op->customdata; @@ -1742,7 +1742,7 @@ static int font_open_exec(bContext *C, wmOperator *op) /* when creating new ID blocks, use is already 1, but RNA * pointer use also increases user, so this compensates it */ id_us_min(&font->id); - + RNA_id_pointer_create(&font->id, &idptr); RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); @@ -1777,7 +1777,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event) return font_open_exec(C, op); RNA_string_set(op->ptr, "filepath", path); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -1788,15 +1788,15 @@ void FONT_OT_open(wmOperatorType *ot) ot->name = "Open Font"; ot->idname = "FONT_OT_open"; ot->description = "Load a new font from a file"; - + /* api callbacks */ ot->exec = font_open_exec; ot->invoke = open_invoke; ot->cancel = font_open_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_FTFONT, FILE_SPECIAL, FILE_OPENFILE, @@ -1813,7 +1813,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op) PropertyPointerRNA pprop; UI_context_active_but_prop_get_templateID(C, &pprop.ptr, &pprop.prop); - + if (pprop.prop == NULL) { BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink"); return OPERATOR_CANCELLED; @@ -1834,7 +1834,7 @@ void FONT_OT_unlink(wmOperatorType *ot) ot->name = "Unlink"; ot->idname = "FONT_OT_unlink"; ot->description = "Unlink active font data-block"; - + /* api callbacks */ ot->exec = font_unlink_exec; } |