Cleanup: Rename & refactor several F-curve functions
Rename and refactor several F-curve key manipulation functions, and move them from `editors` to `blenkernel`. The functions formerly known as `delete_fcurve_key`, `delete_fcurve_keys`, and `clear_fcurve_keys` have been moved from `ED_keyframes_edit.h` to `BKE_fcurve.h` and have been renamed according to hierarchical naming rules. Below is a table of the naming changes. | From | To | | -- | -- | | `delete_fcurve_key(fcu, index, do_recalc)` | `BKE_fcurve_delete_key(fcu, index)` | | `delete_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_selected(fcu)` | | `clear_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_all(fcu)` | | `calchandles_fcurve()` | `BKE_fcurve_handles_recalc()` | | `calchandles_fcurve_ex()`| `BKE_fcurve_handles_recalc_ex()` | The function formerly known as `delete_fcurve_key` no longer takes a `do_fast` parameter, which determined whether or not to call `calchandles_fcurve`. Now, the responsibility is on the caller to run the new `BKE_fcurve_handles_recalc` function if they have want to recalculate the handles. In addition, there is now a new static private function called `fcurve_bezt_free` which sets the key count to zero and frees the key array. This function is now used in couple of instances of functionally equivalent code. Note that `BKE_fcurve_delete_keys_all` is just a wrapper around `fcurve_bezt_free`. This change was initially spurred by the fact that `delete_fcurve_keys` was improperly named; this was a good opportunity to fix the location and naming of a few of these functions. Reviewed By: sybren Differential Revision: https://developer.blender.org/D15282
This commit is contained in:
parent
77df9d788a
commit
8e3879ab52
|
@ -463,23 +463,38 @@ bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple *bezt,
|
|||
struct BezTriple *next,
|
||||
float *r_pdelta);
|
||||
|
||||
/**
|
||||
* Delete a keyframe from an F-curve at a specific index.
|
||||
*/
|
||||
void BKE_fcurve_delete_key(struct FCurve *fcu, int index);
|
||||
|
||||
/**
|
||||
* Delete selected keyframes from an F-curve.
|
||||
*/
|
||||
bool BKE_fcurve_delete_keys_selected(struct FCurve *fcu);
|
||||
|
||||
/**
|
||||
* Delete all keyframes from an F-curve.
|
||||
*/
|
||||
void BKE_fcurve_delete_keys_all(struct FCurve *fcu);
|
||||
|
||||
/* -------- Curve Sanity -------- */
|
||||
|
||||
/**
|
||||
* This function recalculates the handles of an F-Curve. Acts based on selection with `SELECT`
|
||||
* flag. To use a different flag, use #calchandles_fcurve_ex().
|
||||
* flag. To use a different flag, use #BKE_fcurve_handles_recalc_ex().
|
||||
*
|
||||
* If the BezTriples have been rearranged, sort them first before using this.
|
||||
*/
|
||||
void calchandles_fcurve(struct FCurve *fcu);
|
||||
void BKE_fcurve_handles_recalc(struct FCurve *fcu);
|
||||
/**
|
||||
* Variant of #calchandles_fcurve() that allows calculating based on a different select flag.
|
||||
* Variant of #BKE_fcurve_handles_recalc() that allows calculating based on a different select flag.
|
||||
*
|
||||
* \param handle_sel_flag: The flag (bezt.f1/2/3) value to use to determine selection.
|
||||
* Usually `SELECT`, but may want to use a different one at times
|
||||
* (if caller does not operate on selection).
|
||||
*/
|
||||
void calchandles_fcurve_ex(struct FCurve *fcu, eBezTriple_Flag handle_sel_flag);
|
||||
void BKE_fcurve_handles_recalc_ex(struct FCurve *fcu, eBezTriple_Flag handle_sel_flag);
|
||||
/**
|
||||
* Update handles, making sure the handle-types are valid (e.g. correctly deduced from an "Auto"
|
||||
* type), and recalculating their position vectors.
|
||||
|
|
|
@ -363,7 +363,7 @@ static void action_flip_pchan(Object *ob_arm,
|
|||
|
||||
/* Recalculate handles. */
|
||||
for (int i = 0; i < fcurve_array_len; i++) {
|
||||
calchandles_fcurve_ex(fcurve_array[i], 0);
|
||||
BKE_fcurve_handles_recalc_ex(fcurve_array[i], 0);
|
||||
}
|
||||
|
||||
MEM_freeN((void *)keyed_frames);
|
||||
|
|
|
@ -1146,7 +1146,7 @@ void fcurve_samples_to_keyframes(FCurve *fcu, const int start, const int end)
|
|||
MEM_SAFE_FREE(fcu->fpt);
|
||||
|
||||
/* Not strictly needed since we use linear interpolation, but better be consistent here. */
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
/* ***************************** F-Curve Sanity ********************************* */
|
||||
|
@ -1216,7 +1216,7 @@ static BezTriple *cycle_offset_triple(
|
|||
return out;
|
||||
}
|
||||
|
||||
void calchandles_fcurve_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
|
||||
void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
|
||||
{
|
||||
BezTriple *bezt, *prev, *next;
|
||||
int a = fcu->totvert;
|
||||
|
@ -1299,9 +1299,9 @@ void calchandles_fcurve_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
|
|||
}
|
||||
}
|
||||
|
||||
void calchandles_fcurve(FCurve *fcu)
|
||||
void BKE_fcurve_handles_recalc(FCurve *fcu)
|
||||
{
|
||||
calchandles_fcurve_ex(fcu, SELECT);
|
||||
BKE_fcurve_handles_recalc_ex(fcu, SELECT);
|
||||
}
|
||||
|
||||
void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, const bool use_handle)
|
||||
|
@ -1320,7 +1320,7 @@ void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, const bool use_ha
|
|||
}
|
||||
|
||||
/* Recalculate handles. */
|
||||
calchandles_fcurve_ex(fcu, sel_flag);
|
||||
BKE_fcurve_handles_recalc_ex(fcu, sel_flag);
|
||||
}
|
||||
|
||||
void sort_time_fcurve(FCurve *fcu)
|
||||
|
@ -1590,6 +1590,12 @@ static void berekeny(float f1, float f2, float f3, float f4, float *o, int b)
|
|||
}
|
||||
}
|
||||
|
||||
static void fcurve_bezt_free(FCurve *fcu)
|
||||
{
|
||||
MEM_SAFE_FREE(fcu->bezt);
|
||||
fcu->totvert = 0;
|
||||
}
|
||||
|
||||
bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple *bezt,
|
||||
struct BezTriple *prev,
|
||||
struct BezTriple *next,
|
||||
|
@ -1651,6 +1657,69 @@ bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple *bezt,
|
|||
return true;
|
||||
}
|
||||
|
||||
void BKE_fcurve_delete_key(FCurve *fcu, int index)
|
||||
{
|
||||
/* sanity check */
|
||||
if (fcu == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* verify the index:
|
||||
* 1) cannot be greater than the number of available keyframes
|
||||
* 2) negative indices are for specifying a value from the end of the array
|
||||
*/
|
||||
if (abs(index) >= fcu->totvert) {
|
||||
return;
|
||||
}
|
||||
if (index < 0) {
|
||||
index += fcu->totvert;
|
||||
}
|
||||
|
||||
/* Delete this keyframe */
|
||||
memmove(
|
||||
&fcu->bezt[index], &fcu->bezt[index + 1], sizeof(BezTriple) * (fcu->totvert - index - 1));
|
||||
fcu->totvert--;
|
||||
|
||||
/* Free the array of BezTriples if there are not keyframes */
|
||||
if (fcu->totvert == 0) {
|
||||
fcurve_bezt_free(fcu);
|
||||
}
|
||||
}
|
||||
|
||||
bool BKE_fcurve_delete_keys_selected(FCurve *fcu)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if (fcu->bezt == NULL) { /* ignore baked curves */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Delete selected BezTriples */
|
||||
for (int i = 0; i < fcu->totvert; i++) {
|
||||
if (fcu->bezt[i].f2 & SELECT) {
|
||||
if (i == fcu->active_keyframe_index) {
|
||||
BKE_fcurve_active_keyframe_set(fcu, NULL);
|
||||
}
|
||||
memmove(&fcu->bezt[i], &fcu->bezt[i + 1], sizeof(BezTriple) * (fcu->totvert - i - 1));
|
||||
fcu->totvert--;
|
||||
i--;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the array of BezTriples if there are not keyframes */
|
||||
if (fcu->totvert == 0) {
|
||||
fcurve_bezt_free(fcu);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void BKE_fcurve_delete_keys_all(FCurve *fcu)
|
||||
{
|
||||
fcurve_bezt_free(fcu);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
|
@ -1127,7 +1127,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
|
|||
|
||||
/* update the fcurve if the Cycles modifier is added */
|
||||
if ((owner_fcu) && (type == FMODIFIER_TYPE_CYCLES)) {
|
||||
calchandles_fcurve(owner_fcu);
|
||||
BKE_fcurve_handles_recalc(owner_fcu);
|
||||
}
|
||||
|
||||
/* return modifier for further editing */
|
||||
|
@ -1215,7 +1215,7 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
|
|||
|
||||
/* update the fcurve if the Cycles modifier is removed */
|
||||
if (update_fcu) {
|
||||
calchandles_fcurve(update_fcu);
|
||||
BKE_fcurve_handles_recalc(update_fcu);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -356,7 +356,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
|
|||
if (ale->update & ANIM_UPDATE_HANDLES) {
|
||||
ale->update &= ~ANIM_UPDATE_HANDLES;
|
||||
if (fcu) {
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ struct FCurve *alloc_driver_fcurve(const char rna_path[],
|
|||
insert_vert_fcurve(
|
||||
fcu, 1.0f, 1.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST | INSERTKEY_NO_USERPREF);
|
||||
fcu->extend = FCURVE_EXTRAPOLATE_LINEAR;
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1020,7 +1020,7 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
|
|||
|
||||
/* adding or removing the Cycles modifier requires an update to handles */
|
||||
if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic) {
|
||||
calchandles_fcurve(curve);
|
||||
BKE_fcurve_handles_recalc(curve);
|
||||
}
|
||||
|
||||
/* did we succeed? */
|
||||
|
|
|
@ -444,7 +444,7 @@ void ANIM_animdata_keyframe_callback(bAnimContext *ac,
|
|||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, callback_fn, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, callback_fn, BKE_fcurve_handles_recalc);
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,77 +47,6 @@
|
|||
|
||||
/* **************************************************** */
|
||||
|
||||
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
|
||||
{
|
||||
/* sanity check */
|
||||
if (fcu == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* verify the index:
|
||||
* 1) cannot be greater than the number of available keyframes
|
||||
* 2) negative indices are for specifying a value from the end of the array
|
||||
*/
|
||||
if (abs(index) >= fcu->totvert) {
|
||||
return;
|
||||
}
|
||||
if (index < 0) {
|
||||
index += fcu->totvert;
|
||||
}
|
||||
|
||||
/* Delete this keyframe */
|
||||
memmove(
|
||||
&fcu->bezt[index], &fcu->bezt[index + 1], sizeof(BezTriple) * (fcu->totvert - index - 1));
|
||||
fcu->totvert--;
|
||||
|
||||
if (fcu->totvert == 0) {
|
||||
MEM_SAFE_FREE(fcu->bezt);
|
||||
}
|
||||
|
||||
/* recalc handles - only if it won't cause problems */
|
||||
if (do_recalc) {
|
||||
calchandles_fcurve(fcu);
|
||||
}
|
||||
}
|
||||
|
||||
bool delete_fcurve_keys(FCurve *fcu)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if (fcu->bezt == NULL) { /* ignore baked curves */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Delete selected BezTriples */
|
||||
for (int i = 0; i < fcu->totvert; i++) {
|
||||
if (fcu->bezt[i].f2 & SELECT) {
|
||||
if (i == fcu->active_keyframe_index) {
|
||||
BKE_fcurve_active_keyframe_set(fcu, NULL);
|
||||
}
|
||||
memmove(&fcu->bezt[i], &fcu->bezt[i + 1], sizeof(BezTriple) * (fcu->totvert - i - 1));
|
||||
fcu->totvert--;
|
||||
i--;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the array of BezTriples if there are not keyframes */
|
||||
if (fcu->totvert == 0) {
|
||||
clear_fcurve_keys(fcu);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void clear_fcurve_keys(FCurve *fcu)
|
||||
{
|
||||
MEM_SAFE_FREE(fcu->bezt);
|
||||
|
||||
fcu->totvert = 0;
|
||||
}
|
||||
|
||||
/* ---------------- */
|
||||
|
||||
bool duplicate_fcurve_keys(FCurve *fcu)
|
||||
{
|
||||
bool changed = false;
|
||||
|
@ -282,7 +211,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
|
|||
}
|
||||
|
||||
if (fcu->bezt->vec[1][1] == default_value) {
|
||||
clear_fcurve_keys(fcu);
|
||||
BKE_fcurve_delete_keys_all(fcu);
|
||||
|
||||
/* check if curve is really unused and if it is, return signal for deletion */
|
||||
if (BKE_fcurve_is_empty(fcu)) {
|
||||
|
@ -679,7 +608,7 @@ void smooth_fcurve(FCurve *fcu)
|
|||
}
|
||||
|
||||
/* recalculate handles */
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
/* ---------------- */
|
||||
|
@ -762,7 +691,7 @@ void sample_fcurve(FCurve *fcu)
|
|||
}
|
||||
|
||||
/* recalculate channel's handles? */
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
@ -1121,7 +1050,7 @@ static void paste_animedit_keys_fcurve(
|
|||
|
||||
case KEYFRAME_PASTE_MERGE_OVER:
|
||||
/* remove all keys */
|
||||
clear_fcurve_keys(fcu);
|
||||
BKE_fcurve_delete_keys_all(fcu);
|
||||
break;
|
||||
|
||||
case KEYFRAME_PASTE_MERGE_OVER_RANGE:
|
||||
|
@ -1148,7 +1077,7 @@ static void paste_animedit_keys_fcurve(
|
|||
}
|
||||
|
||||
/* remove frames in the range */
|
||||
delete_fcurve_keys(fcu);
|
||||
BKE_fcurve_delete_keys_selected(fcu);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1182,7 +1111,7 @@ static void paste_animedit_keys_fcurve(
|
|||
}
|
||||
|
||||
/* recalculate F-Curve's handles? */
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
const EnumPropertyItem rna_enum_keyframe_paste_offset_items[] = {
|
||||
|
|
|
@ -639,7 +639,7 @@ int insert_vert_fcurve(
|
|||
* - we may calculate twice (due to auto-handle needing to be calculated twice)
|
||||
*/
|
||||
if ((flag & INSERTKEY_FAST) == 0) {
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
/* return the index at which the keyframe was added */
|
||||
|
@ -1282,10 +1282,12 @@ static bool insert_keyframe_value(ReportList *reports,
|
|||
/* delete keyframe immediately before/after newly added */
|
||||
switch (insert_mode) {
|
||||
case KEYNEEDED_DELPREV:
|
||||
delete_fcurve_key(fcu, fcu->totvert - 2, 1);
|
||||
BKE_fcurve_delete_key(fcu, fcu->totvert - 2);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
break;
|
||||
case KEYNEEDED_DELNEXT:
|
||||
delete_fcurve_key(fcu, 1, 1);
|
||||
BKE_fcurve_delete_key(fcu, 1);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1683,7 +1685,8 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
|
|||
i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, cfra, fcu->totvert, &found);
|
||||
if (found) {
|
||||
/* delete the key at the index (will sanity check + do recalc afterwards) */
|
||||
delete_fcurve_key(fcu, i, 1);
|
||||
BKE_fcurve_delete_key(fcu, i);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
|
||||
/* Only delete curve too if it won't be doing anything anymore */
|
||||
if (BKE_fcurve_is_empty(fcu)) {
|
||||
|
@ -2709,7 +2712,8 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
|
|||
i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, cfra, fcu->totvert, &found);
|
||||
if (found) {
|
||||
/* delete the key at the index (will sanity check + do recalc afterwards) */
|
||||
delete_fcurve_key(fcu, i, 1);
|
||||
BKE_fcurve_delete_key(fcu, i);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "BKE_action.h"
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
|
@ -615,7 +616,8 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
|
|||
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
||||
/* check if remove */
|
||||
if (IS_EQF(bezt->vec[1][0], (float)marker->frame)) {
|
||||
delete_fcurve_key(fcu, i, 1);
|
||||
BKE_fcurve_delete_key(fcu, i);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -588,7 +588,7 @@ static void gpencil_stroke_path_animation(bContext *C,
|
|||
}
|
||||
|
||||
/* As we used INSERTKEY_FAST mode, we need to recompute all curve's handles now */
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
|
|
|
@ -388,9 +388,6 @@ bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, con
|
|||
/* ************************************************ */
|
||||
/* Destructive Editing API (keyframes_general.c) */
|
||||
|
||||
void delete_fcurve_key(struct FCurve *fcu, int index, bool do_recalc);
|
||||
bool delete_fcurve_keys(struct FCurve *fcu);
|
||||
void clear_fcurve_keys(struct FCurve *fcu);
|
||||
bool duplicate_fcurve_keys(struct FCurve *fcu);
|
||||
float get_default_rna_value(struct FCurve *fcu, struct PropertyRNA *prop, struct PointerRNA *ptr);
|
||||
|
||||
|
|
|
@ -1006,7 +1006,7 @@ static bool delete_action_keys(bAnimContext *ac)
|
|||
AnimData *adt = ale->adt;
|
||||
|
||||
/* delete selected keyframes only */
|
||||
changed = delete_fcurve_keys(fcu);
|
||||
changed = BKE_fcurve_delete_keys_selected(fcu);
|
||||
|
||||
/* Only delete curve too if it won't be doing anything anymore */
|
||||
if (BKE_fcurve_is_empty(fcu)) {
|
||||
|
@ -1473,7 +1473,7 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
|
|||
/* any selected keyframes for editing? */
|
||||
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
|
||||
/* change type of selected handles */
|
||||
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
}
|
||||
|
@ -1790,11 +1790,11 @@ static void snap_action_keys(bAnimContext *ac, short mode)
|
|||
}
|
||||
else if (adt) {
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
|
||||
}
|
||||
else {
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
}
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
|
@ -1914,11 +1914,11 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
|
|||
}
|
||||
else if (adt) {
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
|
||||
}
|
||||
else {
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
}
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
|
|
|
@ -277,7 +277,7 @@ static void graphedit_activekey_update_cb(bContext *UNUSED(C),
|
|||
|
||||
/* make sure F-Curve and its handles are still valid after this editing */
|
||||
sort_time_fcurve(fcu);
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
/* update callback for active keyframe properties - handle-editing wrapper */
|
||||
|
|
|
@ -723,7 +723,7 @@ static bool delete_graph_keys(bAnimContext *ac)
|
|||
bool changed;
|
||||
|
||||
/* Delete selected keyframes only. */
|
||||
changed = delete_fcurve_keys(fcu);
|
||||
changed = BKE_fcurve_delete_keys_selected(fcu);
|
||||
|
||||
if (changed) {
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
|
@ -1488,7 +1488,7 @@ static void setipo_graph_keys(bAnimContext *ac, short mode)
|
|||
* Currently that's not necessary here.
|
||||
*/
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, BKE_fcurve_handles_recalc);
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT_NOHANDLES;
|
||||
}
|
||||
|
@ -1566,7 +1566,7 @@ static void seteasing_graph_keys(bAnimContext *ac, short mode)
|
|||
* Currently that's not necessary here.
|
||||
*/
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, BKE_fcurve_handles_recalc);
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT_NOHANDLES;
|
||||
}
|
||||
|
@ -1649,7 +1649,7 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode)
|
|||
/* Any selected keyframes for editing? */
|
||||
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
|
||||
/* Change type of selected handles. */
|
||||
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
}
|
||||
|
@ -2295,11 +2295,11 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
|
|||
/* Perform snapping. */
|
||||
if (adt) {
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
|
||||
}
|
||||
else {
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
}
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
|
@ -2555,11 +2555,11 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
|
|||
/* Perform actual mirroring. */
|
||||
if (adt) {
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
|
||||
}
|
||||
else {
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
|
||||
}
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
|
|
|
@ -2205,7 +2205,7 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
* applying this scaling */
|
||||
ked.data = strip;
|
||||
ANIM_animchanneldata_keyframes_loop(
|
||||
&ked, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, calchandles_fcurve);
|
||||
&ked, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, BKE_fcurve_handles_recalc);
|
||||
|
||||
/* clear scale of strip now that it has been applied,
|
||||
* and recalculate the extents of the action now that it has been scaled
|
||||
|
|
|
@ -769,7 +769,7 @@ void posttrans_fcurve_clean(FCurve *fcu, const int sel_flag, const bool use_hand
|
|||
}
|
||||
else {
|
||||
/* Delete Keyframe */
|
||||
delete_fcurve_key(fcu, i, 0);
|
||||
BKE_fcurve_delete_key(fcu, i);
|
||||
}
|
||||
|
||||
/* Update count of how many we've deleted
|
||||
|
@ -779,7 +779,7 @@ void posttrans_fcurve_clean(FCurve *fcu, const int sel_flag, const bool use_hand
|
|||
}
|
||||
else {
|
||||
/* Always delete - Unselected keys don't matter */
|
||||
delete_fcurve_key(fcu, i, 0);
|
||||
BKE_fcurve_delete_key(fcu, i);
|
||||
}
|
||||
|
||||
/* Stop the RK search... we've found our match now */
|
||||
|
|
|
@ -934,7 +934,7 @@ void recalcData_graphedit(TransInfo *t)
|
|||
dosort++;
|
||||
}
|
||||
else {
|
||||
calchandles_fcurve_ex(fcu, BEZT_FLAG_TEMP_TAG);
|
||||
BKE_fcurve_handles_recalc_ex(fcu, BEZT_FLAG_TEMP_TAG);
|
||||
}
|
||||
|
||||
/* set refresh tags for objects using this animation,
|
||||
|
|
|
@ -64,7 +64,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
|
|||
bez.f1 = bez.f2 = bez.f3 = SELECT;
|
||||
bez.h1 = bez.h2 = HD_AUTO;
|
||||
insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
|
||||
|
@ -132,7 +132,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
|
|||
insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
|
||||
}
|
||||
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
|
||||
fcurves.push_back(fcu);
|
||||
unused_curves.push_back(fcu);
|
||||
|
|
|
@ -96,7 +96,7 @@ void BCAnimationCurve::create_bezt(float frame, float output)
|
|||
bez.f1 = bez.f2 = bez.f3 = SELECT;
|
||||
bez.h1 = bez.h2 = HD_AUTO;
|
||||
insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
BCAnimationCurve::~BCAnimationCurve()
|
||||
|
|
|
@ -612,7 +612,7 @@ static void rna_tag_animation_update(Main *bmain, ID *id)
|
|||
static void rna_FCurve_update_data_ex(ID *id, FCurve *fcu, Main *bmain)
|
||||
{
|
||||
sort_time_fcurve(fcu);
|
||||
calchandles_fcurve(fcu);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
|
||||
rna_tag_animation_update(bmain, id);
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ static void rna_FModifier_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
|
|||
FModifier *fcm = (FModifier *)ptr->data;
|
||||
|
||||
if (fcm->curve && fcm->type == FMODIFIER_TYPE_CYCLES) {
|
||||
calchandles_fcurve(fcm->curve);
|
||||
BKE_fcurve_handles_recalc(fcm->curve);
|
||||
}
|
||||
|
||||
rna_tag_animation_update(bmain, id);
|
||||
|
@ -1021,9 +1021,13 @@ static void rna_FKeyframe_points_remove(
|
|||
return;
|
||||
}
|
||||
|
||||
delete_fcurve_key(fcu, index, !do_fast);
|
||||
BKE_fcurve_delete_key(fcu, index);
|
||||
RNA_POINTER_INVALIDATE(bezt_ptr);
|
||||
|
||||
if (!do_fast) {
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
}
|
||||
|
||||
rna_tag_animation_update(bmain, id);
|
||||
}
|
||||
|
||||
|
|
|
@ -487,7 +487,8 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
|||
i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, cfra, fcu->totvert, &found);
|
||||
if (found) {
|
||||
/* delete the key at the index (will sanity check + do recalc afterwards) */
|
||||
delete_fcurve_key(fcu, i, 1);
|
||||
BKE_fcurve_delete_key(fcu, i);
|
||||
BKE_fcurve_handles_recalc(fcu);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue