Fix T53614: New Depsgraph ignores NLA strips
The new depsgraph was only considering the active action when attaching relations from the AnimData component/operation to the properties that are affected by the animation data. As a result, only properties animated by the active action were working, while those animated by NLA strips did not change when playing back/scrubbing the timeline. This commit fixes this introducing a recursive method to properly visit all NLA strips, and calling DepsRelBuilder::build_animdata_curves_targets() on each of those strips.
This commit is contained in:
@@ -916,18 +916,7 @@ void DepsgraphRelationBuilder::build_animdata_curves(ID *id)
|
|||||||
ComponentKey adt_key(id, DEG_NODE_TYPE_ANIMATION);
|
ComponentKey adt_key(id, DEG_NODE_TYPE_ANIMATION);
|
||||||
TimeSourceKey time_src_key;
|
TimeSourceKey time_src_key;
|
||||||
add_relation(time_src_key, adt_key, "TimeSrc -> Animation");
|
add_relation(time_src_key, adt_key, "TimeSrc -> Animation");
|
||||||
/* Build relations from animation operation to properties it changes. */
|
/* Get source operations. */
|
||||||
build_animdata_curves_targets(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_animdata_curves_targets(ID *id)
|
|
||||||
{
|
|
||||||
AnimData *adt = BKE_animdata_from_id(id);
|
|
||||||
if (adt == NULL || adt->action == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* Get source operation. */
|
|
||||||
ComponentKey adt_key(id, DEG_NODE_TYPE_ANIMATION);
|
|
||||||
DepsNode *node_from = get_node(adt_key);
|
DepsNode *node_from = get_node(adt_key);
|
||||||
BLI_assert(node_from != NULL);
|
BLI_assert(node_from != NULL);
|
||||||
if (node_from == NULL) {
|
if (node_from == NULL) {
|
||||||
@@ -935,10 +924,28 @@ void DepsgraphRelationBuilder::build_animdata_curves_targets(ID *id)
|
|||||||
}
|
}
|
||||||
OperationDepsNode *operation_from = node_from->get_exit_operation();
|
OperationDepsNode *operation_from = node_from->get_exit_operation();
|
||||||
BLI_assert(operation_from != NULL);
|
BLI_assert(operation_from != NULL);
|
||||||
|
/* Build relations from animation operation to properties it changes. */
|
||||||
|
if (adt->action != NULL) {
|
||||||
|
build_animdata_curves_targets(id, adt_key,
|
||||||
|
operation_from,
|
||||||
|
&adt->action->curves);
|
||||||
|
}
|
||||||
|
BLI_LISTBASE_FOREACH(NlaTrack *, nlt, &adt->nla_tracks) {
|
||||||
|
build_animdata_nlastrip_targets(id, adt_key,
|
||||||
|
operation_from,
|
||||||
|
&nlt->strips);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepsgraphRelationBuilder::build_animdata_curves_targets(
|
||||||
|
ID *id, ComponentKey &adt_key,
|
||||||
|
OperationDepsNode *operation_from,
|
||||||
|
ListBase *curves)
|
||||||
|
{
|
||||||
/* Iterate over all curves and build relations. */
|
/* Iterate over all curves and build relations. */
|
||||||
PointerRNA id_ptr;
|
PointerRNA id_ptr;
|
||||||
RNA_id_pointer_create(id, &id_ptr);
|
RNA_id_pointer_create(id, &id_ptr);
|
||||||
BLI_LISTBASE_FOREACH(FCurve *, fcu, &adt->action->curves) {
|
BLI_LISTBASE_FOREACH(FCurve *, fcu, curves) {
|
||||||
PointerRNA ptr;
|
PointerRNA ptr;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
int index;
|
int index;
|
||||||
@@ -969,6 +976,25 @@ void DepsgraphRelationBuilder::build_animdata_curves_targets(ID *id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DepsgraphRelationBuilder::build_animdata_nlastrip_targets(
|
||||||
|
ID *id, ComponentKey &adt_key,
|
||||||
|
OperationDepsNode *operation_from,
|
||||||
|
ListBase *strips)
|
||||||
|
{
|
||||||
|
BLI_LISTBASE_FOREACH(NlaStrip *, strip, strips) {
|
||||||
|
if (strip->act != NULL) {
|
||||||
|
build_animdata_curves_targets(id, adt_key,
|
||||||
|
operation_from,
|
||||||
|
&strip->act->curves);
|
||||||
|
}
|
||||||
|
else if (strip->strips.first != NULL) {
|
||||||
|
build_animdata_nlastrip_targets(id, adt_key,
|
||||||
|
operation_from,
|
||||||
|
&strip->strips);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_animdata_drivers(ID *id)
|
void DepsgraphRelationBuilder::build_animdata_drivers(ID *id)
|
||||||
{
|
{
|
||||||
AnimData *adt = BKE_animdata_from_id(id);
|
AnimData *adt = BKE_animdata_from_id(id);
|
||||||
|
|||||||
@@ -201,7 +201,14 @@ struct DepsgraphRelationBuilder
|
|||||||
RootPChanMap *root_map);
|
RootPChanMap *root_map);
|
||||||
void build_animdata(ID *id);
|
void build_animdata(ID *id);
|
||||||
void build_animdata_curves(ID *id);
|
void build_animdata_curves(ID *id);
|
||||||
void build_animdata_curves_targets(ID *id);
|
void build_animdata_curves_targets(ID *id,
|
||||||
|
ComponentKey &adt_key,
|
||||||
|
OperationDepsNode *operation_from,
|
||||||
|
ListBase *curves);
|
||||||
|
void build_animdata_nlastrip_targets(ID *id,
|
||||||
|
ComponentKey &adt_key,
|
||||||
|
OperationDepsNode *operation_from,
|
||||||
|
ListBase *strips);
|
||||||
void build_animdata_drivers(ID *id);
|
void build_animdata_drivers(ID *id);
|
||||||
void build_driver(ID *id, FCurve *fcurve);
|
void build_driver(ID *id, FCurve *fcurve);
|
||||||
void build_driver_data(ID *id, FCurve *fcurve);
|
void build_driver_data(ID *id, FCurve *fcurve);
|
||||||
|
|||||||
Reference in New Issue
Block a user