Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 24 Nov 2017 14:40:53 +0000 (15:40 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 24 Nov 2017 14:40:53 +0000 (15:40 +0100)
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/nodes/deg_node_component.cc
source/blender/depsgraph/intern/nodes/deg_node_component.h

index 221fcea5498a1e5e32e4f01d23d3ea6686eaff97..ccdec492c0a82243f0307cb890bc2cc128a61761 100644 (file)
@@ -235,9 +235,9 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(
         const char *name,
         int name_tag)
 {
-       OperationDepsNode *op_node = comp_node->has_operation(opcode,
-                                                             name,
-                                                             name_tag);
+       OperationDepsNode *op_node = comp_node->find_operation(opcode,
+                                                              name,
+                                                              name_tag);
        if (op_node == NULL) {
                op_node = comp_node->add_operation(op, opcode, name, name_tag);
                graph_->operations.push_back(op_node);
@@ -307,7 +307,7 @@ OperationDepsNode *DepsgraphNodeBuilder::find_operation_node(
         int name_tag)
 {
        ComponentDepsNode *comp_node = add_component_node(id, comp_type, comp_name);
-       return comp_node->has_operation(opcode, name, name_tag);
+       return comp_node->find_operation(opcode, name, name_tag);
 }
 
 OperationDepsNode *DepsgraphNodeBuilder::find_operation_node(
index dd499a014252036fffb7e30ba32bc3687a2f62ef..d920014d704da20d00d0dacfde27866bd9f660fe 100644 (file)
@@ -225,7 +225,7 @@ DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain,
 {
 }
 
-TimeSourceDepsNode *DepsgraphRelationBuilder::find_node(
+TimeSourceDepsNode *DepsgraphRelationBuilder::get_node(
         const TimeSourceKey &key) const
 {
        if (key.id) {
@@ -237,7 +237,7 @@ TimeSourceDepsNode *DepsgraphRelationBuilder::find_node(
        }
 }
 
-ComponentDepsNode *DepsgraphRelationBuilder::find_node(
+ComponentDepsNode *DepsgraphRelationBuilder::get_node(
         const ComponentKey &key) const
 {
        IDDepsNode *id_node = graph_->find_id_node(key.id);
@@ -251,38 +251,23 @@ ComponentDepsNode *DepsgraphRelationBuilder::find_node(
        return node;
 }
 
-OperationDepsNode *DepsgraphRelationBuilder::find_node(
+OperationDepsNode *DepsgraphRelationBuilder::get_node(
         const OperationKey &key) const
 {
-       IDDepsNode *id_node = graph_->find_id_node(key.id);
-       if (!id_node) {
-               fprintf(stderr, "find_node operation: Could not find ID\n");
-               return NULL;
-       }
-
-       ComponentDepsNode *comp_node = id_node->find_component(key.component_type,
-                                                              key.component_name);
-       if (!comp_node) {
-               fprintf(stderr, "find_node operation: Could not find component\n");
-               return NULL;
-       }
-
-       OperationDepsNode *op_node = comp_node->find_operation(key.opcode,
-                                                              key.name,
-                                                              key.name_tag);
-       if (!op_node) {
+       OperationDepsNode *op_node = find_node(key);
+       if (op_node == NULL) {
                fprintf(stderr, "find_node_operation: Failed for (%s, '%s')\n",
                        DEG_OPNAMES[key.opcode], key.name);
        }
        return op_node;
 }
 
-DepsNode *DepsgraphRelationBuilder::find_node(const RNAPathKey &key) const
+DepsNode *DepsgraphRelationBuilder::get_node(const RNAPathKey &key) const
 {
        return graph_->find_node_from_pointer(&key.ptr, key.prop);
 }
 
-OperationDepsNode *DepsgraphRelationBuilder::has_node(
+OperationDepsNode *DepsgraphRelationBuilder::find_node(
         const OperationKey &key) const
 {
        IDDepsNode *id_node = graph_->find_id_node(key.id);
@@ -294,7 +279,12 @@ OperationDepsNode *DepsgraphRelationBuilder::has_node(
        if (!comp_node) {
                return NULL;
        }
-       return comp_node->has_operation(key.opcode, key.name, key.name_tag);
+       return comp_node->find_operation(key.opcode, key.name, key.name_tag);
+}
+
+bool DepsgraphRelationBuilder::has_node(const OperationKey &key) const
+{
+       return find_node(key) != NULL;
 }
 
 void DepsgraphRelationBuilder::add_time_relation(TimeSourceDepsNode *timesrc,
index ef4b9c87c25e4f4cd6e15694bfc1e571de327886..4150accd62c8f68bbf9e0307b9ea56aee04437b6 100644 (file)
@@ -263,11 +263,13 @@ struct DepsgraphRelationBuilder
        Depsgraph *getGraph();
 
 protected:
-       TimeSourceDepsNode *find_node(const TimeSourceKey &key) const;
-       ComponentDepsNode *find_node(const ComponentKey &key) const;
+       TimeSourceDepsNode *get_node(const TimeSourceKey &key) const;
+       ComponentDepsNode *get_node(const ComponentKey &key) const;
+       OperationDepsNode *get_node(const OperationKey &key) const;
+       DepsNode *get_node(const RNAPathKey &key) const;
+
        OperationDepsNode *find_node(const OperationKey &key) const;
-       DepsNode *find_node(const RNAPathKey &key) const;
-       OperationDepsNode *has_node(const OperationKey &key) const;
+       bool has_node(const OperationKey &key) const;
 
        void add_time_relation(TimeSourceDepsNode *timesrc,
                               DepsNode *node_to,
@@ -311,7 +313,7 @@ struct DepsNodeHandle
 template <typename KeyType>
 OperationDepsNode *DepsgraphRelationBuilder::find_operation_node(const KeyType& key)
 {
-       DepsNode *node = find_node(key);
+       DepsNode *node = get_node(key);
        return node != NULL ? node->get_exit_operation() : NULL;
 }
 
@@ -320,8 +322,8 @@ void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from,
                                             const KeyTo &key_to,
                                             const char *description)
 {
-       DepsNode *node_from = find_node(key_from);
-       DepsNode *node_to = find_node(key_to);
+       DepsNode *node_from = get_node(key_from);
+       DepsNode *node_to = get_node(key_to);
        OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
        OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
        if (op_from && op_to) {
@@ -330,7 +332,6 @@ void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from,
        else {
                if (!op_from) {
                        /* XXX TODO handle as error or report if needed */
-                       node_from = find_node(key_from);
                        fprintf(stderr, "add_relation(%s) - Could not find op_from (%s)\n",
                                description, key_from.identifier().c_str());
                }
@@ -355,14 +356,12 @@ void DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from,
                                             const KeyTo &key_to,
                                             const char *description)
 {
-       TimeSourceDepsNode *time_from = find_node(key_from);
-       DepsNode *node_to = find_node(key_to);
+       TimeSourceDepsNode *time_from = get_node(key_from);
+       DepsNode *node_to = get_node(key_to);
        OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
-       if (time_from && op_to) {
+       if (time_from != NULL && op_to != NULL) {
                add_time_relation(time_from, op_to, description);
        }
-       else {
-       }
 }
 
 template <typename KeyType>
@@ -371,10 +370,10 @@ void DepsgraphRelationBuilder::add_node_handle_relation(
         const DepsNodeHandle *handle,
         const char *description)
 {
-       DepsNode *node_from = find_node(key_from);
+       DepsNode *node_from = get_node(key_from);
        OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
        OperationDepsNode *op_to = handle->node->get_entry_operation();
-       if (op_from && op_to) {
+       if (op_from != NULL && op_to != NULL) {
                add_operation_relation(op_from, op_to, description);
        }
        else {
@@ -394,7 +393,7 @@ DepsNodeHandle DepsgraphRelationBuilder::create_node_handle(
         const KeyType &key,
         const char *default_name)
 {
-       return DepsNodeHandle(this, find_node(key), default_name);
+       return DepsNodeHandle(this, get_node(key), default_name);
 }
 
 }  // namespace DEG
index bba16316288905e1bdfd8ba5d8c05248e44ec4bd..c22e74f4577cfc8d276f711e32c52c477b540d48 100644 (file)
@@ -176,34 +176,45 @@ OperationDepsNode *ComponentDepsNode::find_operation(OperationIDKey key) const
                        }
                }
        }
+       return node;
+}
 
-       if (node != NULL) {
-               return node;
-       }
-       else {
+OperationDepsNode *ComponentDepsNode::find_operation(eDepsOperation_Code opcode,
+                                                    const char *name,
+                                                    int name_tag) const
+{
+       OperationIDKey key(opcode, name, name_tag);
+       return find_operation(key);
+}
+
+OperationDepsNode *ComponentDepsNode::get_operation(OperationIDKey key) const
+{
+       OperationDepsNode *node = find_operation(key);
+       if (node == NULL) {
                fprintf(stderr, "%s: find_operation(%s) failed\n",
                        this->identifier().c_str(), key.identifier().c_str());
                BLI_assert(!"Request for non-existing operation, should not happen");
                return NULL;
        }
+       return node;
 }
 
-OperationDepsNode *ComponentDepsNode::find_operation(eDepsOperation_Code opcode,
-                                                     const char *name,
-                                                     int name_tag) const
+OperationDepsNode *ComponentDepsNode::get_operation(eDepsOperation_Code opcode,
+                                                    const char *name,
+                                                    int name_tag) const
 {
        OperationIDKey key(opcode, name, name_tag);
-       return find_operation(key);
+       return get_operation(key);
 }
 
-OperationDepsNode *ComponentDepsNode::has_operation(OperationIDKey key) const
+bool ComponentDepsNode::has_operation(OperationIDKey key) const
 {
-       return reinterpret_cast<OperationDepsNode *>(BLI_ghash_lookup(operations_map, &key));
+       return find_operation(key) != NULL;
 }
 
-OperationDepsNode *ComponentDepsNode::has_operation(eDepsOperation_Code opcode,
-                                                    const char *name,
-                                                    int name_tag) const
+bool ComponentDepsNode::has_operation(eDepsOperation_Code opcode,
+                                      const char *name,
+                                      int name_tag) const
 {
        OperationIDKey key(opcode, name, name_tag);
        return has_operation(key);
@@ -214,7 +225,7 @@ OperationDepsNode *ComponentDepsNode::add_operation(const DepsEvalOperationCb& o
                                                     const char *name,
                                                     int name_tag)
 {
-       OperationDepsNode *op_node = has_operation(opcode, name, name_tag);
+       OperationDepsNode *op_node = find_operation(opcode, name, name_tag);
        if (!op_node) {
                DepsNodeFactory *factory = deg_get_node_factory(DEG_NODE_TYPE_OPERATION);
                op_node = (OperationDepsNode *)factory->create_node(this->owner->id_orig, "", name);
index 9be5388e69f2dffae35b8a4580bc7a007929742c..ba4f8551fea0f7254f978726aca1c2f9eb431e87 100644 (file)
@@ -74,18 +74,26 @@ struct ComponentDepsNode : public DepsNode {
 
        string identifier() const;
 
-       /* Find an existing operation, will throw an assert() if it does not exist. */
+       /* Find an existing operation, if requested operation does not exist
+        * NULL will be returned.
+        */
        OperationDepsNode *find_operation(OperationIDKey key) const;
        OperationDepsNode *find_operation(eDepsOperation_Code opcode,
-                                         const char *name,
-                                         int name_tag) const;
+                                        const char *name,
+                                        int name_tag) const;
 
-       /* Check operation exists and return it. */
-       OperationDepsNode *has_operation(OperationIDKey key) const;
-       OperationDepsNode *has_operation(eDepsOperation_Code opcode,
+       /* Find an existing operation, will throw an assert() if it does not exist. */
+       OperationDepsNode *get_operation(OperationIDKey key) const;
+       OperationDepsNode *get_operation(eDepsOperation_Code opcode,
                                         const char *name,
                                         int name_tag) const;
 
+       /* Check operation exists and return it. */
+       bool has_operation(OperationIDKey key) const;
+       bool has_operation(eDepsOperation_Code opcode,
+                          const char *name,
+                          int name_tag) const;
+
        /**
         * Create a new node for representing an operation and add this to graph
         * \warning If an existing node is found, it will be modified. This helps