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>2018-05-22 09:11:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-22 09:11:13 +0300
commitee1327a84cd5d76f58d40df28d8f8b30f7674d4a (patch)
tree0786e2a38f0ea2994b10f793cf8878c5bdd603c3 /source/blender
parent99f994e7edfd20fb162ea45cad09b5e8c7fc7e26 (diff)
Multi-Object-Mode: EditLattice Select All
D3164 by @ranjian0
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_lattice.h2
-rw-r--r--source/blender/blenkernel/intern/lattice.c16
-rw-r--r--source/blender/editors/lattice/editlattice_select.c72
3 files changed, 56 insertions, 34 deletions
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index d5c241d43e4..b722b7da6a0 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -92,6 +92,8 @@ void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3]);
void BKE_lattice_translate(struct Lattice *lt, float offset[3], bool do_keys);
void BKE_lattice_transform(struct Lattice *lt, float mat[4][4], bool do_keys);
+bool BKE_lattice_is_any_selected(const struct Lattice *lt);
+
int BKE_lattice_index_from_uvw(struct Lattice *lt, const int u, const int v, const int w);
void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index, int *r_u, int *r_v, int *r_w);
int BKE_lattice_index_flip(struct Lattice *lt, const int index,
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index d7105d3423f..2a60bd94d10 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -1229,6 +1229,22 @@ void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys)
}
}
+bool BKE_lattice_is_any_selected(const Lattice *lt)
+{
+ /* Intentionally don't handle 'lt->editlatt' (caller must do this). */
+ const BPoint *bp = lt->def;
+ int a = lt->pntsu * lt->pntsv * lt->pntsw;
+ while (a--) {
+ if (bp->hide == 0) {
+ if (bp->f1 & SELECT) {
+ return true;
+ }
+ }
+ bp++;
+ }
+ return false;
+}
+
/* **** Depsgraph evaluation **** */
void BKE_lattice_eval_geometry(struct Depsgraph *UNUSED(depsgraph),
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index ccf90452b0f..2ba1dde243b 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -366,51 +366,55 @@ void ED_lattice_flags_set(Object *obedit, int flag)
static int lattice_select_all_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- Lattice *lt = obedit->data;
- BPoint *bp;
- int a;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
int action = RNA_enum_get(op->ptr, "action");
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
-
- bp = lt->editlatt->latt->def;
- a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-
- while (a--) {
- if (bp->hide == 0) {
- if (bp->f1 & SELECT) {
- action = SEL_DESELECT;
- break;
- }
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt = obedit->data;
+ if (BKE_lattice_is_any_selected(lt->editlatt->latt)) {
+ action = SEL_DESELECT;
+ break;
}
- bp++;
}
}
- switch (action) {
- case SEL_SELECT:
- ED_lattice_flags_set(obedit, 1);
- break;
- case SEL_DESELECT:
- ED_lattice_flags_set(obedit, 0);
- break;
- case SEL_INVERT:
- bp = lt->editlatt->latt->def;
- a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
- lt->editlatt->latt->actbp = LT_ACTBP_NONE;
-
- while (a--) {
- if (bp->hide == 0) {
- bp->f1 ^= SELECT;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt;
+ BPoint *bp;
+ int a;
+
+ switch (action) {
+ case SEL_SELECT:
+ ED_lattice_flags_set(obedit, 1);
+ break;
+ case SEL_DESELECT:
+ ED_lattice_flags_set(obedit, 0);
+ break;
+ case SEL_INVERT:
+ lt = obedit->data;
+ bp = lt->editlatt->latt->def;
+ a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+ lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+
+ while (a--) {
+ if (bp->hide == 0) {
+ bp->f1 ^= SELECT;
+ }
+ bp++;
}
- bp++;
- }
- break;
+ break;
+ }
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
+ MEM_freeN(objects);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}