Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/fcurve.c
| Show First 20 Lines • Show All 565 Lines • ▼ Show 20 Lines | int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], | ||||
| /* This is just a wrapper which uses the default threshold. */ | /* This is just a wrapper which uses the default threshold. */ | ||||
| return BKE_fcurve_bezt_binarysearch_index_ex( | return BKE_fcurve_bezt_binarysearch_index_ex( | ||||
| array, frame, arraylen, BEZT_BINARYSEARCH_THRESH, r_replace); | array, frame, arraylen, BEZT_BINARYSEARCH_THRESH, r_replace); | ||||
| } | } | ||||
| /* ...................................... */ | /* ...................................... */ | ||||
| /* Helper for calc_fcurve_* functions -> find first and last BezTriple to be used. */ | /* Helper for calc_fcurve_* functions -> find first and last BezTriple to be used. */ | ||||
| static short get_fcurve_end_keyframes(FCurve *fcu, | static short get_fcurve_end_keyframes(const FCurve *fcu, | ||||
| BezTriple **first, | BezTriple **first, | ||||
| BezTriple **last, | BezTriple **last, | ||||
| const bool do_sel_only) | const bool do_sel_only) | ||||
| { | { | ||||
| bool found = false; | bool found = false; | ||||
| /* Init outputs. */ | /* Init outputs. */ | ||||
| *first = NULL; | *first = NULL; | ||||
| Show All 33 Lines | else { | ||||
| *first = fcu->bezt; | *first = fcu->bezt; | ||||
| *last = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, fcu->totvert); | *last = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, fcu->totvert); | ||||
| found = true; | found = true; | ||||
| } | } | ||||
| return found; | return found; | ||||
| } | } | ||||
| bool BKE_fcurve_calc_bounds(FCurve *fcu, | bool BKE_fcurve_calc_bounds(const FCurve *fcu, | ||||
| float *xmin, | float *xmin, | ||||
| float *xmax, | float *xmax, | ||||
| float *ymin, | float *ymin, | ||||
| float *ymax, | float *ymax, | ||||
| const bool do_sel_only, | const bool do_sel_only, | ||||
| const bool include_handles) | const bool include_handles) | ||||
| { | { | ||||
| float xminv = 999999999.0f, xmaxv = -999999999.0f; | float xminv = 999999999.0f, xmaxv = -999999999.0f; | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | if (ymax) { | ||||
| *ymax = 1.0f; | *ymax = 1.0f; | ||||
| } | } | ||||
| } | } | ||||
| return foundvert; | return foundvert; | ||||
| } | } | ||||
| bool BKE_fcurve_calc_range( | bool BKE_fcurve_calc_range( | ||||
| FCurve *fcu, float *start, float *end, const bool do_sel_only, const bool do_min_length) | const FCurve *fcu, float *start, float *end, const bool do_sel_only, const bool do_min_length) | ||||
| { | { | ||||
| float min = 999999999.0f, max = -999999999.0f; | float min = 999999999.0f, max = -999999999.0f; | ||||
| bool foundvert = false; | bool foundvert = false; | ||||
| if (fcu->totvert) { | if (fcu->totvert) { | ||||
| if (fcu->bezt) { | if (fcu->bezt) { | ||||
| BezTriple *bezt_first = NULL, *bezt_last = NULL; | BezTriple *bezt_first = NULL, *bezt_last = NULL; | ||||
| ▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | void BKE_fcurve_keyframe_move_value_with_handles(struct BezTriple *keyframe, const float new_value) | ||||
| keyframe->vec[1][1] = new_value; | keyframe->vec[1][1] = new_value; | ||||
| keyframe->vec[2][1] += value_delta; | keyframe->vec[2][1] += value_delta; | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Status Checks | /** \name Status Checks | ||||
| * \{ */ | * \{ */ | ||||
| bool BKE_fcurve_are_keyframes_usable(FCurve *fcu) | bool BKE_fcurve_are_keyframes_usable(const FCurve *fcu) | ||||
| { | { | ||||
| /* F-Curve must exist. */ | /* F-Curve must exist. */ | ||||
| if (fcu == NULL) { | if (fcu == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* F-Curve must not have samples - samples are mutually exclusive of keyframes. */ | /* F-Curve must not have samples - samples are mutually exclusive of keyframes. */ | ||||
| if (fcu->fpt) { | if (fcu->fpt) { | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Keyframes are usable. */ | /* Keyframes are usable. */ | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool BKE_fcurve_is_protected(FCurve *fcu) | bool BKE_fcurve_is_protected(const FCurve *fcu) | ||||
| { | { | ||||
| return ((fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED))); | return ((fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED))); | ||||
| } | } | ||||
| bool BKE_fcurve_has_selected_control_points(const FCurve *fcu) | bool BKE_fcurve_has_selected_control_points(const FCurve *fcu) | ||||
| { | { | ||||
| int i; | int i; | ||||
| BezTriple *bezt; | BezTriple *bezt; | ||||
| for (bezt = fcu->bezt, i = 0; i < fcu->totvert; ++i, ++bezt) { | for (bezt = fcu->bezt, i = 0; i < fcu->totvert; ++i, ++bezt) { | ||||
| if ((bezt->f2 & SELECT) != 0) { | if ((bezt->f2 & SELECT) != 0) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| bool BKE_fcurve_is_keyframable(FCurve *fcu) | bool BKE_fcurve_is_keyframable(const FCurve *fcu) | ||||
| { | { | ||||
| /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */ | /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */ | ||||
| if (BKE_fcurve_are_keyframes_usable(fcu) == 0) { | if (BKE_fcurve_are_keyframes_usable(fcu) == 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* F-Curve must currently be editable too. */ | /* F-Curve must currently be editable too. */ | ||||
| if (BKE_fcurve_is_protected(fcu)) { | if (BKE_fcurve_is_protected(fcu)) { | ||||
| ▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ***************************** F-Curve Sanity ********************************* */ | /* ***************************** F-Curve Sanity ********************************* */ | ||||
| /* The functions here are used in various parts of Blender, usually after some editing | /* The functions here are used in various parts of Blender, usually after some editing | ||||
| * of keyframe data has occurred. They ensure that keyframe data is properly ordered and | * of keyframe data has occurred. They ensure that keyframe data is properly ordered and | ||||
| * that the handles are correct. | * that the handles are correct. | ||||
| */ | */ | ||||
| eFCU_Cycle_Type BKE_fcurve_get_cycle_type(FCurve *fcu) | eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const FCurve *fcu) | ||||
| { | { | ||||
| FModifier *fcm = fcu->modifiers.first; | FModifier *fcm = fcu->modifiers.first; | ||||
| if (!fcm || fcm->type != FMODIFIER_TYPE_CYCLES) { | if (!fcm || fcm->type != FMODIFIER_TYPE_CYCLES) { | ||||
| return FCU_CYCLE_NONE; | return FCU_CYCLE_NONE; | ||||
| } | } | ||||
| if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) { | if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) { | ||||
| Show All 16 Lines | if (ELEM(data->before_mode, FCM_EXTRAPOLATE_CYCLIC, FCM_EXTRAPOLATE_CYCLIC_OFFSET) && | ||||
| ELEM(data->after_mode, FCM_EXTRAPOLATE_CYCLIC, FCM_EXTRAPOLATE_CYCLIC_OFFSET)) { | ELEM(data->after_mode, FCM_EXTRAPOLATE_CYCLIC, FCM_EXTRAPOLATE_CYCLIC_OFFSET)) { | ||||
| return FCU_CYCLE_OFFSET; | return FCU_CYCLE_OFFSET; | ||||
| } | } | ||||
| } | } | ||||
| return FCU_CYCLE_NONE; | return FCU_CYCLE_NONE; | ||||
| } | } | ||||
| bool BKE_fcurve_is_cyclic(FCurve *fcu) | bool BKE_fcurve_is_cyclic(const FCurve *fcu) | ||||
| { | { | ||||
| return BKE_fcurve_get_cycle_type(fcu) != FCU_CYCLE_NONE; | return BKE_fcurve_get_cycle_type(fcu) != FCU_CYCLE_NONE; | ||||
| } | } | ||||
| /* Shifts 'in' by the difference in coordinates between 'to' and 'from', | /* Shifts 'in' by the difference in coordinates between 'to' and 'from', | ||||
| * using 'out' as the output buffer. | * using 'out' as the output buffer. | ||||
| * When 'to' and 'from' are end points of the loop, this moves the 'in' point one loop cycle. | * When 'to' and 'from' are end points of the loop, this moves the 'in' point one loop cycle. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 989 Lines • ▼ Show 20 Lines | if (fcu->totvert == 0) { | ||||
| cvalue = evaltime; | cvalue = evaltime; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return evaluate_fcurve_ex(fcu, evaltime, cvalue); | return evaluate_fcurve_ex(fcu, evaltime, cvalue); | ||||
| } | } | ||||
| bool BKE_fcurve_is_empty(FCurve *fcu) | bool BKE_fcurve_is_empty(const FCurve *fcu) | ||||
| { | { | ||||
| return (fcu->totvert == 0) && (fcu->driver == NULL) && | return (fcu->totvert == 0) && (fcu->driver == NULL) && | ||||
| !list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE); | !list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE); | ||||
| } | } | ||||
| float calculate_fcurve(PathResolvedRNA *anim_rna, | float calculate_fcurve(PathResolvedRNA *anim_rna, | ||||
| FCurve *fcu, | FCurve *fcu, | ||||
| const AnimationEvalContext *anim_eval_context) | const AnimationEvalContext *anim_eval_context) | ||||
| ▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines | |||||