Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-26 10:47:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-26 12:25:25 +0300
commit40f8ddf8297a062968fc6a1523aa210d69c22626 (patch)
tree27e26dd44f3e8778ad06012d184fcb11ed175c94 /source/blender/editors/curve/editcurve_select.c
parent30fbf905ef8bd587eef43030b81d75b9eb704bec (diff)
3D View: move deselect all logic into an option
This removes `VIEW3D_OT_select_or_deselect_all`, adding a deselect_all option to the `VIEW3D_OT_select` operator. - Add utility functions to simplify de-selecting all. - Return true from selection functions when they change the selection to avoid redundant updates. - Use arrays of bases when passing objects between selection utility functions since some users require bases. - Fix logical error in box selection that updated all objects after the first hit.
Diffstat (limited to 'source/blender/editors/curve/editcurve_select.c')
-rw-r--r--source/blender/editors/curve/editcurve_select.c103
1 files changed, 69 insertions, 34 deletions
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index c52e5d3d787..7ba1b6b0cef 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -163,15 +163,18 @@ int ED_curve_nurb_select_count(View3D *v3d, Nurb *nu)
return sel;
}
-void ED_curve_nurb_select_all(Nurb *nu)
+bool ED_curve_nurb_select_all(const Nurb *nu)
{
+ bool changed = false;
int i;
-
if (nu->bezt) {
BezTriple *bezt;
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
if (bezt->hide == 0) {
- BEZT_SEL_ALL(bezt);
+ if (BEZT_ISSEL_ALL(bezt) == false) {
+ BEZT_SEL_ALL(bezt);
+ changed = true;
+ }
}
}
}
@@ -179,36 +182,48 @@ void ED_curve_nurb_select_all(Nurb *nu)
BPoint *bp;
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
if (bp->hide == 0) {
- bp->f1 |= SELECT;
+ if ((bp->f1 & SELECT) == 0) {
+ bp->f1 |= SELECT;
+ changed = true;
+ }
}
}
}
+ return changed;
}
-void ED_curve_select_all(EditNurb *editnurb)
+bool ED_curve_select_all(EditNurb *editnurb)
{
- Nurb *nu;
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
- ED_curve_nurb_select_all(nu);
+ bool changed = false;
+ for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ changed |= ED_curve_nurb_select_all(nu);
}
+ return changed;
}
-void ED_curve_nurb_deselect_all(Nurb *nu)
+bool ED_curve_nurb_deselect_all(const Nurb *nu)
{
+ bool changed = false;
int i;
-
if (nu->bezt) {
BezTriple *bezt;
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
- BEZT_DESEL_ALL(bezt);
+ if (BEZT_ISSEL_ANY(bezt)) {
+ BEZT_DESEL_ALL(bezt);
+ changed = true;
+ }
}
}
else if (nu->bp) {
BPoint *bp;
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
- bp->f1 &= ~SELECT;
+ if (bp->f1 & SELECT) {
+ bp->f1 &= ~SELECT;
+ changed = true;
+ }
}
}
+ return changed;
}
int ED_curve_select_count(View3D *v3d, struct EditNurb *editnurb)
@@ -236,30 +251,45 @@ bool ED_curve_select_check(View3D *v3d, struct EditNurb *editnurb)
return false;
}
-void ED_curve_deselect_all(EditNurb *editnurb)
+bool ED_curve_deselect_all(EditNurb *editnurb)
{
- Nurb *nu;
-
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
- ED_curve_nurb_deselect_all(nu);
+ bool changed = false;
+ for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ changed |= ED_curve_nurb_deselect_all(nu);
}
+ return changed;
}
-void ED_curve_deselect_all_multi(Object **objects, int objects_len)
+bool ED_curve_deselect_all_multi_ex(Base **bases, int bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
Curve *cu = obedit->data;
- ED_curve_deselect_all(cu->editnurb);
+ changed_multi |= ED_curve_deselect_all(cu->editnurb);
+ DEG_id_tag_update(&cu->id, ID_RECALC_SELECT);
}
+ return changed_multi;
+}
+
+bool ED_curve_deselect_all_multi(struct bContext *C)
+{
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(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;
}
-void ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
+bool ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
{
Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
+ bool changed = false;
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
@@ -272,6 +302,7 @@ void ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
bezt->f1 ^= SELECT;
bezt->f3 ^= SELECT;
}
+ changed = true;
}
bezt++;
}
@@ -280,11 +311,15 @@ void ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
while (a--) {
- swap_selection_bpoint(bp);
+ if (bp->hide == 0) {
+ swap_selection_bpoint(bp);
+ changed = true;
+ }
bp++;
}
}
}
+ return changed;
}
/**
@@ -489,7 +524,6 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
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);
-
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -506,22 +540,25 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
+ bool changed = false;
switch (action) {
case SEL_SELECT:
- ED_curve_select_all(cu->editnurb);
+ changed = ED_curve_select_all(cu->editnurb);
break;
case SEL_DESELECT:
- ED_curve_deselect_all(cu->editnurb);
+ changed = ED_curve_deselect_all(cu->editnurb);
break;
case SEL_INVERT:
- ED_curve_select_swap(cu->editnurb, (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0);
+ changed = ED_curve_select_swap(cu->editnurb, (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0);
break;
}
- 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(cu);
+ if (changed) {
+ 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(cu);
+ }
}
MEM_freeN(objects);
@@ -567,8 +604,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
for (nu = nurbs->first; nu; nu = nu->next) {
if (ED_curve_nurb_select_check(v3d, nu)) {
- ED_curve_nurb_select_all(nu);
- changed = true;
+ changed |= ED_curve_nurb_select_all(nu);
}
}
@@ -1634,8 +1670,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
case SIMCURHAND_TYPE:
{
if (nu->type & type_ref) {
- ED_curve_nurb_select_all(nu);
- changed = true;
+ changed |= ED_curve_nurb_select_all(nu);
}
break;
}