Depsgraph: fix dependencies for drivers and animation on Bone properties.

The driver code was almost there, but didn't work because ID nodes
have no outlinks - and using links won't be safe anyway because of
ordering issues. Instead, just loop over all IDNodes.

Animation is fixed simply by referring to ARMATURE_EVAL instead of
BONE in construct_node_identifier - the bArmature ID doesn't have
BONE components in any case, so the old identifier can't work.
This commit is contained in:
Sergey Sharybin
2019-04-28 20:04:55 +03:00
committed by Alexander Gavrilov
parent 788bbac5bd
commit a57fec986d
2 changed files with 16 additions and 18 deletions

View File

@@ -1336,25 +1336,24 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu)
fcu->rna_path ? fcu->rna_path : "",
fcu->array_index);
const char *rna_path = fcu->rna_path ? fcu->rna_path : "";
if (GS(id->name) == ID_AR && strstr(rna_path, "bones[")) {
if (GS(id->name) == ID_AR && STRPREFIX(rna_path, "bones[")) {
/* Drivers on armature-level bone settings (i.e. bbone stuff),
* which will affect the evaluation of corresponding pose bones. */
IDNode *arm_node = graph_->find_id_node(id);
char *bone_name = BLI_str_quoted_substrN(rna_path, "bones[");
if (arm_node != NULL && bone_name != NULL) {
if (bone_name != NULL) {
/* Find objects which use this, and make their eval callbacks
* depend on this. */
for (Relation *rel : arm_node->outlinks) {
IDNode *to_node = (IDNode *)rel->to;
/* We only care about objects with pose data which use this. */
for (IDNode *to_node : graph_->id_nodes) {
if (GS(to_node->id_orig->name) == ID_OB) {
Object *object = (Object *)to_node->id_orig;
// NOTE: object->pose may be NULL
bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
if (pchan != NULL) {
OperationKey bone_key(
&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL);
add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
/* We only care about objects with pose data which use this. */
if (object->data == id && object->pose != NULL) {
bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
if (pchan != NULL) {
OperationKey bone_key(
&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL);
add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
}
}
}
}

View File

@@ -202,12 +202,11 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
return node_identifier;
}
else if (ptr->type == &RNA_Bone) {
const Bone *bone = static_cast<const Bone *>(ptr->data);
/* Armature-level bone, but it ends up going to bone component
* anyway. */
// NOTE: the ID in this case will end up being bArmature.
node_identifier.type = NodeType::BONE;
node_identifier.component_name = bone->name;
/* Armature-level bone mapped to Armature Eval, and thus Pose Init.
* Drivers have special code elsewhere that links them to the pose
* bone components, instead of using this generic code. */
node_identifier.type = NodeType::PARAMETERS;
node_identifier.operation_code = OperationCode::ARMATURE_EVAL;
return node_identifier;
}
else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) {