Commit: 4fc5233467b1c273cdb82b221d8faa53249b99c6 Author: Philipp Oeser Date: Mon Jun 29 12:43:54 2020 +0200 Branches: master https://developer.blender.org/rB4fc5233467b1c273cdb82b221d8faa53249b99c6
Fix T78401: Convert Mesh to Grease Pencil with empty material slot crashes Also create the 'simple fill' in case there are only empty material slots. Maniphest Tasks: T78401 Differential Revision: https://developer.blender.org/D8151 =================================================================== M source/blender/blenkernel/intern/gpencil_geom.c =================================================================== diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 18c0848bad9..542f80aa9b5 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -1908,14 +1908,27 @@ void BKE_gpencil_convert_mesh(Main *bmain, /* Export faces as filled strokes. */ if (use_faces) { if (create_mat) { + /* Find a material slot with material assigned */ + bool material_found = false; + for (i = 0; i < ob_mesh->totcol; i++) { + Material *ma = BKE_object_material_get(ob_mesh, i + 1); + if (ma != NULL) { + material_found = true; + break; + } + } + /* If no materials, create a simple fill. */ - if (ob_mesh->totcol == 0) { + if (!material_found) { gpencil_add_material(bmain, ob_gp, "Fill", default_colors[1], false, true, &r_idx); } else { /* Create all materials for fill. */ for (i = 0; i < ob_mesh->totcol; i++) { Material *ma = BKE_object_material_get(ob_mesh, i + 1); + if (ma == NULL) { + continue; + } float color[4]; copy_v3_v3(color, &ma->r); color[3] = 1.0f; _______________________________________________ Bf-blender-cvs mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-blender-cvs
