Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/fcurve.c
| Show First 20 Lines • Show All 1,866 Lines • ▼ Show 20 Lines | float evaluate_fcurve_only_curve(FCurve *fcu, float evaltime) | ||||
| * Also works for driver-fcurves when the driver itself is not relevant. | * Also works for driver-fcurves when the driver itself is not relevant. | ||||
| * E.g. when inserting a keyframe in a driver fcurve. */ | * E.g. when inserting a keyframe in a driver fcurve. */ | ||||
| return evaluate_fcurve_ex(fcu, evaltime, 0.0); | return evaluate_fcurve_ex(fcu, evaltime, 0.0); | ||||
| } | } | ||||
| float evaluate_fcurve_driver(PathResolvedRNA *anim_rna, | float evaluate_fcurve_driver(PathResolvedRNA *anim_rna, | ||||
| FCurve *fcu, | FCurve *fcu, | ||||
| ChannelDriver *driver_orig, | ChannelDriver *driver_orig, | ||||
| float evaltime) | const AnimationEvalContext *anim_eval_context) | ||||
| { | { | ||||
| BLI_assert(fcu->driver != NULL); | BLI_assert(fcu->driver != NULL); | ||||
| float cvalue = 0.0f; | float cvalue = 0.0f; | ||||
| float evaltime = anim_eval_context->eval_time; | |||||
| /* If there is a driver (only if this F-Curve is acting as 'driver'), | /* If there is a driver (only if this F-Curve is acting as 'driver'), | ||||
| * evaluate it to find value to use as "evaltime" since drivers essentially act as alternative | * evaluate it to find value to use as "evaltime" since drivers essentially act as alternative | ||||
| * input (i.e. in place of 'time') for F-Curves. */ | * input (i.e. in place of 'time') for F-Curves. */ | ||||
| if (fcu->driver) { | if (fcu->driver) { | ||||
| /* evaltime now serves as input for the curve */ | /* evaltime now serves as input for the curve */ | ||||
| evaltime = evaluate_driver(anim_rna, fcu->driver, driver_orig, evaltime); | evaltime = evaluate_driver(anim_rna, fcu->driver, driver_orig, anim_eval_context); | ||||
| /* only do a default 1-1 mapping if it's unlikely that anything else will set a value... */ | /* only do a default 1-1 mapping if it's unlikely that anything else will set a value... */ | ||||
| if (fcu->totvert == 0) { | if (fcu->totvert == 0) { | ||||
| FModifier *fcm; | FModifier *fcm; | ||||
| bool do_linear = true; | bool do_linear = true; | ||||
| /* out-of-range F-Modifiers will block, as will those which just plain overwrite the values | /* out-of-range F-Modifiers will block, as will those which just plain overwrite the values | ||||
| * XXX: additive is a bit more dicey; it really depends then if things are in range or not... | * XXX: additive is a bit more dicey; it really depends then if things are in range or not... | ||||
| Show All 25 Lines | |||||
| /* Checks if the curve has valid keys, drivers or modifiers that produce an actual curve. */ | /* Checks if the curve has valid keys, drivers or modifiers that produce an actual curve. */ | ||||
| bool BKE_fcurve_is_empty(FCurve *fcu) | bool BKE_fcurve_is_empty(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); | ||||
| } | } | ||||
| /* Calculate the value of the given F-Curve at the given frame, and set its curval */ | /* Calculate the value of the given F-Curve at the given frame, and set its curval */ | ||||
| float calculate_fcurve(PathResolvedRNA *anim_rna, FCurve *fcu, float evaltime) | float calculate_fcurve(PathResolvedRNA *anim_rna, | ||||
| FCurve *fcu, | |||||
| const AnimationEvalContext *anim_eval_context) | |||||
| { | { | ||||
| /* only calculate + set curval (overriding the existing value) if curve has | /* only calculate + set curval (overriding the existing value) if curve has | ||||
| * any data which warrants this... | * any data which warrants this... | ||||
| */ | */ | ||||
| if (BKE_fcurve_is_empty(fcu)) { | if (BKE_fcurve_is_empty(fcu)) { | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| /* calculate and set curval (evaluates driver too if necessary) */ | /* calculate and set curval (evaluates driver too if necessary) */ | ||||
| float curval; | float curval; | ||||
| if (fcu->driver) { | if (fcu->driver) { | ||||
| curval = evaluate_fcurve_driver(anim_rna, fcu, fcu->driver, evaltime); | curval = evaluate_fcurve_driver(anim_rna, fcu, fcu->driver, anim_eval_context); | ||||
| } | } | ||||
| else { | else { | ||||
| curval = evaluate_fcurve(fcu, evaltime); | curval = evaluate_fcurve(fcu, anim_eval_context->eval_time); | ||||
| } | } | ||||
| fcu->curval = curval; /* debug display only, not thread safe! */ | fcu->curval = curval; /* debug display only, not thread safe! */ | ||||
| return curval; | return curval; | ||||
| } | } | ||||