diff options
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c index c023c63ebc9..7ebb869e955 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c @@ -88,7 +88,12 @@ static void clear_strokes(Object *ob, GpencilModifierData *md, int frame) BKE_gpencil_layer_frame_delete(gpl, gpf); } -static bool bake_strokes(Object *ob, Depsgraph *dg, GpencilModifierData *md, int frame) +static bool bake_strokes(Object *ob, + Depsgraph *dg, + LineartCache **lc, + GpencilModifierData *md, + int frame, + bool is_first) { /* Modifier data sanity check. */ if (lineart_mod_is_disabled(md)) { @@ -111,11 +116,22 @@ static bool bake_strokes(Object *ob, Depsgraph *dg, GpencilModifierData *md, int /* No greasepencil frame created or found. */ return false; } - - MOD_lineart_compute_feature_lines(dg, lmd); + LineartCache *local_lc = *lc; + if (!(*lc)) { + MOD_lineart_compute_feature_lines(dg, lmd, lc); + MOD_lineart_destroy_render_data(lmd); + } + else { + if (is_first || (!(lmd->flags & LRT_GPENCIL_USE_CACHE))) { + MOD_lineart_compute_feature_lines(dg, lmd, &local_lc); + MOD_lineart_destroy_render_data(lmd); + } + MOD_lineart_chain_clear_picked_flag(local_lc); + lmd->cache = local_lc; + } MOD_lineart_gpencil_generate( - lmd->render_buffer, + lmd->cache, dg, ob, gpl, @@ -135,7 +151,15 @@ static bool bake_strokes(Object *ob, Depsgraph *dg, GpencilModifierData *md, int lmd->vgname, lmd->flags); - MOD_lineart_destroy_render_data(lmd); + if (!(lmd->flags & LRT_GPENCIL_USE_CACHE)) { + /* Clear local cache. */ + if (!is_first) { + MOD_lineart_clear_cache(&local_lc); + } + /* Restore the original cache pointer so the modifiers below still have access to the + * "global" cache. */ + lmd->cache = gpd->runtime.lineart_cache; + } return true; } @@ -174,14 +198,21 @@ static bool lineart_gpencil_bake_single_target(LineartBakeJob *bj, Object *ob, i } } + GpencilLineartLimitInfo info = BKE_gpencil_get_lineart_modifier_limits(ob); + + LineartCache *lc = NULL; + bool is_first = true; LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) { if (md->type != eGpencilModifierType_Lineart) { continue; } - if (bake_strokes(ob, bj->dg, md, frame)) { + BKE_gpencil_set_lineart_modifier_limits(md, &info, is_first); + if (bake_strokes(ob, bj->dg, &lc, md, frame, is_first)) { touched = true; + is_first = false; } } + MOD_lineart_clear_cache(&lc); return touched; } |