From fd3629b80a1c205344627f872323714065bf0fca Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 12 Dec 2023 16:04:53 +0100 Subject: [PATCH] Refactor: Remove dependencies on Editor code from animrig No functional changes. This moves the function `update_autoflags_fcurve_direct` from the editors/animation section to blender/animrig. This is in an effort to remove the need for editor code in animrig. Also removes the include of editor code from fcurve.cc This was only used on a single line for a macro. Pull Request: https://projects.blender.org/blender/blender/pulls/116100 --- source/blender/animrig/ANIM_keyframing.hh | 3 +++ source/blender/animrig/intern/fcurve.cc | 6 ++--- source/blender/animrig/intern/keyframing.cc | 22 ++++++++++++++++ .../blender/editors/animation/keyframing.cc | 25 +------------------ .../blender/editors/include/ED_keyframing.hh | 1 - 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/source/blender/animrig/ANIM_keyframing.hh b/source/blender/animrig/ANIM_keyframing.hh index 7a100805a71..f55d93cf360 100644 --- a/source/blender/animrig/ANIM_keyframing.hh +++ b/source/blender/animrig/ANIM_keyframing.hh @@ -32,6 +32,9 @@ namespace blender::animrig { /** \name Key-Framing Management * \{ */ +/* Set the FCurve flag based on the property type of `prop`. */ +void update_autoflags_fcurve_direct(FCurve *fcu, PropertyRNA *prop); + /** * \brief Main Insert Key-framing API call. * diff --git a/source/blender/animrig/intern/fcurve.cc b/source/blender/animrig/intern/fcurve.cc index ce400441fab..c7f5e7a25c8 100644 --- a/source/blender/animrig/intern/fcurve.cc +++ b/source/blender/animrig/intern/fcurve.cc @@ -14,7 +14,6 @@ #include "BKE_fcurve.h" #include "BLI_math_vector_types.hh" #include "DNA_anim_types.h" -#include "ED_anim_api.hh" #include "MEM_guardedalloc.h" namespace blender::animrig { @@ -240,9 +239,8 @@ void initialize_bezt(BezTriple *beztr, beztr->ipo = BEZT_IPO_LIN; } - /* Set keyframe type value (supplied), which should come from the scene - * settings in most cases. */ - BEZKEYTYPE(beztr) = settings.keyframe_type; + /* The keytype is hackily stored on the hide flag since that isn't used in animation. */ + beztr->hide = settings.keyframe_type; /* Set default values for "easing" interpolation mode settings. * NOTE: Even if these modes aren't currently used, if users switch diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index 82860f226c7..e60e6677593 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -45,6 +45,28 @@ namespace blender::animrig { +void update_autoflags_fcurve_direct(FCurve *fcu, PropertyRNA *prop) +{ + /* Set additional flags for the F-Curve (i.e. only integer values). */ + fcu->flag &= ~(FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES); + switch (RNA_property_type(prop)) { + case PROP_FLOAT: + /* Do nothing. */ + break; + case PROP_INT: + /* Do integer (only 'whole' numbers) interpolation between all points. */ + fcu->flag |= FCURVE_INT_VALUES; + break; + default: + /* Do 'discrete' (i.e. enum, boolean values which cannot take any intermediate + * values at all) interpolation between all points. + * - however, we must also ensure that evaluated values are only integers still. + */ + fcu->flag |= (FCURVE_DISCRETE_VALUES | FCURVE_INT_VALUES); + break; + } +} + /** Used to make curves newly added to a cyclic Action cycle with the correct period. */ static void make_new_fcurve_cyclic(const bAction *act, FCurve *fcu) { diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index 1dedcd52d7d..5898fe868ff 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -156,29 +156,6 @@ bAction *ED_id_action_ensure(Main *bmain, ID *id) return adt->action; } -/** Helper for #update_autoflags_fcurve(). */ -void update_autoflags_fcurve_direct(FCurve *fcu, PropertyRNA *prop) -{ - /* set additional flags for the F-Curve (i.e. only integer values) */ - fcu->flag &= ~(FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES); - switch (RNA_property_type(prop)) { - case PROP_FLOAT: - /* do nothing */ - break; - case PROP_INT: - /* do integer (only 'whole' numbers) interpolation between all points */ - fcu->flag |= FCURVE_INT_VALUES; - break; - default: - /* do 'discrete' (i.e. enum, boolean values which cannot take any intermediate - * values at all) interpolation between all points - * - however, we must also ensure that evaluated values are only integers still - */ - fcu->flag |= (FCURVE_DISCRETE_VALUES | FCURVE_INT_VALUES); - break; - } -} - void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, PointerRNA *ptr) { PointerRNA tmp_ptr; @@ -205,7 +182,7 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin } /* update F-Curve flags */ - update_autoflags_fcurve_direct(fcu, prop); + blender::animrig::update_autoflags_fcurve_direct(fcu, prop); if (old_flag != fcu->flag) { /* Same as if keyframes had been changed */ diff --git a/source/blender/editors/include/ED_keyframing.hh b/source/blender/editors/include/ED_keyframing.hh index 4c3d9b365b9..623063d6318 100644 --- a/source/blender/editors/include/ED_keyframing.hh +++ b/source/blender/editors/include/ED_keyframing.hh @@ -63,7 +63,6 @@ bAction *ED_id_action_ensure(Main *bmain, ID *id); * but also through RNA when editing an ID prop, see #37103). */ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, PointerRNA *ptr); -void update_autoflags_fcurve_direct(FCurve *fcu, PropertyRNA *prop); /* -------- */