diff options
Diffstat (limited to 'source')
7 files changed, 33 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index faa331aa02d..85ba8175143 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -41,6 +41,7 @@ struct Object; struct Scene; struct SpaceImage; struct ToolSettings; +struct ViewLayer; struct bDeformGroup; struct bGPDframe; struct bGPDlayer; @@ -253,7 +254,8 @@ typedef void (*gpIterCb)(struct bGPDlayer *layer, struct bGPDstroke *stroke, void *thunk); -void BKE_gpencil_visible_stroke_iter(struct Object *ob, +void BKE_gpencil_visible_stroke_iter(struct ViewLayer *view_layer, + struct Object *ob, gpIterCb layer_cb, gpIterCb stroke_cb, void *thunk, diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 4311e425abf..103a1f7dbd5 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1855,8 +1855,13 @@ bool BKE_gpencil_from_image(SpaceImage *sima, bGPDframe *gpf, const float size, * * \{ */ -void BKE_gpencil_visible_stroke_iter( - Object *ob, gpIterCb layer_cb, gpIterCb stroke_cb, void *thunk, bool do_onion, int cfra) +void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer, + Object *ob, + gpIterCb layer_cb, + gpIterCb stroke_cb, + void *thunk, + bool do_onion, + int cfra) { bGPdata *gpd = (bGPdata *)ob->data; const bool is_multiedit = GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); @@ -1878,6 +1883,14 @@ void BKE_gpencil_visible_stroke_iter( continue; } + /* Hide the layer if it's defined a view layer filter. This is used to + * generate renders, putting only selected GP layers for each View Layer. + * This is used only in final render and never in Viewport. */ + if ((view_layer != NULL) && (gpl->viewlayername[0] != '\0') && + (!STREQ(view_layer->name, gpl->viewlayername))) { + continue; + } + if (is_multiedit) { sta_gpf = end_gpf = NULL; /* Check the whole range and tag the editable frames. */ diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 2214db662df..495de7ef10b 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -91,6 +91,7 @@ void GPENCIL_engine_init(void *ved) stl->pd->gp_object_pool = vldata->gp_object_pool; stl->pd->gp_layer_pool = vldata->gp_layer_pool; stl->pd->gp_vfx_pool = vldata->gp_vfx_pool; + stl->pd->view_layer = ctx->view_layer; stl->pd->scene = ctx->scene; stl->pd->v3d = ctx->v3d; stl->pd->last_light_pool = NULL; @@ -598,6 +599,7 @@ void GPENCIL_cache_populate(void *ved, Object *ob) GPENCIL_Data *vedata = (GPENCIL_Data *)ved; GPENCIL_PrivateData *pd = vedata->stl->pd; GPENCIL_TextureList *txl = vedata->txl; + const bool is_final_render = DRW_state_is_image_render(); /* object must be visible */ if (!(DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) { @@ -617,7 +619,8 @@ void GPENCIL_cache_populate(void *ved, Object *ob) bGPdata *gpd = (bGPdata *)ob->data; bool do_onion = (!pd->is_render) ? pd->do_onion : (gpd->onion_flag & GP_ONION_GHOST_ALWAYS); - BKE_gpencil_visible_stroke_iter(ob, + BKE_gpencil_visible_stroke_iter(is_final_render ? pd->view_layer : NULL, + ob, gpencil_layer_cache_populate, gpencil_stroke_cache_populate, &iter, diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index f765dcf73de..cedd75af813 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -307,6 +307,8 @@ typedef struct GPENCIL_PrivateData { float dof_params[2]; /* Used for DoF Setup. */ Object *camera; + /* Copy of draw_ctx->view_layer for convenience. */ + struct ViewLayer *view_layer; /* Copy of draw_ctx->scene for convenience. */ struct Scene *scene; /* Copy of draw_ctx->vie3d for convenience. */ diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c b/source/blender/draw/engines/overlay/overlay_gpencil.c index 1397ef7b4b2..ccc914e0422 100644 --- a/source/blender/draw/engines/overlay/overlay_gpencil.c +++ b/source/blender/draw/engines/overlay/overlay_gpencil.c @@ -361,7 +361,7 @@ static void OVERLAY_gpencil_color_names(Object *ob) int cfra = DEG_get_ctime(draw_ctx->depsgraph); BKE_gpencil_visible_stroke_iter( - ob, NULL, overlay_gpencil_draw_stroke_color_name, ob, false, cfra); + NULL, ob, NULL, overlay_gpencil_draw_stroke_color_name, ob, false, cfra); } void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob) diff --git a/source/blender/draw/engines/overlay/overlay_outline.c b/source/blender/draw/engines/overlay/overlay_outline.c index 142421f58d8..99d22fc380f 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.c +++ b/source/blender/draw/engines/overlay/overlay_outline.c @@ -259,7 +259,7 @@ static void OVERLAY_outline_gpencil(OVERLAY_PrivateData *pd, Object *ob) } BKE_gpencil_visible_stroke_iter( - ob, gp_layer_cache_populate, gp_stroke_cache_populate, &iter, false, pd->cfra); + NULL, ob, gp_layer_cache_populate, gp_stroke_cache_populate, &iter, false, pd->cfra); } void OVERLAY_outline_cache_populate(OVERLAY_Data *vedata, diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c index ee148e0934d..b4974330043 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil.c +++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c @@ -102,6 +102,7 @@ static GpencilBatchCache *gpencil_batch_cache_init(Object *ob, int cfra) cache->is_dirty = true; cache->cache_frame = cfra; + return cache; } @@ -385,7 +386,8 @@ static void gpencil_batches_ensure(Object *ob, GpencilBatchCache *cache, int cfr .vert_len = 1, /* Start at 1 for the gl_InstanceID trick to work (see vert shader). */ .tri_len = 0, }; - BKE_gpencil_visible_stroke_iter(ob, NULL, gp_object_verts_count_cb, &iter, do_onion, cfra); + BKE_gpencil_visible_stroke_iter( + NULL, ob, NULL, gp_object_verts_count_cb, &iter, do_onion, cfra); /* Create VBOs. */ GPUVertFormat *format = gpencil_stroke_format(); @@ -401,7 +403,7 @@ static void gpencil_batches_ensure(Object *ob, GpencilBatchCache *cache, int cfr GPU_indexbuf_init(&iter.ibo, GPU_PRIM_TRIS, iter.tri_len, iter.vert_len); /* Fill buffers with data. */ - BKE_gpencil_visible_stroke_iter(ob, NULL, gpencil_stroke_iter_cb, &iter, do_onion, cfra); + BKE_gpencil_visible_stroke_iter(NULL, ob, NULL, gpencil_stroke_iter_cb, &iter, do_onion, cfra); /* Mark last 2 verts as invalid. */ for (int i = 0; i < 2; i++) { @@ -475,7 +477,7 @@ GPUBatch *DRW_cache_gpencil_face_wireframe_get(Object *ob) /* IMPORTANT: Keep in sync with gpencil_edit_batches_ensure() */ bool do_onion = true; - BKE_gpencil_visible_stroke_iter(ob, NULL, gp_lines_indices_cb, &iter, do_onion, cfra); + BKE_gpencil_visible_stroke_iter(NULL, ob, NULL, gp_lines_indices_cb, &iter, do_onion, cfra); GPUIndexBuf *ibo = GPU_indexbuf_build(&iter.ibo); @@ -724,7 +726,8 @@ static void gpencil_edit_batches_ensure(Object *ob, GpencilBatchCache *cache, in iter.verts = (gpEditVert *)cache->edit_vbo->data; /* Fill buffers with data. */ - BKE_gpencil_visible_stroke_iter(ob, NULL, gpencil_edit_stroke_iter_cb, &iter, do_onion, cfra); + BKE_gpencil_visible_stroke_iter( + NULL, ob, NULL, gpencil_edit_stroke_iter_cb, &iter, do_onion, cfra); /* Create the batches */ cache->edit_points_batch = GPU_batch_create(GPU_PRIM_POINTS, cache->vbo, NULL); |