Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/gpencil_geom.c
| Show First 20 Lines • Show All 1,902 Lines • ▼ Show 20 Lines | void BKE_gpencil_convert_mesh(Main *bmain, | ||||
| const float default_colors[2][4] = {{0.0f, 0.0f, 0.0f, 1.0f}, {0.7f, 0.7f, 0.7f, 1.0f}}; | const float default_colors[2][4] = {{0.0f, 0.0f, 0.0f, 1.0f}, {0.7f, 0.7f, 0.7f, 1.0f}}; | ||||
| /* Create stroke material. */ | /* Create stroke material. */ | ||||
| if (create_mat) { | if (create_mat) { | ||||
| gpencil_add_material(bmain, ob_gp, "Stroke", default_colors[0], true, false, &r_idx); | gpencil_add_material(bmain, ob_gp, "Stroke", default_colors[0], true, false, &r_idx); | ||||
| } | } | ||||
| /* Export faces as filled strokes. */ | /* Export faces as filled strokes. */ | ||||
| if (use_faces) { | if (use_faces) { | ||||
| if (create_mat) { | 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 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); | gpencil_add_material(bmain, ob_gp, "Fill", default_colors[1], false, true, &r_idx); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Create all materials for fill. */ | /* Create all materials for fill. */ | ||||
| for (i = 0; i < ob_mesh->totcol; i++) { | for (i = 0; i < ob_mesh->totcol; i++) { | ||||
| Material *ma = BKE_object_material_get(ob_mesh, i + 1); | Material *ma = BKE_object_material_get(ob_mesh, i + 1); | ||||
| if (ma == NULL) { | |||||
| continue; | |||||
| } | |||||
| float color[4]; | float color[4]; | ||||
| copy_v3_v3(color, &ma->r); | copy_v3_v3(color, &ma->r); | ||||
| color[3] = 1.0f; | color[3] = 1.0f; | ||||
| gpencil_add_material(bmain, ob_gp, ma->id.name + 2, color, false, true, &r_idx); | gpencil_add_material(bmain, ob_gp, ma->id.name + 2, color, false, true, &r_idx); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines | |||||