From f3fce877b34154224ff0d1e7789b28382fa8f0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 6 Oct 2020 13:13:42 +0200 Subject: Cleanup: Depsgraph, reduce nesting of driver relations code Reduce nesting of `DepsgraphRelationBuilder::build_driver_data()` by flipping conditions and `return`/`continue` early. No functional changes. --- .../intern/builder/deg_builder_relations.cc | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 525f9e304cb..26839c67324 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1484,31 +1484,35 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) /* Drivers on armature-level bone settings (i.e. bbone stuff), * which will affect the evaluation of corresponding pose bones. */ Bone *bone = (Bone *)property_entry_key.ptr.data; - if (bone != nullptr) { - /* Find objects which use this, and make their eval callbacks - * depend on this. */ - for (IDNode *to_node : graph_->id_nodes) { - if (GS(to_node->id_orig->name) == ID_OB) { - Object *object = (Object *)to_node->id_orig; - /* We only care about objects with pose data which use this. */ - if (object->data == id_ptr && object->pose != nullptr) { - bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone->name); - if (pchan != nullptr) { - OperationKey bone_key( - &object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL); - add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone"); - } - } - } + if (bone == nullptr) { + fprintf(stderr, "Couldn't find armature bone name for driver path - '%s'\n", rna_path); + return; + } + + /* Find objects which use this, and make their eval callbacks depend on this. */ + for (IDNode *to_node : graph_->id_nodes) { + if (GS(to_node->id_orig->name) != ID_OB) { + continue; } - /* Make the driver depend on COW, similar to the generic case below. */ - if (id_ptr != id) { - ComponentKey cow_key(id_ptr, NodeType::COPY_ON_WRITE); - add_relation(cow_key, driver_key, "Driven CoW -> Driver", RELATION_CHECK_BEFORE_ADD); + + /* We only care about objects with pose data which use this. */ + Object *object = (Object *)to_node->id_orig; + if (object->data != id_ptr || object->pose == nullptr) { + continue; + } + + bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone->name); + if (pchan == nullptr) { + continue; } + + OperationKey bone_key(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL); + add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone"); } - else { - fprintf(stderr, "Couldn't find armature bone name for driver path - '%s'\n", rna_path); + /* Make the driver depend on COW, similar to the generic case below. */ + if (id_ptr != id) { + ComponentKey cow_key(id_ptr, NodeType::COPY_ON_WRITE); + add_relation(cow_key, driver_key, "Driven CoW -> Driver", RELATION_CHECK_BEFORE_ADD); } } else { -- cgit v1.2.3