diff options
Diffstat (limited to 'source/blender/editors/curve/editcurve_select.c')
-rw-r--r-- | source/blender/editors/curve/editcurve_select.c | 100 |
1 files changed, 55 insertions, 45 deletions
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index 5a1777b7097..9c0c580f699 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -30,7 +30,6 @@ #include "ED_object.h" #include "ED_screen.h" #include "ED_select_utils.h" -#include "ED_types.h" #include "ED_view3d.h" #include "curve_intern.h" @@ -47,7 +46,7 @@ bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Types hidden) { if ((bezt->hide == 0) || (hidden == HIDDEN)) { - if (selstatus == SELECT) { /* selects */ + if (selstatus) { /* selects */ bezt->f1 |= flag; bezt->f2 |= flag; bezt->f3 |= flag; @@ -66,7 +65,7 @@ bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Ty bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden) { if ((bp->hide == 0) || (hidden == 1)) { - if (selstatus == SELECT) { + if (selstatus) { bp->f1 |= flag; return true; } @@ -80,17 +79,17 @@ bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden) static bool swap_selection_beztriple(BezTriple *bezt) { if (bezt->f2 & SELECT) { - return select_beztriple(bezt, DESELECT, SELECT, VISIBLE); + return select_beztriple(bezt, false, SELECT, VISIBLE); } - return select_beztriple(bezt, SELECT, SELECT, VISIBLE); + return select_beztriple(bezt, true, SELECT, VISIBLE); } static bool swap_selection_bpoint(BPoint *bp) { if (bp->f1 & SELECT) { - return select_bpoint(bp, DESELECT, SELECT, VISIBLE); + return select_bpoint(bp, false, SELECT, VISIBLE); } - return select_bpoint(bp, SELECT, SELECT, VISIBLE); + return select_bpoint(bp, true, SELECT, VISIBLE); } bool ED_curve_nurb_select_check(const View3D *v3d, const Nurb *nu) @@ -260,7 +259,7 @@ bool ED_curve_deselect_all_multi(struct bContext *C) ED_view3d_viewcontext_init(C, &vc, depsgraph); uint bases_len = 0; Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data( - vc.view_layer, vc.v3d, &bases_len); + vc.scene, vc.view_layer, vc.v3d, &bases_len); bool changed_multi = ED_curve_deselect_all_multi_ex(bases, bases_len); MEM_freeN(bases); return changed_multi; @@ -336,9 +335,9 @@ static void select_adjacent_cp(ListBase *editnurb, break; } if ((lastsel == false) && (bezt->hide == 0) && - ((bezt->f2 & SELECT) || (selstatus == DESELECT))) { + ((bezt->f2 & SELECT) || (selstatus == false))) { bezt += next; - if (!(bezt->f2 & SELECT) || (selstatus == DESELECT)) { + if (!(bezt->f2 & SELECT) || (selstatus == false)) { bool sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE); if (sel && !cont) { lastsel = true; @@ -363,10 +362,9 @@ static void select_adjacent_cp(ListBase *editnurb, if (a - abs(next) < 0) { break; } - if ((lastsel == false) && (bp->hide == 0) && - ((bp->f1 & SELECT) || (selstatus == DESELECT))) { + if ((lastsel == false) && (bp->hide == 0) && ((bp->f1 & SELECT) || (selstatus == false))) { bp += next; - if (!(bp->f1 & SELECT) || (selstatus == DESELECT)) { + if (!(bp->f1 & SELECT) || (selstatus == false)) { bool sel = select_bpoint(bp, selstatus, SELECT, VISIBLE); if (sel && !cont) { lastsel = true; @@ -470,14 +468,15 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op)) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; - selectend_nurb(obedit, FIRST, true, DESELECT); + selectend_nurb(obedit, FIRST, true, false); DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); BKE_curve_nurb_vert_active_validate(obedit->data); @@ -503,14 +502,15 @@ void CURVE_OT_de_select_first(wmOperatorType *ot) static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; - selectend_nurb(obedit, LAST, true, DESELECT); + selectend_nurb(obedit, LAST, true, false); DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); BKE_curve_nurb_vert_active_validate(obedit->data); @@ -545,11 +545,12 @@ static int de_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); if (action == SEL_TOGGLE) { action = SEL_SELECT; for (uint ob_index = 0; ob_index < objects_len; ob_index++) { @@ -618,12 +619,13 @@ void CURVE_OT_select_all(wmOperatorType *ot) static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; Curve *cu = obedit->data; @@ -780,12 +782,12 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) for (b = 0; b < nu->pntsu; b++, bp++) { if (direction) { if (a == v) { - select_bpoint(bp, SELECT, SELECT, VISIBLE); + select_bpoint(bp, true, SELECT, VISIBLE); } } else { if (b == u) { - select_bpoint(bp, SELECT, SELECT, VISIBLE); + select_bpoint(bp, true, SELECT, VISIBLE); } } } @@ -820,10 +822,11 @@ void CURVE_OT_select_row(wmOperatorType *ot) static int select_next_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; @@ -861,10 +864,11 @@ void CURVE_OT_select_next(wmOperatorType *ot) static int select_previous_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; @@ -918,12 +922,12 @@ static void curve_select_more(Object *obedit) bp = nu->bp; selbpoints = BLI_BITMAP_NEW(a, "selectlist"); while (a > 0) { - if ((!BLI_BITMAP_TEST(selbpoints, a)) && (bp->hide == 0) && (bp->f1 & SELECT)) { + if (!BLI_BITMAP_TEST(selbpoints, a) && (bp->hide == 0) && (bp->f1 & SELECT)) { /* upper control point */ if (a % nu->pntsu != 0) { tempbp = bp - 1; if (!(tempbp->f1 & SELECT)) { - select_bpoint(tempbp, SELECT, SELECT, VISIBLE); + select_bpoint(tempbp, true, SELECT, VISIBLE); } } @@ -932,7 +936,7 @@ static void curve_select_more(Object *obedit) sel = 0; tempbp = bp + nu->pntsu; if (!(tempbp->f1 & SELECT)) { - sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE); + sel = select_bpoint(tempbp, true, SELECT, VISIBLE); } /* make sure selected bpoint is discarded */ if (sel == 1) { @@ -944,7 +948,7 @@ static void curve_select_more(Object *obedit) if (a + nu->pntsu < nu->pntsu * nu->pntsv) { tempbp = bp - nu->pntsu; if (!(tempbp->f1 & SELECT)) { - select_bpoint(tempbp, SELECT, SELECT, VISIBLE); + select_bpoint(tempbp, true, SELECT, VISIBLE); } } @@ -953,7 +957,7 @@ static void curve_select_more(Object *obedit) sel = 0; tempbp = bp + 1; if (!(tempbp->f1 & SELECT)) { - sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE); + sel = select_bpoint(tempbp, true, SELECT, VISIBLE); } if (sel) { bp++; @@ -977,10 +981,11 @@ static void curve_select_more(Object *obedit) static int curve_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; curve_select_more(obedit); @@ -1080,7 +1085,7 @@ static void curve_select_less(Object *obedit) } if (sel != 4) { - select_bpoint(bp, DESELECT, SELECT, VISIBLE); + select_bpoint(bp, false, SELECT, VISIBLE); BLI_BITMAP_ENABLE(selbpoints, a); } } @@ -1130,7 +1135,7 @@ static void curve_select_less(Object *obedit) } if (sel != 2) { - select_beztriple(bezt, DESELECT, SELECT, VISIBLE); + select_beztriple(bezt, false, SELECT, VISIBLE); lastsel = true; } else { @@ -1175,7 +1180,7 @@ static void curve_select_less(Object *obedit) } if (sel != 2) { - select_bpoint(bp, DESELECT, SELECT, VISIBLE); + select_bpoint(bp, false, SELECT, VISIBLE); lastsel = true; } else { @@ -1195,10 +1200,11 @@ static void curve_select_less(Object *obedit) static int curve_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; curve_select_less(obedit); @@ -1236,10 +1242,11 @@ static int curve_select_random_exec(bContext *C, wmOperator *op) const float randfac = RNA_float_get(op->ptr, "ratio"); const int seed = WM_operator_properties_select_random_seed_increment_get(op); + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; @@ -1359,7 +1366,7 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, const struct CheckerInter while (a--) { const int depth = abs(start - a); if (!WM_operator_properties_checker_interval_test(params, depth)) { - select_beztriple(bezt, DESELECT, SELECT, HIDDEN); + select_beztriple(bezt, false, SELECT, HIDDEN); } bezt--; @@ -1382,7 +1389,7 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, const struct CheckerIntervalPara while (a--) { const int depth = abs(pnt - startpnt) + abs(row - startrow); if (!WM_operator_properties_checker_interval_test(params, depth)) { - select_bpoint(bp, DESELECT, SELECT, HIDDEN); + select_bpoint(bp, false, SELECT, HIDDEN); } pnt--; @@ -1416,6 +1423,7 @@ static bool ed_curve_select_nth(Curve *cu, const struct CheckerIntervalParams *p static int select_nth_exec(bContext *C, wmOperator *op) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obact = CTX_data_edit_object(C); View3D *v3d = CTX_wm_view3d(C); @@ -1426,7 +1434,7 @@ static int select_nth_exec(bContext *C, wmOperator *op) uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; Curve *cu = obedit->data; @@ -1645,7 +1653,7 @@ static bool curve_nurb_select_similar_type(Object *ob, } if (select) { - select_beztriple(bezt, SELECT, SELECT, VISIBLE); + select_beztriple(bezt, true, SELECT, VISIBLE); changed = true; } } @@ -1690,7 +1698,7 @@ static bool curve_nurb_select_similar_type(Object *ob, } if (select) { - select_bpoint(bp, SELECT, SELECT, VISIBLE); + select_bpoint(bp, true, SELECT, VISIBLE); changed = true; } } @@ -1706,12 +1714,13 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op) const float thresh = RNA_float_get(op->ptr, "threshold"); const int compare = RNA_enum_get(op->ptr, "compare"); + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); int tot_nurbs_selected_all = 0; uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; @@ -1898,10 +1907,10 @@ static void curve_select_shortest_path_curve(Nurb *nu, int vert_src, int vert_ds i = vert_src; while (true) { if (nu->type & CU_BEZIER) { - select_beztriple(&nu->bezt[i], SELECT, SELECT, HIDDEN); + select_beztriple(&nu->bezt[i], true, SELECT, HIDDEN); } else { - select_bpoint(&nu->bp[i], SELECT, SELECT, HIDDEN); + select_bpoint(&nu->bp[i], true, SELECT, HIDDEN); } if (i == vert_dst) { @@ -1979,10 +1988,10 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst int i = 0; while (vert_curr != vert_src && i++ < vert_num) { if (nu->type == CU_BEZIER) { - select_beztriple(&nu->bezt[vert_curr], SELECT, SELECT, HIDDEN); + select_beztriple(&nu->bezt[vert_curr], true, SELECT, HIDDEN); } else { - select_bpoint(&nu->bp[vert_curr], SELECT, SELECT, HIDDEN); + select_bpoint(&nu->bp[vert_curr], true, SELECT, HIDDEN); } vert_curr = data[vert_curr].vert_prev; } @@ -2040,7 +2049,8 @@ static int edcu_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE BKE_curve_nurb_vert_active_set(cu, nu_dst, vert_dst_p); - if (vc.view_layer->basact != basact) { + BKE_view_layer_synced_ensure(vc.scene, vc.view_layer); + if (BKE_view_layer_active_base_get(vc.view_layer) != basact) { ED_object_base_activate(C, basact); } |