Fix T69573: Driver Value does not slide along the actual value in the Driver Editor

This change is two-fold:

- Ensure the result of the F-Curve evaluation is stored on the FCurve
  object. This was done in 2.79 but lost when we moved to more granular
  per-curve evaluation from the depsgraph.
- Flush this result from the CoW copy back to the original.

Reviewed by: sergey

Differential Revision: https://developer.blender.org/D5888
This commit is contained in:
Sybren A. Stüvel 2019-09-25 10:31:34 +02:00
parent d0279f7d36
commit fbfa904bce
Notes: blender-bot 2023-02-14 10:09:24 +01:00
Referenced by issue #69573, Driver Value does not slide along the actual value in the Driver Editor
3 changed files with 13 additions and 14 deletions

View File

@ -289,7 +289,7 @@ void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
void BKE_animsys_eval_driver(struct Depsgraph *depsgraph,
struct ID *id,
int driver_index,
struct ChannelDriver *driver_orig);
struct FCurve *fcu_orig);
void BKE_animsys_update_driver_array(struct ID *id);

View File

@ -4082,11 +4082,10 @@ void BKE_animsys_update_driver_array(ID *id)
}
}
void BKE_animsys_eval_driver(Depsgraph *depsgraph,
ID *id,
int driver_index,
ChannelDriver *driver_orig)
void BKE_animsys_eval_driver(Depsgraph *depsgraph, ID *id, int driver_index, FCurve *fcu_orig)
{
BLI_assert(fcu_orig != NULL);
/* TODO(sergey): De-duplicate with BKE animsys. */
PointerRNA id_ptr;
bool ok = false;
@ -4111,6 +4110,7 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
/* check if driver itself is tagged for recalculation */
/* XXX driver recalc flag is not set yet by depsgraph! */
ChannelDriver *driver_orig = fcu_orig->driver;
if ((driver_orig) && !(driver_orig->flag & DRIVER_FLAG_INVALID)) {
/* 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
@ -4121,7 +4121,7 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
if (animsys_store_rna_setting(&id_ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
/* Evaluate driver, and write results to COW-domain destination */
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);
/* Flush results & status codes to original data for UI (T59984) */
@ -4129,6 +4129,7 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
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 */
fcu_orig->curval = fcu->curval;
driver_orig->curval = fcu->driver->curval;
driver_orig->flag = fcu->driver->flag;

View File

@ -900,19 +900,17 @@ void DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcurve, int driver_index
{
/* Create data node for this driver */
ID *id_cow = get_cow_id(id);
ChannelDriver *driver_orig = fcurve->driver;
/* TODO(sergey): ideally we could pass the COW of fcu, but since it
* has not yet been allocated at this point we can't. As a workaround
* the animation systems allocates an array so we can do a fast lookup
* with the driver index. */
ensure_operation_node(
id,
NodeType::PARAMETERS,
OperationCode::DRIVER,
function_bind(BKE_animsys_eval_driver, _1, id_cow, driver_index, driver_orig),
fcurve->rna_path ? fcurve->rna_path : "",
fcurve->array_index);
ensure_operation_node(id,
NodeType::PARAMETERS,
OperationCode::DRIVER,
function_bind(BKE_animsys_eval_driver, _1, id_cow, driver_index, fcurve),
fcurve->rna_path ? fcurve->rna_path : "",
fcurve->array_index);
build_driver_variables(id, fcurve);
}