Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.c15
1 files changed, 14 insertions, 1 deletions
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;