T90372: Assets: When dropping material use active material slot.

Currently when dropping an asset the first material slot is always updated.
This patch changes that logic to update the active material slot.

In future the behavior will be updated to use the material slot of the face under the cursor.
That requires better feedback tot he user.

Reviewed By: Severin

Maniphest Tasks: T90372

Differential Revision: https://developer.blender.org/D12056
This commit is contained in:
Jeroen Bakker 2021-08-03 08:06:26 +02:00 committed by Jeroen Bakker
parent a53feb0aff
commit ebd55b4acd
Notes: blender-bot 2023-02-14 08:10:06 +01:00
Referenced by issue #90372, As a user I want to update the active material slot when dropping a material on an object
1 changed files with 5 additions and 1 deletions

View File

@ -2736,7 +2736,11 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_CANCELLED;
}
BKE_object_material_assign(CTX_data_main(C), base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF);
Object *ob = base->object;
const short active_mat_slot = ob->actcol;
BKE_object_material_assign(
CTX_data_main(C), base->object, ma, active_mat_slot, BKE_MAT_ASSIGN_USERPREF);
DEG_id_tag_update(&base->object->id, ID_RECALC_TRANSFORM);