Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/anim_sys.c
| Show First 20 Lines • Show All 4,076 Lines • ▼ Show 20 Lines | if (adt && adt->drivers.first) { | ||||
| int driver_index = 0; | int driver_index = 0; | ||||
| for (FCurve *fcu = adt->drivers.first; fcu; fcu = fcu->next) { | for (FCurve *fcu = adt->drivers.first; fcu; fcu = fcu->next) { | ||||
| adt->driver_array[driver_index++] = fcu; | adt->driver_array[driver_index++] = fcu; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void BKE_animsys_eval_driver(Depsgraph *depsgraph, | void BKE_animsys_eval_driver(Depsgraph *depsgraph, ID *id, int driver_index, FCurve *fcu_orig) | ||||
sergey: Ideally we should store original fcurve pointer similar to how we do it in `ParticleSystem… | |||||
| ID *id, | |||||
| int driver_index, | |||||
| ChannelDriver *driver_orig) | |||||
| { | { | ||||
| BLI_assert(fcu_orig != NULL); | |||||
| /* TODO(sergey): De-duplicate with BKE animsys. */ | /* TODO(sergey): De-duplicate with BKE animsys. */ | ||||
| PointerRNA id_ptr; | PointerRNA id_ptr; | ||||
| bool ok = false; | bool ok = false; | ||||
| /* Lookup driver, accelerated with driver array map. */ | /* Lookup driver, accelerated with driver array map. */ | ||||
| const AnimData *adt = BKE_animdata_from_id(id); | const AnimData *adt = BKE_animdata_from_id(id); | ||||
| FCurve *fcu; | FCurve *fcu; | ||||
| if (adt->driver_array) { | if (adt->driver_array) { | ||||
| fcu = adt->driver_array[driver_index]; | fcu = adt->driver_array[driver_index]; | ||||
| } | } | ||||
| else { | else { | ||||
| fcu = BLI_findlink(&adt->drivers, driver_index); | fcu = BLI_findlink(&adt->drivers, driver_index); | ||||
| } | } | ||||
| DEG_debug_print_eval_subdata_index( | DEG_debug_print_eval_subdata_index( | ||||
| depsgraph, __func__, id->name, id, "fcu", fcu->rna_path, fcu, fcu->array_index); | depsgraph, __func__, id->name, id, "fcu", fcu->rna_path, fcu, fcu->array_index); | ||||
| RNA_id_pointer_create(id, &id_ptr); | RNA_id_pointer_create(id, &id_ptr); | ||||
| /* check if this driver's curve should be skipped */ | /* check if this driver's curve should be skipped */ | ||||
| if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) { | if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) { | ||||
| /* check if driver itself is tagged for recalculation */ | /* check if driver itself is tagged for recalculation */ | ||||
| /* XXX driver recalc flag is not set yet by depsgraph! */ | /* XXX driver recalc flag is not set yet by depsgraph! */ | ||||
| ChannelDriver *driver_orig = fcu_orig->driver; | |||||
Done Inline Actionsfcu_orig is not supposed to be NULL. Add an assert at the top and avoid NULL pointers checks later on. sergey: `fcu_orig` is not supposed to be `NULL`. Add an assert at the top and avoid NULL pointers… | |||||
| if ((driver_orig) && !(driver_orig->flag & DRIVER_FLAG_INVALID)) { | if ((driver_orig) && !(driver_orig->flag & DRIVER_FLAG_INVALID)) { | ||||
Not Done Inline ActionsThis seems very dodgy. Access to original is only allowed for an active dependency graph. Render thread should not be querying state of original data. sergey: This seems very dodgy. Access to original is only allowed for an active dependency graph. | |||||
| /* evaluate this using values set already in other places | /* evaluate this using values set already in other places | ||||
| * NOTE: for 'layering' option later on, we should check if we should remove old value before | * NOTE: for 'layering' option later on, we should check if we should remove old value before | ||||
| * adding new to only be done when drivers only changed */ | * adding new to only be done when drivers only changed */ | ||||
| // printf("\told val = %f\n", fcu->curval); | // printf("\told val = %f\n", fcu->curval); | ||||
| PathResolvedRNA anim_rna; | PathResolvedRNA anim_rna; | ||||
| if (animsys_store_rna_setting(&id_ptr, fcu->rna_path, fcu->array_index, &anim_rna)) { | if (animsys_store_rna_setting(&id_ptr, fcu->rna_path, fcu->array_index, &anim_rna)) { | ||||
| /* Evaluate driver, and write results to COW-domain destination */ | /* Evaluate driver, and write results to COW-domain destination */ | ||||
| const float ctime = DEG_get_ctime(depsgraph); | const float ctime = DEG_get_ctime(depsgraph); | ||||
| const float curval = evaluate_fcurve_driver(&anim_rna, fcu, driver_orig, ctime); | const float curval = calculate_fcurve(&anim_rna, fcu, ctime); | ||||
| ok = animsys_write_rna_setting(&anim_rna, curval); | ok = animsys_write_rna_setting(&anim_rna, curval); | ||||
| /* Flush results & status codes to original data for UI (T59984) */ | /* Flush results & status codes to original data for UI (T59984) */ | ||||
| if (ok && DEG_is_active(depsgraph)) { | if (ok && DEG_is_active(depsgraph)) { | ||||
| animsys_write_orig_anim_rna(&id_ptr, fcu->rna_path, fcu->array_index, curval); | animsys_write_orig_anim_rna(&id_ptr, fcu->rna_path, fcu->array_index, curval); | ||||
| /* curval is displayed in the UI, and flag contains error-status codes */ | /* curval is displayed in the UI, and flag contains error-status codes */ | ||||
| fcu_orig->curval = fcu->curval; | |||||
| driver_orig->curval = fcu->driver->curval; | driver_orig->curval = fcu->driver->curval; | ||||
| driver_orig->flag = fcu->driver->flag; | driver_orig->flag = fcu->driver->flag; | ||||
| DriverVar *dvar_orig = driver_orig->variables.first; | DriverVar *dvar_orig = driver_orig->variables.first; | ||||
| DriverVar *dvar = fcu->driver->variables.first; | DriverVar *dvar = fcu->driver->variables.first; | ||||
| for (; dvar_orig && dvar; dvar_orig = dvar_orig->next, dvar = dvar->next) { | for (; dvar_orig && dvar; dvar_orig = dvar_orig->next, dvar = dvar->next) { | ||||
| DriverTarget *dtar_orig = &dvar_orig->targets[0]; | DriverTarget *dtar_orig = &dvar_orig->targets[0]; | ||||
| DriverTarget *dtar = &dvar->targets[0]; | DriverTarget *dtar = &dvar->targets[0]; | ||||
| Show All 18 Lines | |||||
Ideally we should store original fcurve pointer similar to how we do it in ParticleSystem::orig_psys and avoid binding subdata pointers.
This is separate story though.