From b07f0e8a65be3bac4ed85237a5535ddde7b60202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 19 Jun 2024 18:17:16 +0200 Subject: [PATCH] Anim: prevent pushing down layered Actions onto the NLA Prevent creating NLA strips from layered Actions via the 'Push Down' operator. Maybe in the future the NLA will support layered Actions (as a transitional phase, before the NLA is replaced with layered Actions itself). For now, it's better to create stable boundaries to prevent their use in the NLA. When NLA support is being worked on, those boundaries can be removed again. Pull Request: https://projects.blender.org/blender/blender/pulls/123467 --- source/blender/editors/space_action/CMakeLists.txt | 4 ++++ source/blender/editors/space_action/action_data.cc | 10 ++++++++++ source/blender/editors/space_nla/CMakeLists.txt | 5 +++++ source/blender/editors/space_nla/nla_tracks.cc | 12 ++++++++++++ 4 files changed, 31 insertions(+) diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index f2421e139df..61b48b7dd9c 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -33,6 +33,7 @@ set(SRC set(LIB bf_blenkernel + PRIVATE bf::animrig PRIVATE bf::blenlib PRIVATE bf::depsgraph PRIVATE bf::dna @@ -40,6 +41,9 @@ set(LIB PRIVATE bf::animrig ) +if(WITH_EXPERIMENTAL_FEATURES) + add_definitions(-DWITH_ANIM_BAKLAVA) +endif() blender_add_lib(bf_editor_space_action "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_action/action_data.cc b/source/blender/editors/space_action/action_data.cc index 77ea5408af8..a7bdb429095 100644 --- a/source/blender/editors/space_action/action_data.cc +++ b/source/blender/editors/space_action/action_data.cc @@ -32,6 +32,8 @@ #include "BKE_report.hh" #include "BKE_scene.hh" +#include "ANIM_action.hh" + #include "ED_anim_api.hh" #include "ED_screen.hh" @@ -311,6 +313,14 @@ static bool action_pushdown_poll(bContext *C) return false; } +#ifdef WITH_ANIM_BAKLAVA + blender::animrig::Action &action = saction->action->wrap(); + if (!action.is_action_legacy()) { + CTX_wm_operator_poll_msg_set(C, "Layered Actions cannot be used as NLA strips"); + return false; + } +#endif + /* NOTE: We check this for the AnimData block in question and not the global flag, * as the global flag may be left dirty by some of the browsing ops here. */ diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index e8f2a5a450c..5fc001c1434 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -32,12 +32,17 @@ set(SRC set(LIB bf_blenkernel + PRIVATE bf::animrig PRIVATE bf::blenlib PRIVATE bf::depsgraph PRIVATE bf::dna PRIVATE bf::intern::guardedalloc ) +if(WITH_EXPERIMENTAL_FEATURES) + add_definitions(-DWITH_ANIM_BAKLAVA) +endif() + blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") # RNA_prototypes.h dna_type_offsets.h diff --git a/source/blender/editors/space_nla/nla_tracks.cc b/source/blender/editors/space_nla/nla_tracks.cc index f06ee85992c..8dfec3e33ec 100644 --- a/source/blender/editors/space_nla/nla_tracks.cc +++ b/source/blender/editors/space_nla/nla_tracks.cc @@ -24,6 +24,8 @@ #include "BKE_nla.h" #include "BKE_report.hh" +#include "ANIM_action.hh" + #include "ED_anim_api.hh" #include "ED_keyframes_edit.hh" #include "ED_object.hh" @@ -434,6 +436,16 @@ static int nlatracks_pushdown_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } +#ifdef WITH_ANIM_BAKLAVA + /* Reject layered Actions, until the NLA knows how to handle them. + * Ideally this would happen in the poll function, but the way it's determined which Action to + * push down is a bit convoluted (see code above). */ + if (!adt->action->wrap().is_action_legacy()) { + BKE_report(op->reports, RPT_ERROR, "Layered Actions cannot be used as NLA strips"); + return OPERATOR_CANCELLED; + } +#endif // WITH_ANIM_BAKLAVA + /* 'push-down' action - only usable when not in Tweak-mode. */ BKE_nla_action_pushdown(adt, ID_IS_OVERRIDE_LIBRARY(id));