GPencil: Improve viewlayer masking check

Check if the mask layer is used in a layer that is going to be used in the current viewlayer.

Related to T77667
This commit is contained in:
Antonio Vazquez 2020-06-09 11:13:07 +02:00 committed by Jeroen Bakker
parent 0178e7b393
commit 8e555bf4e3
Notes: blender-bot 2023-02-14 08:28:46 +01:00
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 6 additions and 2 deletions

View File

@ -1833,9 +1833,13 @@ bool BKE_gpencil_from_image(SpaceImage *sima, bGPDframe *gpf, const float size,
* \param gpl_mask Actual Layer
* \return True if the layer is a mask
*/
static bool gpencil_is_layer_mask(bGPdata *gpd, bGPDlayer *gpl_mask)
static bool gpencil_is_layer_mask(ViewLayer *view_layer, bGPdata *gpd, bGPDlayer *gpl_mask)
{
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
if ((gpl->viewlayername[0] != '\0') && (!STREQ(view_layer->name, gpl->viewlayername))) {
continue;
}
LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl->mask_layers) {
if (STREQ(gpl_mask->info, mask->name)) {
return true;
@ -1889,7 +1893,7 @@ void BKE_gpencil_visible_stroke_iter(ViewLayer *view_layer,
(!STREQ(view_layer->name, gpl->viewlayername))) {
/* If the layer is used as mask, cannot be filtered or the masking system
* will crash because needs the mask layer in the draw pipeline. */
if (!gpencil_is_layer_mask(gpd, gpl)) {
if (!gpencil_is_layer_mask(view_layer, gpd, gpl)) {
continue;
}
}