Refactor: More specific arguments for ANIM_get_normalization_flags
No functional changes. `ANIM_get_normalization_flags` had the argument type of `bAnimContext *`. That made it more difficult than it needs to be to reuse that function. Pass a `SpaceLink *` instead since that is what the function actually uses. Pull Request: https://projects.blender.org/blender/blender/pulls/114676
This commit is contained in:
committed by
Christoph Lendenfeld
parent
43c2c1844f
commit
6e7af8ceff
@@ -77,7 +77,7 @@ static bool get_normalized_fcurve_bounds(FCurve *fcu,
|
||||
return false;
|
||||
}
|
||||
|
||||
const short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
const short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
|
||||
float offset;
|
||||
const float unit_fac = ANIM_unit_mapping_get_factor(
|
||||
|
||||
@@ -321,10 +321,10 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, boo
|
||||
/* *************************************************** */
|
||||
/* UNITS CONVERSION MAPPING (required for drawing and editing keyframes) */
|
||||
|
||||
short ANIM_get_normalization_flags(bAnimContext *ac)
|
||||
short ANIM_get_normalization_flags(SpaceLink *space_link)
|
||||
{
|
||||
if (ac->sl->spacetype == SPACE_GRAPH) {
|
||||
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
|
||||
if (space_link->spacetype == SPACE_GRAPH) {
|
||||
SpaceGraph *sipo = (SpaceGraph *)space_link;
|
||||
bool use_normalization = (sipo->flag & SIPO_NORMALIZE) != 0;
|
||||
bool freeze_normalization = (sipo->flag & SIPO_NORMALIZE_FREEZE) != 0;
|
||||
return use_normalization ? (ANIM_UNITCONV_NORMALIZE |
|
||||
|
||||
@@ -923,6 +923,7 @@ void ED_nla_postop_refresh(bAnimContext *ac);
|
||||
|
||||
/** Flags for conversion mapping. */
|
||||
enum eAnimUnitConv_Flags {
|
||||
ANIM_UNITCONV_NONE = 0,
|
||||
/** Restore to original internal values. */
|
||||
ANIM_UNITCONV_RESTORE = (1 << 0),
|
||||
/** Ignore handles (i.e. only touch main keyframes). */
|
||||
@@ -944,7 +945,7 @@ enum eAnimUnitConv_Flags {
|
||||
/**
|
||||
* Get flags used for normalization in ANIM_unit_mapping_get_factor.
|
||||
*/
|
||||
short ANIM_get_normalization_flags(bAnimContext *ac);
|
||||
short ANIM_get_normalization_flags(SpaceLink *space_link);
|
||||
/**
|
||||
* Get unit conversion factor for given ID + F-Curve.
|
||||
*/
|
||||
|
||||
@@ -592,7 +592,7 @@ static void draw_fcurve_curve(bAnimContext *ac,
|
||||
const bool use_nla_remap,
|
||||
const bool draw_extrapolation)
|
||||
{
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
|
||||
/* when opening a blend file on a different sized screen or while dragging the toolbar this can
|
||||
* happen best just bail out in this case. */
|
||||
@@ -739,7 +739,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac,
|
||||
float fac, v[2];
|
||||
int b = fcu->totvert;
|
||||
float unit_scale, offset;
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
int count = fcu->totvert;
|
||||
|
||||
const bool extrap_left = draw_extrapolation && prevfpt->vec[0] > v2d->cur.xmin;
|
||||
@@ -1023,7 +1023,7 @@ static void draw_fcurve_curve_keys(
|
||||
/* Apply unit mapping. */
|
||||
GPU_matrix_push();
|
||||
float offset;
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
const float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
|
||||
GPU_matrix_scale_2f(1.0f, unit_scale);
|
||||
GPU_matrix_translate_2f(0.0f, offset);
|
||||
@@ -1264,7 +1264,7 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn
|
||||
}
|
||||
}
|
||||
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
float offset;
|
||||
const float unit_scale = ANIM_unit_mapping_get_factor(
|
||||
ac->scene, ale->id, fcu, mapping_flag, &offset);
|
||||
@@ -1319,7 +1319,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
|
||||
{
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
View2D *v2d = &ac->region->v2d;
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
float offset;
|
||||
float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
float offset;
|
||||
float unit_scale = ANIM_unit_mapping_get_factor(
|
||||
ac->scene, ale->id, static_cast<FCurve *>(ale->key_data), mapping_flag, &offset);
|
||||
@@ -321,7 +321,7 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
|
||||
ListBase anim_data;
|
||||
ToolSettings *ts = ac.scene->toolsettings;
|
||||
|
||||
short mapping_flag = ANIM_get_normalization_flags(&ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac.sl);
|
||||
float scale, offset;
|
||||
|
||||
/* Preserve selection? */
|
||||
@@ -2119,7 +2119,7 @@ static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
|
||||
|
||||
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
KeyframeEditData current_ked;
|
||||
float offset;
|
||||
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene,
|
||||
@@ -2441,7 +2441,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
|
||||
|
||||
/* Normalize cursor value (for normalized F-Curves display). */
|
||||
if (mode == GRAPHKEYS_SNAP_VALUE) {
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
float offset;
|
||||
float unit_scale = ANIM_unit_mapping_get_factor(
|
||||
ac->scene, ale->id, static_cast<FCurve *>(ale->key_data), mapping_flag, &offset);
|
||||
@@ -2754,7 +2754,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
|
||||
|
||||
/* Apply unit corrections. */
|
||||
if (mode == GRAPHKEYS_MIRROR_VALUE) {
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
float offset;
|
||||
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene,
|
||||
ale->id,
|
||||
|
||||
@@ -181,7 +181,7 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
|
||||
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
|
||||
filter |= ANIMFILTER_SEL;
|
||||
}
|
||||
mapping_flag |= ANIM_get_normalization_flags(ac);
|
||||
mapping_flag |= ANIM_get_normalization_flags(ac->sl);
|
||||
ANIM_animdata_filter(
|
||||
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
|
||||
|
||||
@@ -581,7 +581,7 @@ static void initialize_box_select_key_editing_data(const bool incl_handles,
|
||||
*r_mapping_flag = ANIM_UNITCONV_ONLYKEYS;
|
||||
}
|
||||
|
||||
*r_mapping_flag |= ANIM_get_normalization_flags(ac);
|
||||
*r_mapping_flag |= ANIM_get_normalization_flags(ac->sl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,7 +90,7 @@ void get_graph_keyframe_extents(bAnimContext *ac,
|
||||
|
||||
/* Get range. */
|
||||
if (BKE_fcurve_calc_bounds(fcu, do_sel_only, include_handles, nullptr, &bounds)) {
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
|
||||
/* Apply NLA scaling. */
|
||||
if (adt) {
|
||||
@@ -410,7 +410,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
|
||||
FPoint *fpt;
|
||||
float unitFac, offset;
|
||||
int cfra;
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac);
|
||||
short mapping_flag = ANIM_get_normalization_flags(ac->sl);
|
||||
|
||||
/* Disable driver so that it don't muck up the sampling process. */
|
||||
fcu->driver = nullptr;
|
||||
|
||||
@@ -240,7 +240,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
|
||||
return;
|
||||
}
|
||||
|
||||
anim_map_flag |= ANIM_get_normalization_flags(&ac);
|
||||
anim_map_flag |= ANIM_get_normalization_flags(ac.sl);
|
||||
|
||||
/* filter data */
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE |
|
||||
|
||||
Reference in New Issue
Block a user