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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user