Fix T77156: GPencil view layer filter by layer not working
This was removed by error during the refactor done in 2.83. Differential Revision: https://developer.blender.org/D7909 Reviewers: @fclem
This commit is contained in:
parent
df17ee202b
commit
4184371fb0
Notes:
blender-bot
2023-11-20 12:14:32 +01:00
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83 Referenced by issue #77156, GPencil: Problem with assigning layers to view layers
|
@ -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,
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue