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:
authorAntonio Vazquez <blendergit@gmail.com>2019-11-29 13:22:36 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-11-29 13:25:16 +0300
commitbe1f4d875fb8001a10886a8577032e0f197827d3 (patch)
tree8fa739997e591216661e2838fe25319a6fb5e12d /source/blender/editors/gpencil
parentb25bb2d7ec31ef08d67142ad655d59cd37e1d747 (diff)
Fix T72013: Gpencil Interpolate strokes causes instant crash when material list is empty
The problem was the draw function tried to use the material and gpsettings and both were NULL. Now, the default material is used.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c11
1 files changed, 9 insertions, 2 deletions
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);
}