Anim: add debug operator for printing anim channel info

Add an operator (`anim.debug_channel_list`) that lists animation channel
info in the terminal.

It's only available in debug builds of Blender, because it's a
developer-only tool. It is not available in a menu, just in the F3
search.

Pull Request: https://projects.blender.org/blender/blender/pulls/129804
This commit is contained in:
Sybren A. Stüvel
2024-11-04 17:10:31 +01:00
parent a4e0b799c8
commit b4f59c5348

View File

@@ -678,6 +678,56 @@ static void ANIM_OT_previewrange_clear(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Debug operator: channel list
* \{ */
#ifndef NDEBUG
static int debug_channel_list_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
ListBase anim_data = {nullptr, nullptr};
/* Same filter flags as in action_channel_region_draw() in
* `source/blender/editors/space_action/space_action.cc`. */
const eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
printf("==============================================\n");
printf("Animation Channel List:\n");
printf("----------------------------------------------\n");
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
ANIM_channel_debug_print_info(ale, 1);
}
printf("==============================================\n");
ANIM_animdata_freelist(&anim_data);
return OPERATOR_FINISHED;
}
static void ANIM_OT_debug_channel_list(wmOperatorType *ot)
{
ot->name = "Debug Channel List";
ot->idname = "ANIM_OT_debug_channel_list";
ot->description =
"Log the channel list info in the terminal. This operator is only available in debug builds "
"of Blender";
ot->exec = debug_channel_list_exec;
ot->poll = ED_operator_animview_active;
ot->flag = OPTYPE_REGISTER;
}
#endif /* !NDEBUG */
/** \} */
/* -------------------------------------------------------------------- */
/** \name Frame Scene/Preview Range Operator
* \{ */
@@ -894,6 +944,10 @@ void ED_operatortypes_anim()
WM_operatortype_append(ANIM_OT_scene_range_frame);
#ifndef NDEBUG
WM_operatortype_append(ANIM_OT_debug_channel_list);
#endif
/* Entire UI --------------------------------------- */
WM_operatortype_append(ANIM_OT_keyframe_insert);
WM_operatortype_append(ANIM_OT_keyframe_delete);