Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/curve/editcurve_select.c
| Context not available. | |||||
| /* basic method: deselect if control point doesn't have all neighbors selected */ | /* basic method: deselect if control point doesn't have all neighbors selected */ | ||||
| static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) | static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | |||||
| ListBase *editnurb = object_editcurve_get(obedit); | |||||
| Nurb *nu; | Nurb *nu; | ||||
| BPoint *bp; | BPoint *bp; | ||||
| BezTriple *bezt; | BezTriple *bezt; | ||||
| Context not available. | |||||
| int sel = 0; | int sel = 0; | ||||
| bool lastsel = false; | bool lastsel = false; | ||||
| if (obedit->type == OB_SURF) { | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| for (nu = editnurb->first; nu; nu = nu->next) { | uint objects_len = 0; | ||||
| BLI_bitmap *selbpoints; | Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); | ||||
| a = nu->pntsu * nu->pntsv; | for (uint ob_index = 0; ob_index < objects_len; ob_index++) | ||||
| bp = nu->bp; | { | ||||
| selbpoints = BLI_BITMAP_NEW(a, "selectlist"); | Object *obedit = objects[ob_index]; | ||||
| while (a--) { | ListBase *editnurb = object_editcurve_get(obedit); | ||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) { | |||||
| sel = 0; | |||||
| /* check if neighbors have been selected */ | |||||
| /* edges of surface are an exception */ | |||||
| if ((a + 1) % nu->pntsu == 0) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bp--; | |||||
| if (BLI_BITMAP_TEST(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; | |||||
| bp++; | |||||
| } | |||||
| if ((a + 1) % nu->pntsu == 1) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bp++; | |||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | |||||
| bp--; | |||||
| } | |||||
| if (a + 1 > nu->pntsu * nu->pntsv - nu->pntsu) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bp -= nu->pntsu; | |||||
| if (BLI_BITMAP_TEST(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; | |||||
| bp += nu->pntsu; | |||||
| } | |||||
| if (a < nu->pntsu) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bp += nu->pntsu; | |||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | |||||
| bp -= nu->pntsu; | |||||
| } | |||||
| if (sel != 4) { | |||||
| select_bpoint(bp, DESELECT, SELECT, VISIBLE); | |||||
| BLI_BITMAP_ENABLE(selbpoints, a); | |||||
| } | |||||
| } | |||||
| else { | |||||
| lastsel = false; | |||||
| } | |||||
| bp++; | |||||
| } | |||||
| MEM_freeN(selbpoints); | if (obedit->type == OB_SURF) { | ||||
| } | for (nu = editnurb->first; nu; nu = nu->next) { | ||||
| } | BLI_bitmap *selbpoints; | ||||
| else { | a = nu->pntsu * nu->pntsv; | ||||
| for (nu = editnurb->first; nu; nu = nu->next) { | bp = nu->bp; | ||||
| lastsel = false; | selbpoints = BLI_BITMAP_NEW(a, "selectlist"); | ||||
| /* check what type of curve/nurb it is */ | |||||
| if (nu->type == CU_BEZIER) { | |||||
| a = nu->pntsu; | |||||
| bezt = nu->bezt; | |||||
| while (a--) { | while (a--) { | ||||
| if ((bezt->hide == 0) && (bezt->f2 & SELECT)) { | if ((bp->hide == 0) && (bp->f1 & SELECT)) { | ||||
| sel = (lastsel == 1); | sel = 0; | ||||
| /* check if neighbors have been selected */ | /* check if neighbors have been selected */ | ||||
| /* first and last are exceptions */ | /* edges of surface are an exception */ | ||||
| if (a == nu->pntsu - 1) { | if ((a + 1) % nu->pntsu == 0) { | ||||
| sel++; | sel++; | ||||
| } | } | ||||
| else { | else { | ||||
| bezt--; | bp--; | ||||
| if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; | if (BLI_BITMAP_TEST(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; | ||||
| bezt++; | bp++; | ||||
| } | } | ||||
| if (a == 0) { | if ((a + 1) % nu->pntsu == 1) { | ||||
| sel++; | sel++; | ||||
| } | } | ||||
| else { | else { | ||||
| bezt++; | bp++; | ||||
| if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; | if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | ||||
| bezt--; | bp--; | ||||
| } | } | ||||
| if (sel != 2) { | if (a + 1 > nu->pntsu * nu->pntsv - nu->pntsu) { | ||||
| select_beztriple(bezt, DESELECT, SELECT, VISIBLE); | sel++; | ||||
| lastsel = true; | |||||
| } | } | ||||
| else { | else { | ||||
| lastsel = false; | bp -= nu->pntsu; | ||||
| if (BLI_BITMAP_TEST(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; | |||||
| bp += nu->pntsu; | |||||
| } | |||||
| if (a < nu->pntsu) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bp += nu->pntsu; | |||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | |||||
| bp -= nu->pntsu; | |||||
| } | |||||
| if (sel != 4) { | |||||
| select_bpoint(bp, DESELECT, SELECT, VISIBLE); | |||||
| BLI_BITMAP_ENABLE(selbpoints, a); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| lastsel = false; | lastsel = false; | ||||
| } | } | ||||
| bezt++; | bp++; | ||||
| } | } | ||||
| MEM_freeN(selbpoints); | |||||
| } | } | ||||
| else { | } | ||||
| a = nu->pntsu * nu->pntsv; | else { | ||||
| bp = nu->bp; | for (nu = editnurb->first; nu; nu = nu->next) { | ||||
| while (a--) { | lastsel = false; | ||||
| if ((lastsel == false) && (bp->hide == 0) && (bp->f1 & SELECT)) { | /* check what type of curve/nurb it is */ | ||||
| sel = 0; | if (nu->type == CU_BEZIER) { | ||||
| a = nu->pntsu; | |||||
| bezt = nu->bezt; | |||||
| while (a--) { | |||||
| if ((bezt->hide == 0) && (bezt->f2 & SELECT)) { | |||||
| sel = (lastsel == 1); | |||||
| /* check if neighbors have been selected */ | |||||
| /* first and last are exceptions */ | |||||
| if (a == nu->pntsu - 1) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bezt--; | |||||
| if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; | |||||
| bezt++; | |||||
| } | |||||
| /* first and last are exceptions */ | if (a == 0) { | ||||
| if (a == nu->pntsu * nu->pntsv - 1) { | sel++; | ||||
| sel++; | } | ||||
| } | else { | ||||
| else { | bezt++; | ||||
| bp--; | if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; | ||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | bezt--; | ||||
| bp++; | } | ||||
| } | |||||
| if (a == 0) { | if (sel != 2) { | ||||
| sel++; | select_beztriple(bezt, DESELECT, SELECT, VISIBLE); | ||||
| lastsel = true; | |||||
| } | |||||
| else { | |||||
| lastsel = false; | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| bp++; | lastsel = false; | ||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | |||||
| bp--; | |||||
| } | } | ||||
| if (sel != 2) { | bezt++; | ||||
| select_bpoint(bp, DESELECT, SELECT, VISIBLE); | } | ||||
| lastsel = true; | } | ||||
| else { | |||||
| a = nu->pntsu * nu->pntsv; | |||||
| bp = nu->bp; | |||||
| while (a--) { | |||||
| if ((lastsel == false) && (bp->hide == 0) && (bp->f1 & SELECT)) { | |||||
| sel = 0; | |||||
| /* first and last are exceptions */ | |||||
| if (a == nu->pntsu * nu->pntsv - 1) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bp--; | |||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | |||||
| bp++; | |||||
| } | |||||
| if (a == 0) { | |||||
| sel++; | |||||
| } | |||||
| else { | |||||
| bp++; | |||||
| if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; | |||||
| bp--; | |||||
| } | |||||
| if (sel != 2) { | |||||
| select_bpoint(bp, DESELECT, SELECT, VISIBLE); | |||||
| lastsel = true; | |||||
| } | |||||
| else { | |||||
| lastsel = false; | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| lastsel = false; | lastsel = false; | ||||
| } | } | ||||
| } | |||||
| else { | |||||
| lastsel = false; | |||||
| } | |||||
| bp++; | bp++; | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); | WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); | ||||
| BKE_curve_nurb_vert_active_validate(obedit->data); | BKE_curve_nurb_vert_active_validate(obedit->data); | ||||
| } | |||||
| MEM_freeN(objects); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Context not available. | |||||