Fix T59248: Crash in Grease Pencil Edit mode when adding Annotation

This commit is contained in:
Antonio Vazquez 2018-12-12 19:48:24 +01:00
parent 80ad2f8cf6
commit 9c5d104224
Notes: blender-bot 2023-05-29 09:17:12 +02:00
Referenced by issue #59248, Blender 2.8 crashes in Grease Pencil Edit mode when adding Annotation
2 changed files with 23 additions and 17 deletions

View File

@ -1387,28 +1387,32 @@ static void DRW_gpencil_shgroups_create(
}
case eGpencilBatchGroupType_Edit:
{
const int len = elm->vertex_idx - start_edit;
/* use always the same group */
DRW_shgroup_call_range_add(
stl->g_data->shgrps_edit_point,
cache->b_edit.batch,
(!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat,
start_edit, len);
if (stl->g_data->shgrps_edit_point) {
const int len = elm->vertex_idx - start_edit;
/* use always the same group */
DRW_shgroup_call_range_add(
stl->g_data->shgrps_edit_point,
cache->b_edit.batch,
(!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat,
start_edit, len);
start_edit = elm->vertex_idx;
start_edit = elm->vertex_idx;
}
break;
}
case eGpencilBatchGroupType_Edlin:
{
const int len = elm->vertex_idx - start_edlin;
/* use always the same group */
DRW_shgroup_call_range_add(
stl->g_data->shgrps_edit_line,
cache->b_edlin.batch,
(!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat,
start_edlin, len);
if (stl->g_data->shgrps_edit_line) {
const int len = elm->vertex_idx - start_edlin;
/* use always the same group */
DRW_shgroup_call_range_add(
stl->g_data->shgrps_edit_line,
cache->b_edlin.batch,
(!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat,
start_edlin, len);
start_edlin = elm->vertex_idx;
start_edlin = elm->vertex_idx;
}
break;
}
default:

View File

@ -719,6 +719,8 @@ void GPENCIL_draw_scene(void *ved)
Object *obact = draw_ctx->obact;
const bool playing = stl->storage->is_playing;
const bool is_render = stl->storage->is_render;
bGPdata *gpd_act = (obact) && (obact->type == OB_GPENCIL) ? (bGPdata *)obact->data : NULL;
const bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd_act);
/* paper pass to display a comfortable area to draw over complex scenes with geometry */
if ((!is_render) && (obact) && (obact->type == OB_GPENCIL)) {
@ -875,7 +877,7 @@ void GPENCIL_draw_scene(void *ved)
}
}
/* edit points */
if ((!is_render) && (!playing)) {
if ((!is_render) && (!playing) && (is_edit)) {
DRW_draw_pass(psl->edit_pass);
}
}