Fix #133034: Grease Pencil: Reset ob->actcol when converting from mesh

When converting object to grease pencil from mesh, the material counters
need to be set to the the value that matches
`GreasePencil::material_array_num` to avoid index issues in adding
grease pencil materials downstream.

Pull Request: https://projects.blender.org/blender/blender/pulls/133038
This commit is contained in:
YimingWu 2025-01-14 12:15:31 +01:00 committed by Falk David
parent 6cb8cdaa45
commit e18011fddc

View file

@ -3209,11 +3209,13 @@ static Object *convert_mesh_to_grease_pencil(Base &base,
newob->data = grease_pencil;
newob->type = OB_GREASE_PENCIL;
/* Reset `ob->totcol` since currently the generic / grease pencil material functions still
* depend on this value being coherent (The same value as `GreasePencil::material_array_num`).
/* Reset `ob->totcol` and `ob->actcol` since currently the generic / grease pencil material
* functions still depend on this value being coherent (The same value as
* `GreasePencil::material_array_num`).
*/
short *totcol = BKE_object_material_len_p(newob);
newob->totcol = *totcol;
newob->actcol = *totcol;
mesh_to_grease_pencil_add_material(
*info.bmain, *newob, DATA_("Stroke"), float4(0.0f, 0.0f, 0.0f, 1.0f), {});