diff options
-rw-r--r-- | source/blender/blenkernel/BKE_material.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 5 | ||||
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 11 |
3 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 7ff9c4e6376..d7b037a8189 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -95,6 +95,7 @@ bool BKE_object_material_slot_remove(struct Main *bmain, struct Object *ob); bool BKE_object_material_slot_used(struct ID *id, short actcol); struct Material *BKE_material_gpencil_get(struct Object *ob, short act); +struct Material *BKE_material_gpencil_default_get(void); struct MaterialGPencilStyle *BKE_material_gpencil_settings_get(struct Object *ob, short act); void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 73c278a0ab6..54432c8da74 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -598,6 +598,11 @@ Material *BKE_material_gpencil_get(Object *ob, short act) } } +struct Material *BKE_material_gpencil_default_get(void) +{ + return &defgpencil_material; +} + MaterialGPencilStyle *BKE_material_gpencil_settings_get(Object *ob, short act) { Material *ma = give_current_material(ob, act); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 80795b825b0..06e5f36637b 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -51,6 +51,7 @@ #include "BKE_context.h" #include "BKE_brush.h" #include "BKE_global.h" +#include "BKE_material.h" #include "BKE_paint.h" #include "BKE_gpencil.h" #include "BKE_image.h" @@ -427,7 +428,9 @@ static void gp_draw_stroke_fill(bGPdata *gpd, const float color[4]) { BLI_assert(gps->totpoints >= 3); - Material *ma = gpd->mat[gps->mat_nr]; + const bool use_mat = (gpd->mat != NULL); + + Material *ma = (use_mat) ? gpd->mat[gps->mat_nr] : BKE_material_gpencil_default_get(); MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; /* Calculate triangles cache for filling area (must be done only after changes) */ @@ -869,6 +872,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw) short sthickness; float ink[4]; const bool is_unique = (tgpw->gps != NULL); + const bool use_mat = (tgpw->gpd->mat != NULL); GPU_program_point_size(true); @@ -880,7 +884,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw) continue; } /* check if the color is visible */ - Material *ma = tgpw->gpd->mat[gps->mat_nr]; + Material *ma = (use_mat) ? tgpw->gpd->mat[gps->mat_nr] : BKE_material_gpencil_default_get(); MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; if ((gp_style == NULL) || (gp_style->flag & GP_STYLE_COLOR_HIDE) || @@ -1159,6 +1163,9 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in copy_v4_v4(tgpw.tintcolor, color); tgpw.onion = true; tgpw.custonion = true; + if (obact->totcol == 0) { + tgpw.gpd->mat = NULL; + } gp_draw_strokes(&tgpw); } |