From f1cf706758e333040d4d2d5dd368b4db511a25b5 Mon Sep 17 00:00:00 2001 From: Erik Abrahamsson Date: Sun, 25 Apr 2021 18:30:27 +0200 Subject: Fix unreported "Convert Mesh to Gpencil" when fill material already exists If an object named for example `Suzanne` is converted to Gpencil, a material called `Suzanne_Fill` will be created for the gpencil fill. When this material already exists, the new material will be called `Suzanne_Fill.001` and the operator will not see that this material is already present the next iteration. This leads to a new material being created for every polygon. This commit changes the code to search for a material starting with `ObjectName_Fill` instead of being equal to. Reviewed By: filedescriptor, antoniov Differential Revision: https://developer.blender.org/D11067 --- source/blender/blenkernel/intern/gpencil_geom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 27c2d9e146b..8ae5a9e2d1f 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -2433,7 +2433,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain, Material *ma = BKE_object_material_get(ob_mesh, mp->mat_nr + 1); make_element_name( ob_mesh->id.name + 2, (ma != NULL) ? ma->id.name + 2 : "Fill", 64, element_name); - mat_idx = gpencil_material_find_index_by_name(ob_gp, element_name); + mat_idx = BKE_gpencil_material_find_index_by_name_prefix(ob_gp, element_name); if (mat_idx == -1) { float color[4]; if (ma != NULL) { -- cgit v1.2.3