diff options
Diffstat (limited to 'source')
5 files changed, 78 insertions, 50 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index ec07d1e5fc0..95535355bb5 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -266,7 +266,7 @@ OperationDepsNode *DepsgraphRelationBuilder::get_node( DepsNode *DepsgraphRelationBuilder::get_node(const RNAPathKey &key) const { - return graph_->find_node_from_pointer(&key.ptr, key.prop); + return graph_->find_node_from_pointer(&key.ptr, key.prop, key.source); } OperationDepsNode *DepsgraphRelationBuilder::find_node( @@ -1233,7 +1233,8 @@ void DepsgraphRelationBuilder::build_animdata_curves_targets( { continue; } - DepsNode *node_to = graph_->find_node_from_pointer(&ptr, prop); + DepsNode *node_to = graph_->find_node_from_pointer( + &ptr, prop, RNAPointerSource::ENTRY); if (node_to == NULL) { continue; } @@ -1402,7 +1403,6 @@ 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 : ""; - const RNAPathKey self_key(id, rna_path); if (GS(id->name) == ID_AR && strstr(rna_path, "bones[")) { /* Drivers on armature-level bone settings (i.e. bbone stuff), * which will affect the evaluation of corresponding pose bones. @@ -1443,20 +1443,19 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) } } else if (rna_path != NULL && rna_path[0] != '\0') { - RNAPathKey property_key(id, rna_path); - if (RNA_pointer_is_null(&property_key.ptr)) { + RNAPathKey property_entry_key(id, rna_path, RNAPointerSource::ENTRY); + if (RNA_pointer_is_null(&property_entry_key.ptr)) { /* TODO(sergey): This would only mean that driver is broken. * so we can't create relation anyway. However, we need to avoid * adding drivers which are known to be buggy to a dependency - * graph, in order to save computational power. - */ + * graph, in order to save computational power. */ return; } - add_relation(driver_key, property_key, "Driver -> Driven Property"); + add_relation( + driver_key, property_entry_key, "Driver -> Driven Property"); /* Similar to the case with f-curves, driver might drive a nested * datablock, which means driver execution should wait for that - * datablock to be copied. - */ + * datablock to be copied. */ { PointerRNA id_ptr; PointerRNA ptr; @@ -1472,13 +1471,14 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) } } } - if (property_key.prop != NULL && - RNA_property_is_idprop(property_key.prop)) + if (property_entry_key.prop != NULL && + RNA_property_is_idprop(property_entry_key.prop)) { + RNAPathKey property_exit_key(id, rna_path, RNAPointerSource::EXIT); OperationKey parameters_key(id, DEG_NODE_TYPE_PARAMETERS, DEG_OPCODE_PARAMETERS_EVAL); - add_relation(property_key, + add_relation(property_exit_key, parameters_key, "Driven Property -> Properties"); } @@ -1494,8 +1494,7 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu) fcu->rna_path ? fcu->rna_path : "", fcu->array_index); const char *rna_path = fcu->rna_path ? fcu->rna_path : ""; - const RNAPathKey self_key(id, rna_path); - + const RNAPathKey self_key(id, rna_path, RNAPointerSource::ENTRY); LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) { /* Only used targets. */ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar) @@ -1548,22 +1547,28 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu) add_relation(target_key, driver_key, "Target -> Driver"); } else if (dtar->rna_path != NULL && dtar->rna_path[0] != '\0') { - RNAPathKey variable_key(dtar->id, dtar->rna_path); - if (RNA_pointer_is_null(&variable_key.ptr)) { + RNAPathKey variable_exit_key( + dtar->id, dtar->rna_path, RNAPointerSource::EXIT); + if (RNA_pointer_is_null(&variable_exit_key.ptr)) { continue; } - if (is_same_bone_dependency(variable_key, self_key) || - is_same_nodetree_node_dependency(variable_key, self_key) || - is_same_shapekey_dependency(variable_key, self_key)) + if (is_same_bone_dependency(variable_exit_key, self_key) || + is_same_nodetree_node_dependency(variable_exit_key, self_key) || + is_same_shapekey_dependency(variable_exit_key, self_key)) { continue; } - add_relation(variable_key, driver_key, "RNA Target -> Driver"); + add_relation(variable_exit_key, + driver_key, + "RNA Target -> Driver"); if (proxy_from != NULL) { RNAPathKey proxy_from_variable_key(&proxy_from->id, - dtar->rna_path); + dtar->rna_path, + RNAPointerSource::EXIT); + RNAPathKey variable_entry_key( + dtar->id, dtar->rna_path, RNAPointerSource::ENTRY); add_relation(proxy_from_variable_key, - variable_key, + variable_entry_key, "Proxy From -> Variable"); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 03212f6d0c8..3b1a2d00e98 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -164,16 +164,18 @@ struct OperationKey struct RNAPathKey { - /* NOTE: see depsgraph_build.cpp for implementation */ - RNAPathKey(ID *id, const char *path); - - RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop); + RNAPathKey(ID *id, const char *path, RNAPointerSource source); + RNAPathKey(ID *id, + const PointerRNA &ptr, + PropertyRNA *prop, + RNAPointerSource source); string identifier() const; ID *id; PointerRNA ptr; PropertyRNA *prop; + RNAPointerSource source; }; struct DepsgraphRelationBuilder diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc index 3aae358dda3..f86959a1693 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc @@ -34,7 +34,7 @@ namespace DEG { -///////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Time source. TimeSourceKey::TimeSourceKey() @@ -52,7 +52,7 @@ string TimeSourceKey::identifier() const return string("TimeSourceKey"); } -///////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Component. ComponentKey::ComponentKey() @@ -82,7 +82,7 @@ string ComponentKey::identifier() const return result; } -///////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Operation. OperationKey::OperationKey() @@ -189,30 +189,35 @@ string OperationKey::identifier() const return result; } -///////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // RNA path. -RNAPathKey::RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop) +RNAPathKey::RNAPathKey(ID *id, const char *path, RNAPointerSource source) : id(id), - ptr(ptr), - prop(prop) -{ -} - -RNAPathKey::RNAPathKey(ID *id, const char *path) - : id(id) + source(source) { - /* create ID pointer for root of path lookup */ + /* Create ID pointer for root of path lookup. */ PointerRNA id_ptr; RNA_id_pointer_create(id, &id_ptr); - /* try to resolve path... */ + /* Try to resolve path. */ int index; - if (!RNA_path_resolve_full(&id_ptr, path, &this->ptr, &this->prop, &index)) { - this->ptr = PointerRNA_NULL; - this->prop = NULL; + if (!RNA_path_resolve_full(&id_ptr, path, &ptr, &prop, &index)) { + ptr = PointerRNA_NULL; + prop = NULL; } } +RNAPathKey::RNAPathKey(ID *id, + const PointerRNA &ptr, + PropertyRNA *prop, + RNAPointerSource source) + : id(id), + ptr(ptr), + prop(prop), + source(source) +{ +} + string RNAPathKey::identifier() const { const char *id_name = (id) ? id->name : "<No ID>"; diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index dabab482eff..d7da6658e3e 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -121,6 +121,7 @@ Depsgraph::~Depsgraph() static bool pointer_to_component_node_criteria( const PointerRNA *ptr, const PropertyRNA *prop, + RNAPointerSource /*source*/, ID **id, eDepsNode_Type *type, const char **subdata, @@ -287,16 +288,16 @@ static bool pointer_to_component_node_criteria( /* Convenience wrapper to find node given just pointer + property. */ DepsNode *Depsgraph::find_node_from_pointer(const PointerRNA *ptr, - const PropertyRNA *prop) const + const PropertyRNA *prop, + RNAPointerSource source) const { ID *id; eDepsNode_Type node_type; const char *component_name, *operation_name; eDepsOperation_Code operation_code; int operation_name_tag; - if (pointer_to_component_node_criteria( - ptr, prop, + ptr, prop, source, &id, &node_type, &component_name, &operation_code, &operation_name, &operation_name_tag)) { diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index 27dd27c923b..a816fcc32df 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -103,6 +103,20 @@ struct DepsRelation { void unlink(); }; +/* For queries which gives operation node or key defines whether we are + * interested in a result of the given property or whether we are linking some + * dependency to that property. */ +enum class RNAPointerSource { + /* Query will return pointer to an entry operation of component which is + * responsible for evaluation of the given property. */ + ENTRY, + /* Query will return pointer to an exit operation of component which is + * responsible for evaluation of the given property. + * More precisely, it will return operation at which the property is known + * to be evaluated. */ + EXIT, +}; + /* ********* */ /* Depsgraph */ @@ -125,9 +139,10 @@ struct Depsgraph { * results in inner nodes being returned * * \return A node matching the required characteristics if it exists - * or NULL if no such node exists in the graph - */ - DepsNode *find_node_from_pointer(const PointerRNA *ptr, const PropertyRNA *prop) const; + * or NULL if no such node exists in the graph */ + DepsNode *find_node_from_pointer(const PointerRNA *ptr, + const PropertyRNA *prop, + RNAPointerSource source) const; TimeSourceDepsNode *add_time_source(); TimeSourceDepsNode *find_time_source() const; |