Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/fcurve.c
| Show First 20 Lines • Show All 2,845 Lines • ▼ Show 20 Lines | |||||
| /* ***************************** F-Curve - Evaluation ********************************* */ | /* ***************************** F-Curve - Evaluation ********************************* */ | ||||
| /* Evaluate and return the value of the given F-Curve at the specified frame ("evaltime") | /* Evaluate and return the value of the given F-Curve at the specified frame ("evaltime") | ||||
| * Note: this is also used for drivers | * Note: this is also used for drivers | ||||
| */ | */ | ||||
| static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue) | static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue) | ||||
| { | { | ||||
| FModifierStackStorage *storage; | |||||
| float devaltime; | float devaltime; | ||||
| /* evaluate modifiers which modify time to evaluate the base curve at */ | /* evaluate modifiers which modify time to evaluate the base curve at */ | ||||
| storage = evaluate_fmodifiers_storage_new(&fcu->modifiers); | FModifiersStackStorage storage; | ||||
| devaltime = evaluate_time_fmodifiers(storage, &fcu->modifiers, fcu, cvalue, evaltime); | storage.modifier_count = BLI_listbase_count(&fcu->modifiers); | ||||
| storage.size_per_modifier = evaluate_fmodifiers_storage_size_per_modifier(&fcu->modifiers); | |||||
| storage.buffer = alloca(storage.modifier_count * storage.size_per_modifier); | |||||
| devaltime = evaluate_time_fmodifiers(&storage, &fcu->modifiers, fcu, cvalue, evaltime); | |||||
| /* evaluate curve-data | /* evaluate curve-data | ||||
| * - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying | * - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying | ||||
| * F-Curve modifier on the stack requested the curve to be evaluated at | * F-Curve modifier on the stack requested the curve to be evaluated at | ||||
| */ | */ | ||||
| if (fcu->bezt) | if (fcu->bezt) | ||||
| cvalue = fcurve_eval_keyframes(fcu, fcu->bezt, devaltime); | cvalue = fcurve_eval_keyframes(fcu, fcu->bezt, devaltime); | ||||
| else if (fcu->fpt) | else if (fcu->fpt) | ||||
| cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime); | cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime); | ||||
| /* evaluate modifiers */ | /* evaluate modifiers */ | ||||
| evaluate_value_fmodifiers(storage, &fcu->modifiers, fcu, &cvalue, devaltime); | evaluate_value_fmodifiers(&storage, &fcu->modifiers, fcu, &cvalue, devaltime); | ||||
| evaluate_fmodifiers_storage_free(storage); | |||||
| /* if curve can only have integral values, perform truncation (i.e. drop the decimal part) | /* if curve can only have integral values, perform truncation (i.e. drop the decimal part) | ||||
| * here so that the curve can be sampled correctly | * here so that the curve can be sampled correctly | ||||
| */ | */ | ||||
| if (fcu->flag & FCURVE_INT_VALUES) | if (fcu->flag & FCURVE_INT_VALUES) | ||||
| cvalue = floorf(cvalue + 0.5f); | cvalue = floorf(cvalue + 0.5f); | ||||
| /* return evaluated value */ | /* return evaluated value */ | ||||
| ▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines | |||||