Fix T91691: Selecting "Remove unused slots" in Materials panel removes slots that are assigned to particle systems/hair.

`BKE_object_material_slot_used` would only check obdata usages, but
particle settings can also (weirdly enough) use objects' material slots.

So now, as its name suggests, `BKE_object_material_slot_used` does take
an object as parameter, and also checks for potential slot usage from
psys in the object.
This commit is contained in:
2021-09-27 18:07:01 +02:00
parent 824733ea47
commit 6578db57cd
7 changed files with 27 additions and 14 deletions

View File

@@ -690,7 +690,7 @@ static int material_slot_remove_unused_exec(bContext *C, wmOperator *op)
Object *ob = objects[ob_index];
int actcol = ob->actcol;
for (int slot = 1; slot <= ob->totcol; slot++) {
while (slot <= ob->totcol && !BKE_object_material_slot_used(ob->data, slot)) {
while (slot <= ob->totcol && !BKE_object_material_slot_used(ob, slot)) {
ob->actcol = slot;
BKE_object_material_slot_remove(bmain, ob);