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-12 03:57:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-12 04:08:24 +0300
commit6b39dc7672eb463618efb5538f91961365db5797 (patch)
treec01642526a0772eb3b482f58a6aa9b52d728d943 /source/blender/editors/render
parent3017d88aec7f3f44ba9db930920ac2a51aef750d (diff)
Fix T61531: can't select same material in multi edit mode
D4441 by @zazizizou w/ edits.
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r--source/blender/editors/render/render_shading.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 51edf6c835f..329aec52100 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -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;