Refactor: Remove dependencies on Editor code from animrig #116100

Merged
Christoph Lendenfeld merged 2 commits from ChrisLend/blender:refactor_remove_ed_from_animrig into main 2023-12-12 16:05:02 +01:00
5 changed files with 28 additions and 29 deletions

View File

@ -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.
*

View File

@ -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

View File

@ -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)
{

View File

@ -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 */

View File

@ -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);
/* -------- */