Fix #130611: Grease Pencil: Airbrush affects material of other brushes
Don't change the object's active material when adding a material slot. This active material will be used by brushes with no pinned material, while the added slot is meant for the pinned material. The if-statement in `BKE_grease_pencil_object_material_ensure_from_brush()` would change the active unpinned material, even though it was only meant to handle the pinned material. This was not a new issue, it was just unlikely to run into it. Before brush assets were introduced this if-statement would not be executed when activating any of the default brushes. Afterwards it would be, because the material was newly linked (because the brush asset was linked) and so there was no material slot created for it yet. Pull Request: https://projects.blender.org/blender/blender/pulls/132865
This commit is contained in:
committed by
Julian Eisel
parent
179c305a40
commit
4b2a4341a7
@@ -95,7 +95,11 @@ void BKE_object_material_array_assign(
|
||||
Main *bmain, Object *ob, Material ***matar, int totcol, bool to_object_only);
|
||||
|
||||
short BKE_object_material_slot_find_index(Object *ob, Material *ma);
|
||||
bool BKE_object_material_slot_add(Main *bmain, Object *ob);
|
||||
/**
|
||||
* \param set_active: Set the newly added slot as active material slot of the object. Usually that
|
||||
* is wanted when adding a material slot, so it's the default.
|
||||
*/
|
||||
bool BKE_object_material_slot_add(Main *bmain, Object *ob, bool set_active = true);
|
||||
bool BKE_object_material_slot_remove(Main *bmain, Object *ob);
|
||||
bool BKE_object_material_slot_used(Object *object, short actcol);
|
||||
|
||||
|
||||
@@ -2441,7 +2441,11 @@ Material *BKE_grease_pencil_object_material_ensure_from_brush(Main *bmain,
|
||||
|
||||
/* check if the material is already on object material slots and add it if missing */
|
||||
if (ma && BKE_object_material_index_get(ob, ma) < 0) {
|
||||
BKE_object_material_slot_add(bmain, ob);
|
||||
/* The object's active material is what's used for the unpinned material. Do not touch it
|
||||
* while using a pinned material. */
|
||||
const bool change_active_material = false;
|
||||
|
||||
BKE_object_material_slot_add(bmain, ob, change_active_material);
|
||||
BKE_object_material_assign(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
|
||||
}
|
||||
|
||||
|
||||
@@ -1322,7 +1322,7 @@ short BKE_object_material_slot_find_index(Object *ob, Material *ma)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BKE_object_material_slot_add(Main *bmain, Object *ob)
|
||||
bool BKE_object_material_slot_add(Main *bmain, Object *ob, const bool set_active)
|
||||
{
|
||||
if (ob == nullptr) {
|
||||
return false;
|
||||
@@ -1332,7 +1332,9 @@ bool BKE_object_material_slot_add(Main *bmain, Object *ob)
|
||||
}
|
||||
|
||||
BKE_object_material_assign(bmain, ob, nullptr, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
|
||||
ob->actcol = ob->totcol;
|
||||
if (set_active) {
|
||||
ob->actcol = ob->totcol;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user