diff options
Diffstat (limited to 'source/blender/draw')
3 files changed, 20 insertions, 4 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index 5478c4a60b9..63af8ecc141 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -186,7 +186,7 @@ static bool gpencil_batch_cache_valid(GpencilBatchCache *cache, bGPdata *gpd, in else if (gpd->flag & GP_DATA_CACHE_IS_DIRTY) { valid = false; } - else if (gpd->flag & GP_DATA_SHOW_ONIONSKINS) { + else if (DRW_gpencil_onion_active(gpd)) { /* if onion, set as dirty always * This reduces performance, but avoid any crash in the multiple * overlay and multiwindow options and keep all windows working diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index eaae8033b8b..a0e9d124e6b 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -366,6 +366,20 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create( return grp; } +/* check if some onion is enabled */ +bool DRW_gpencil_onion_active(bGPdata *gpd) +{ + if ((gpd->flag & GP_DATA_SHOW_ONIONSKINS) == 0) { + return false; + } + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + if (gpl->onion_flag & GP_LAYER_ONIONSKIN) { + return true; + } + } + return false; +} + /* create shading group for strokes */ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create( GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass, GPUShader *shader, Object *ob, @@ -1499,7 +1513,8 @@ void DRW_gpencil_populate_datablock( bGPDframe *derived_gpf = NULL; const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true; - const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion; + const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && + main_onion && DRW_gpencil_onion_active(gpd); const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) : true; const bool time_remap = BKE_gpencil_has_time_modifiers(ob); @@ -1585,8 +1600,7 @@ void DRW_gpencil_populate_datablock( /* draw onion skins */ if (!ID_IS_LINKED(&gpd->id)) { - if ((gpd->flag & GP_DATA_SHOW_ONIONSKINS) && - (do_onion) && (gpl->onion_flag & GP_LAYER_ONIONSKIN) && + if ((do_onion) && (gpl->onion_flag & GP_LAYER_ONIONSKIN) && ((!playing) || (gpd->onion_flag & GP_ONION_GHOST_ALWAYS)) && (!cache_ob->is_dup_ob) && (gpd->id.us <= 1)) { diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index b8b526cb873..4aaf81ea5fd 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -385,6 +385,8 @@ struct tGPencilObjectCache *gpencil_object_cache_add( struct tGPencilObjectCache *cache_array, struct Object *ob, int *gp_cache_size, int *gp_cache_used); +bool DRW_gpencil_onion_active(struct bGPdata *gpd); + /* shading groups cache functions */ struct GpencilBatchGroup *gpencil_group_cache_add( struct GpencilBatchGroup *cache_array, |