Multi-Object-Mode: EditLattice Select All

D3164 by @ranjian0
This commit is contained in:
Campbell Barton 2018-05-22 08:11:13 +02:00
parent 99f994e7ed
commit ee1327a84c
Notes: blender-bot 2023-03-24 17:05:22 +01:00
Referenced by issue #54647, Multi-Object-Mode: Edit Lattice Tools
3 changed files with 55 additions and 33 deletions

View File

@ -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,

View File

@ -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),

View File

@ -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;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Lattice *lt;
BPoint *bp;
int a;
while (a--) {
if (bp->hide == 0) {
bp->f1 ^= SELECT;
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;
}