Fix T61531: can't select same material in multi edit mode
D4441 by @zazizizou w/ edits.
This commit is contained in:
parent
3017d88aec
commit
6b39dc7672
Notes:
blender-bot
2023-02-14 08:42:53 +01:00
Referenced by issue #62698, crash during hair particel , edit broom,cut Referenced by issue #62700, disconnect hair bug Referenced by issue #62701, Hair edit mode crashes with AMD Radeon HD 5700 Referenced by issue #62654, eevee display object as wireframe in viewport is not rendered Referenced by issue #62629, gease pencil ,jitter settings of 0.001 Referenced by issue #62616, belender becomes unresponsive when subdiv is inserted Referenced by issue #62572, unwrapping bug Referenced by issue #62583, poly build alt +click does not desolve vertex Referenced by issue #62550, error traceback call during unwrapping Referenced by issue #62557, object display as wire , invisible when overlay is turned off Referenced by issue #62500, VSE doesn't work with left click select Referenced by issue #62487, inverted normal on a single face when extruding a loop Referenced by issue #62480, Closing files takes about 5 times longer Referenced by issue #61531, can't select the same material in multi edit mode
|
@ -288,18 +288,46 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
|
|||
static int material_slot_de_select(bContext *C, bool select)
|
||||
{
|
||||
bool changed_multi = false;
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
const Material *mat_active = obact ? give_current_material(obact, obact->actcol) : NULL;
|
||||
|
||||
uint objects_len = 0;
|
||||
Object **objects = object_array_for_shading(C, &objects_len);
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *ob = objects[ob_index];
|
||||
short mat_nr_active = -1;
|
||||
|
||||
if (ob->totcol == 0) {
|
||||
continue;
|
||||
}
|
||||
if (obact && (mat_active == give_current_material(ob, obact->actcol))) {
|
||||
/* Avoid searching since there may be multiple slots with the same material.
|
||||
* For the active object or duplicates: match the material slot index first. */
|
||||
mat_nr_active = obact->actcol - 1;
|
||||
}
|
||||
else {
|
||||
/* Find the first matching material.
|
||||
* Note: there may be multiple but thats not a common use case. */
|
||||
for (short i = 0; i < ob->totcol; i++) {
|
||||
const Material *mat = give_current_material(ob, i + 1);
|
||||
if (mat_active == mat) {
|
||||
mat_nr_active = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mat_nr_active == -1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool changed = false;
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
||||
|
||||
if (em) {
|
||||
changed = EDBM_deselect_by_material(em, ob->actcol - 1, select);
|
||||
changed = EDBM_deselect_by_material(em, mat_nr_active, select);
|
||||
}
|
||||
}
|
||||
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
||||
|
@ -311,7 +339,7 @@ static int material_slot_de_select(bContext *C, bool select)
|
|||
|
||||
if (nurbs) {
|
||||
for (nu = nurbs->first; nu; nu = nu->next) {
|
||||
if (nu->mat_nr == ob->actcol - 1) {
|
||||
if (nu->mat_nr == mat_nr_active) {
|
||||
if (nu->bezt) {
|
||||
a = nu->pntsu;
|
||||
bezt = nu->bezt;
|
||||
|
|
Loading…
Reference in New Issue