Fix #127293: GPv3: Show regular keyframes Dope Sheet for GP object data

In the Dope Sheet, show regular keyframes for GreasePencil object data.
The GPv3 transition missed a few cases in the animation
channel/filtering code to add the channels from regular Actions on
GreasePencil data blocks.

Pull Request: https://projects.blender.org/blender/blender/pulls/129807
This commit is contained in:
Sybren A. Stüvel
2024-11-04 17:03:19 +01:00
committed by Falk David
parent bdfb3ea6e7
commit 822907a68d
5 changed files with 33 additions and 12 deletions

View File

@@ -3576,7 +3576,7 @@ static void acf_gpd_color(bAnimContext * /*ac*/, bAnimListElem * /*ale*/, float
/* TODO: just get this from RNA? */
static int acf_gpd_icon(bAnimListElem * /*ale*/)
{
return ICON_OUTLINER_OB_GREASEPENCIL;
return ICON_OUTLINER_DATA_GREASEPENCIL;
}
/* check if some setting exists for this channel */

View File

@@ -2206,29 +2206,38 @@ static size_t animdata_filter_grease_pencil_data(bAnimContext *ac,
size_t items = 0;
/* The Grease Pencil mode is not supposed to show channels for regular F-Curves from regular
* Actions. At some point this might be desirable, but it would also require changing the
* filtering flags for pretty much all operators running there. */
const bool show_animdata = grease_pencil->adt && (ac->datatype != ANIMCONT_GPENCIL);
/* When asked from "AnimData" blocks (i.e. the top-level containers for normal animation),
* for convenience, this will return grease pencil data-blocks instead.
* This may cause issues down the track, but for now, this will do.
*/
if (filter_mode & ANIMFILTER_ANIMDATA) {
/* Just add data block container. */
if (grease_pencil->adt != nullptr) {
ANIMCHANNEL_NEW_CHANNEL(
ac->bmain, grease_pencil, ANIMTYPE_GREASE_PENCIL_DATABLOCK, grease_pencil, nullptr);
if (show_animdata) {
items += animfilter_block_data(ac, anim_data, (ID *)grease_pencil, filter_mode);
}
ANIMCHANNEL_NEW_CHANNEL(
ac->bmain, grease_pencil, ANIMTYPE_GREASE_PENCIL_DATABLOCK, grease_pencil, nullptr);
}
else {
ListBase tmp_data = {nullptr, nullptr};
size_t tmp_items = 0;
if (!(filter_mode & ANIMFILTER_FCURVESONLY)) {
/* Add grease pencil layer channels. */
BEGIN_ANIMFILTER_SUBCHANNELS (grease_pencil->flag &GREASE_PENCIL_ANIM_CHANNEL_EXPANDED) {
/* Add grease pencil layer channels. */
BEGIN_ANIMFILTER_SUBCHANNELS (grease_pencil->flag &GREASE_PENCIL_ANIM_CHANNEL_EXPANDED) {
if (show_animdata) {
tmp_items += animfilter_block_data(ac, &tmp_data, (ID *)grease_pencil, filter_mode);
}
if (!(filter_mode & ANIMFILTER_FCURVESONLY)) {
tmp_items += animdata_filter_grease_pencil_layers_data(
ac, &tmp_data, grease_pencil, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
}
END_ANIMFILTER_SUBCHANNELS;
if (tmp_items == 0) {
/* If no sub-channels, return early. */

View File

@@ -30,6 +30,7 @@
#include "UI_resources.hh"
#include "UI_view2d.hh"
#include "ED_anim_api.hh"
#include "ED_keyframes_draw.hh"
#include "ED_keyframes_keylist.hh"
@@ -479,6 +480,9 @@ static void build_channel_keylist(ChannelListElement *elem, blender::float2 rang
break;
}
case ChannelType::GREASE_PENCIL_DATA: {
if (elem->ac->datatype != ANIMCONT_GPENCIL && elem->adt) {
action_to_keylist(elem->adt, elem->adt->action, elem->keylist, elem->saction_flag, range);
}
grease_pencil_data_block_to_keylist(
elem->adt, elem->grease_pencil, elem->keylist, elem->saction_flag, false);
break;
@@ -789,7 +793,8 @@ void ED_add_action_channel(ChannelDrawList *channel_list,
}
void ED_add_grease_pencil_datablock_channel(ChannelDrawList *channel_list,
bDopeSheet * /*ads*/,
bAnimContext *ac,
AnimData *adt,
const GreasePencil *grease_pencil,
const float ypos,
const float yscale_fac,
@@ -800,7 +805,12 @@ void ED_add_grease_pencil_datablock_channel(ChannelDrawList *channel_list,
ypos,
yscale_fac,
eSAction_Flag(saction_flag));
/* GreasePencil properties can be animated via an Action, so the GP-related
* animation data is not limited to GP drawings. */
draw_elem->adt = adt;
draw_elem->act = adt ? adt->action : nullptr;
draw_elem->grease_pencil = grease_pencil;
draw_elem->ac = ac;
}
void ED_add_grease_pencil_cels_channel(ChannelDrawList *channel_list,

View File

@@ -130,7 +130,8 @@ void ED_add_grease_pencil_layer_group_channel(ChannelDrawList *draw_list,
/* Grease Pencil data channels */
void ED_add_grease_pencil_datablock_channel(ChannelDrawList *draw_list,
bDopeSheet *ads,
bAnimContext *ac,
AnimData *adt,
const GreasePencil *grease_pencil,
const float ypos,
const float yscale_fac,

View File

@@ -432,7 +432,8 @@ static void draw_keyframes(bAnimContext *ac,
break;
case ALE_GREASE_PENCIL_DATA:
ED_add_grease_pencil_datablock_channel(draw_list,
ads,
ac,
ale->adt,
static_cast<const GreasePencil *>(ale->data),
ycenter,
scale_factor,